此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# E2 J8 t0 X- K2 S' I0 P9 I
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。0 Q* B; O5 } y
方式一: t4 Y' k y" f8 T5 u1 z
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# E4 r; l/ X( v% r* q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ S+ C1 l: ~5 t/ V; f& d HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 A( [2 [/ F# T" a8 D: ?5 v% a# a 方式二:
" {. A2 u: @7 ]7 x6 M 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& P& ?0 X2 o1 Y. A+ B2 t SetTitleMatchMode RegEx
7 \0 g7 g7 z9 m5 K5 d% b% h return1 a& h1 {# x/ r$ `
; Stuff to do when Windows Explorer is open
F& u+ n2 T- U" e4 g' H ;
. J. L* u8 v6 H' j #IfWinActive ahk_class ExploreWClass|CabinetWClass, @6 ]' W6 b3 e2 R
; open ‘cmd’ in the current directory
! H$ H& ^1 a' S& r! V ;
" S& G! \6 R7 t% i9 W #c::
5 O' E: }* e$ Z" i7 p0 N OpenCmdInCurrent()
1 l! }8 l; @! i. b3 n% ` return
& }5 Y: n3 D! q/ N, K/ O6 u #IfWinActive
2 u6 ]( P8 @. I* f S; X1 Q d- D ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 r- W2 b1 ?2 j+ O* a/ A
; Note: expecting to be run when the active window is Explorer.
. ~0 ?6 _$ A$ R) ]8 E ;, b" h( Z3 L N p7 Z0 T
OpenCmdInCurrent()
6 o5 k c1 O4 O2 ~- T+ n# Q" j {7 m, C- F F* V/ [9 d6 u
; This is required to get the full path of the file from the address bar- |. d4 ] y4 e5 x: l
WinGetText, full_path, A
+ s. A( O( K# Q% G3 }" k ; Split on newline (`n)
" ]3 s/ E6 n: V1 B" S+ w" ? StringSplit, word_array, full_path, `n
9 K! d2 ]! P; b0 ^' F7 ~' |4 Z ; Take the first element from the array& z. q* k4 v; ~6 m( I
full_path = %word_array1%
$ |; `: X, J4 t" j ; strip to bare address' }* R7 U$ [4 i
full_path := RegExReplace(full_path, “地址: “, “”)2 i* M" m8 W5 M+ J- V
; Just in case – remove all carriage returns (`r)7 e8 l8 w9 j) K& B z
StringReplace, full_path, full_path, `r, , all/ b( z+ @2 x1 O/ ]! w- h) N% V
IfInString full_path, \% f! A7 @8 E: l! u3 x! L. ?8 g0 |
{% F5 x4 r7 D- o4 k
Run, cmd /K cd /D “%full_path%”- E) Q: a& b. a/ E& l% S: u
}
8 a) b# H& Q: H9 A# m else
% B, ~ u* ]7 W) A8 B7 j {( f& h: P) ~$ u& j: g, D
Run, cmd /K cd /D “C:\ ”
- v6 A0 ^1 m' c& g3 @( e. I3 y }
5 i1 r$ ?- A6 m1 M) M }! Y3 L" N8 u' K& B! p
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( U& G" o* ~, B6 b) r7 }* S
这段小代码肯能有两个你需要修改的地方
0 i+ ^$ d% S1 K8 K& O3 J- w 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键! `. j6 Z5 F6 B
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ ~: H& ~+ A; C% w( Q
|