此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
1 U& X' O b6 g% y) L 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。3 s7 e. Q5 X8 n) T4 E! O
方式一:
( K( ]! K0 W$ @* U. U: T 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* z% p9 S! q2 E. i$ [ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 u8 y* C3 h: f5 n% K+ ]/ @% p
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 \& C2 I# C) P" U* j 方式二:2 x) M. w2 P' | T2 ^) U5 M/ B- Z" ~' ]
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:# Z+ x. W$ R+ [" {% q/ |
SetTitleMatchMode RegEx9 p- R3 A, ^% V" b8 _
return% `# S7 {8 U$ M
; Stuff to do when Windows Explorer is open& `# ^& p& v/ L5 h4 K) c. ^
;; M' b* r, @. `! L! x- p+ c, c% l% a
#IfWinActive ahk_class ExploreWClass|CabinetWClass
& t, g- \, R( o5 Y0 U( `* l; s ; open ‘cmd’ in the current directory, o! l6 b0 c+ z1 v
;
# _0 o7 j% c& H E) ~# N #c::$ |' S% w' z7 @# b
OpenCmdInCurrent()) t& r, Q+ S7 d
return, q* }8 H8 W) F, w
#IfWinActive
# @5 u6 { K- G+ L w, l ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. |7 D% _! W- y+ M7 e @ ; Note: expecting to be run when the active window is Explorer. x% j& G, G% c. f/ Z
;) D4 T7 P! G D& N9 Y; Z- O( w: j
OpenCmdInCurrent()* Z3 c5 C$ e9 r l- j
{; J$ X [& V5 n& A8 x. `$ @ Z
; This is required to get the full path of the file from the address bar
}5 M- ]7 c/ l2 d+ J. R WinGetText, full_path, A# r+ r4 F# y/ M4 K
; Split on newline (`n)+ F: J- U% ~; W
StringSplit, word_array, full_path, `n; ^* H) }* K, Y8 t, v3 F
; Take the first element from the array
7 |8 W9 S! J) O q full_path = %word_array1%) L1 X$ b. {5 v- x
; strip to bare address" a7 H$ n7 e" W* o
full_path := RegExReplace(full_path, “地址: “, “”)
6 [$ h- A: B% e$ D ; Just in case – remove all carriage returns (`r)' t; }$ A Q* j+ }8 q
StringReplace, full_path, full_path, `r, , all4 @* l! A/ B% ]' g4 p/ ~# P1 t. O
IfInString full_path, \
, y! B* z8 w2 f% q, E' f; h, v {0 ~0 L2 b" O+ q7 w! {4 Z
Run, cmd /K cd /D “%full_path%”5 Q$ n2 X1 x+ @% A; d+ i* _ f. n
}7 c2 G$ B$ ^# q6 s2 K3 W
else
, ]4 _& Z8 J$ B5 a, P {7 f9 o( |* {* ]- i; q
Run, cmd /K cd /D “C:\ ”: T2 h1 _: c( I3 a8 K- ]- l
} w& b+ ^: Q, J6 |
}
/ F; V g, L# N6 F 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 ~& J/ g8 q' @# g/ W' j5 {3 L) d* r 这段小代码肯能有两个你需要修改的地方
9 B% f' i+ n3 S7 K) ^ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) R! P3 W' G( Q
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 b6 V" x1 E* u. S" i |