此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 C: F- x; H) C5 o, D 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
{( z/ q) b9 M 方式一:
0 H$ b% U1 V6 n. x* ]7 E 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 D1 _ s y( T3 _" q, s( ]+ m
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
$ X2 L( o" ^; B0 w( } HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
: X+ D# ~$ }& ^8 i; q r 方式二:$ {$ H2 V- c3 ^: }$ s/ z# z4 w, c
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
4 n% x5 _ }7 W: A9 I- ^8 l+ F SetTitleMatchMode RegEx( O& x- C" Q4 C' j8 G
return
1 K7 g- l: T9 i' v+ Q ; Stuff to do when Windows Explorer is open( b; `& J5 `% v9 v/ v2 E
;; m1 ~8 O0 Y1 N0 r
#IfWinActive ahk_class ExploreWClass|CabinetWClass* k8 |3 P9 j4 H
; open ‘cmd’ in the current directory6 B" d7 `: D/ E% ~9 e$ O
;$ T* }* d) q+ M6 T
#c:: S$ R4 A z, p2 p s
OpenCmdInCurrent()
) P2 c3 o2 x2 p% C s; E return# Z2 m6 l5 j e& s$ L3 K6 y
#IfWinActive; ~. I+ W- x+ [
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' N3 A! O6 x: o. s9 I0 ]# J
; Note: expecting to be run when the active window is Explorer.
# L1 h' w7 g" p ;
/ D9 W. [7 h/ _ OpenCmdInCurrent()" n. I3 I5 }# |0 G
{
! F1 |; E/ \! u ; This is required to get the full path of the file from the address bar
, t. C$ l3 `, m! z( a- p. V V WinGetText, full_path, A6 w: ]% [# F* \( B
; Split on newline (`n)
# Y8 W6 X0 F4 M, Z. R StringSplit, word_array, full_path, `n
; h, ~6 [& H" V# e ; Take the first element from the array" Y; Y5 ~+ S5 r' a
full_path = %word_array1%
1 g2 S1 Z. A, | G- @( l ; strip to bare address
' O, R4 {/ @6 T. N+ j) E full_path := RegExReplace(full_path, “地址: “, “”)3 c$ h( a) T, Q. t1 Y
; Just in case – remove all carriage returns (`r)' Z- Y% k" M8 s0 i* l6 O6 j
StringReplace, full_path, full_path, `r, , all
, N+ l/ H I+ M4 f IfInString full_path, \* A; B/ A0 m1 v$ I6 m
{' L/ Y3 k: E# \
Run, cmd /K cd /D “%full_path%”& E. I; r w) M% T- {: o* D0 s
}
, R; j$ r" Y% L% _ else
' [! A2 S3 i6 a, z# p3 w. B {) U5 q- Z' x0 g6 U0 z- _5 ]
Run, cmd /K cd /D “C:\ ”
1 |+ D5 Y' {9 ]" ~3 V4 p }
0 Z5 w( k+ Y. l" ^2 p; Y }
+ l, k. S6 h2 H8 U 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
% a( }( c: _, K5 |, u% a 这段小代码肯能有两个你需要修改的地方8 t5 B4 q) F- a4 m
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键4 C6 G3 N5 k8 D$ s) p/ o9 v2 h5 t- s
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! p9 z6 |: t! b. t5 A( h/ V |