此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。0 t0 M2 h( c: {$ {# S
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 U; h- O0 O( t ?9 [
方式一:# }$ p/ I# t. x; b+ q
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* ~1 x+ a; R+ p$ q+ s0 J 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 O0 _5 L+ E5 B1 i0 K5 v7 W HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 o5 n2 o! \1 u: X7 @" n( h
方式二:
O/ } R( B& E 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ n8 F9 t. Z" q' d% N/ _/ H SetTitleMatchMode RegEx1 e. S* x5 s% Y( p+ N) p, W
return( t, i1 Q" |5 O$ o8 X6 K9 H, T. z
; Stuff to do when Windows Explorer is open- U/ S( B6 B h, r
;
! W% T+ x1 v" h0 {# g #IfWinActive ahk_class ExploreWClass|CabinetWClass/ I) s5 F0 k; A% K$ \. |0 E
; open ‘cmd’ in the current directory* f6 S0 W$ K/ x O8 Q6 z6 `/ a
;! s6 M! \1 d2 h/ m/ B
#c::2 M! k" {% Z6 g
OpenCmdInCurrent()( a O" o) n0 E, P
return
. m) v( |" P. [* F+ v #IfWinActive
; u+ j3 ], O: [5 y ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 c" [- y5 K- \! Y. o# ]+ ^# V
; Note: expecting to be run when the active window is Explorer.
( T9 J4 J$ ~! ?4 [3 k8 ?8 y6 e ; R; _$ i7 B# V3 a& k
OpenCmdInCurrent() S) X+ v8 o7 ~1 M, [6 T; T
{' n- ^; c! ?9 E2 i3 N" O( c3 T# p
; This is required to get the full path of the file from the address bar8 ~. d, U1 d7 z) ~8 e+ U
WinGetText, full_path, A
. f5 s4 g* }7 m! ]6 x; N9 I A. j ; Split on newline (`n)
0 k8 o- ]9 w/ Z9 D4 M StringSplit, word_array, full_path, `n
, ]; d6 S' Q& U7 ?: e$ S; [, \+ k2 q ; Take the first element from the array
( \" s* d" u) `) y8 W( K full_path = %word_array1%) ?. ?! q7 ^2 E
; strip to bare address6 t; H" M/ f1 Z; Q& `
full_path := RegExReplace(full_path, “地址: “, “”)
p9 j- z. v! _# b/ c( q ; Just in case – remove all carriage returns (`r)" Q1 x+ }, G$ }4 G
StringReplace, full_path, full_path, `r, , all
4 y' V) C6 L) E IfInString full_path, \
3 K+ W: e S* d' o U {; {9 r3 I( N6 s
Run, cmd /K cd /D “%full_path%”
8 C% F8 t& P/ Z }
! D$ ?+ V5 N( B1 c+ c) p else" D6 G5 `" ~ J9 a; `- r
{
3 d$ _7 J& S7 M- i9 A- n, m Run, cmd /K cd /D “C:\ ”4 [$ h! s# v/ u/ J) E0 B$ }8 Q, u- r
}/ r" i9 [" k. ~# l& b8 K
}
* y' H- u9 Q1 w3 c; Z 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 G" r) w, g2 {! S6 U; | 这段小代码肯能有两个你需要修改的地方! K$ f1 S8 |) \/ G4 T/ a
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% a* i+ W# }. s" T 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “* Y! ~, R' B4 o& U; |( Z
|