此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 S) c7 s' b9 \1 U 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 T' E/ E: X7 L# h2 W8 ^
方式一:
! B: X+ X" u2 y W5 T3 h 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表," R. N+ [8 ]5 ~# M
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, T4 t. I# ]0 a g. [
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。# \) _- s# M0 ?1 B; y s* E( A
方式二:
1 }! I! Y1 | {( Q 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
! N4 U# Q: V2 T2 P SetTitleMatchMode RegEx" |7 h4 e& F3 R2 o- `8 v# l5 k
return
! L/ s) `; y) J, r. M ; Stuff to do when Windows Explorer is open. M* X) T: [' ]
;
D. L# M C5 @( g' Q0 u #IfWinActive ahk_class ExploreWClass|CabinetWClass
1 }' K l8 k6 R4 i7 K- e8 X ; open ‘cmd’ in the current directory
1 \ L( Y; _! N) J# s ;- b4 _, G8 [% @- c8 u$ V6 B* }
#c::
+ z3 M0 x& L& t OpenCmdInCurrent()
4 a' O! x3 i0 A% n8 D2 {/ E& H return
' W2 O- C+ d1 y% ^8 x4 z #IfWinActive& G/ a& b8 t1 ?. y
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.+ t3 P8 _9 U0 F, X G2 Y- C
; Note: expecting to be run when the active window is Explorer.6 o. A+ g; `* ]- f
; p' H& L( M. }7 N
OpenCmdInCurrent()
0 i- B! W# y- m0 J; P& W {2 Y2 L% s! u* K# h5 z9 N1 x
; This is required to get the full path of the file from the address bar* o+ Q' U3 ]2 }& T6 g3 ]' p$ b2 r
WinGetText, full_path, A
7 ?$ g: F" s% N! \" [ ; Split on newline (`n)
4 O5 S% z- y5 `0 d. w- w StringSplit, word_array, full_path, `n
/ n& {5 ^( K5 |" j: _ ; Take the first element from the array* h: ]3 R0 s, I2 U3 D
full_path = %word_array1%
7 d' H. p7 Q* D, o0 Q+ r8 e ; strip to bare address
/ s* i9 W& P1 O0 T# ] full_path := RegExReplace(full_path, “地址: “, “”)
- t6 ^. D- M7 l* v3 s! w ; Just in case – remove all carriage returns (`r)3 [+ |7 D9 M; V' }* z& M3 h$ ~
StringReplace, full_path, full_path, `r, , all
! m! J, F$ ?* y IfInString full_path, \
" _, @% Q5 m- K! b6 { {
' P9 x! P8 a3 ]6 o3 s& B$ e Run, cmd /K cd /D “%full_path%”+ y, [, T2 G, c/ r" `( p; U( V) _* J
}8 l6 z0 j" i2 B' L- A
else
" `1 C& k0 r. v {
+ v' p+ q2 Z) m: X- t Run, cmd /K cd /D “C:\ ”2 r- L& E" ^6 p2 a- c. X! [ j
}
, o' d& `3 o5 C8 a4 [ }1 y$ A0 c' e/ W* |" l* A' m {
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- E* m3 @% v3 N1 n. {3 P# R 这段小代码肯能有两个你需要修改的地方; ~ y2 q$ H/ k* B# b0 E9 I5 J
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键! T4 Z4 n5 z7 X' ?* G: N5 c
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
- R1 M* X! f6 }* o, G |