此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# X0 N/ ~7 B; U8 {9 z |. M% V, A
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 J, H$ I" z: ?6 m$ J9 q: E h
方式一:
8 X9 ^* U- B- U) q* j9 C 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 {$ F+ y7 c5 a
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和$ U! u$ b2 |, W, M- Z ^5 y
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ g( ^% z0 z) x. T! i9 ?
方式二:
% x' q2 w0 B& s" W' ? 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 h* `5 @9 ^4 O, Y: t3 f
SetTitleMatchMode RegEx& e1 F! I5 A3 Z5 O" O
return
7 [0 b8 v( E* y ; Stuff to do when Windows Explorer is open
. {) P6 x; v6 ]* a ;
7 p3 O, Y& j4 f" h* ] #IfWinActive ahk_class ExploreWClass|CabinetWClass
, L# c" w; o$ t- K4 [ ; open ‘cmd’ in the current directory
# E% M, j- I- q. |2 S8 | ;
0 f% z4 k# ]% N! S, f2 } #c:: z, n/ e# f$ q' c2 H) x" G
OpenCmdInCurrent()5 ?5 y/ R- p$ G- v, j8 W' P; x
return
! G9 Y! y; l% C #IfWinActive3 D2 h- W$ _5 R; S
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
! x( T$ U* b5 f+ e, M6 y ; Note: expecting to be run when the active window is Explorer.
; H S- h& ?, L$ e- { ;/ U. s7 _( r5 e$ O a/ Q; |. G
OpenCmdInCurrent()4 X8 L4 ]1 f, r6 O+ Y. j$ X
{6 x6 a: a5 n! G8 {& c6 u
; This is required to get the full path of the file from the address bar* y. e- p( m0 Q( F6 }& H
WinGetText, full_path, A: |& k; r: H7 y ~6 ~9 b, {% p
; Split on newline (`n)9 @/ X( y0 N _1 q3 }$ j, x$ s6 ^ S
StringSplit, word_array, full_path, `n
3 D4 t4 s/ C$ q# h/ k ; Take the first element from the array" M, C9 s/ a' P1 R: O Z# y& x# [
full_path = %word_array1%2 j6 P9 a3 l, h
; strip to bare address4 @) t/ O1 l W2 {5 x, ~
full_path := RegExReplace(full_path, “地址: “, “”)" ?$ S# L+ l; m9 k5 i9 L
; Just in case – remove all carriage returns (`r); y. c6 f+ e1 N& ?; h/ h% o2 V, V
StringReplace, full_path, full_path, `r, , all. w x6 P5 o& C1 r7 F/ x! F! ]
IfInString full_path, \
. m. M1 W7 u" `$ L: e5 ]6 T {/ s+ `8 h; n3 N J/ n# o& i
Run, cmd /K cd /D “%full_path%”6 V' [% t$ q: ]4 D
}6 ]+ Y% s! Y% I
else
! w( O/ G# o8 `1 W+ i9 Y$ b {: P0 ?( D; q" S+ h0 W
Run, cmd /K cd /D “C:\ ”
3 ^0 m( h) i$ R9 K$ j( n2 V }% _# S: x* {1 n. {4 ?# z) f0 M
}
2 Q- K. }9 I4 u 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) W' a" v8 S% a# ]7 L& o
这段小代码肯能有两个你需要修改的地方 g/ _$ i# b9 e. p7 P. Z7 v
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& L" s4 p6 [# E7 A% Y! W
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
+ T, i( Z6 Y; k; h! t |