此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' n7 S5 w& j7 i1 O9 o- h: t
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
6 |7 l: m! t. M, f Z" y 方式一:
( y' v% Y j& k+ @- K0 g 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
! e5 K( F- A; S5 m2 E: N 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' Q8 O( ]/ \' N% _5 @
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& \3 w! f4 d7 w5 X# g 方式二:+ e! n: j Q9 z& t/ q2 R* `
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
. Y% \: }5 t% T! b, @# s& a SetTitleMatchMode RegEx2 A) ^5 b! c7 N5 j1 p1 O
return+ s) C! Q: q" @6 B8 M6 X
; Stuff to do when Windows Explorer is open
( N3 `* Z1 R1 O1 x y ;
( {1 i# B' J* R C5 y #IfWinActive ahk_class ExploreWClass|CabinetWClass$ f2 l3 t. |. `. ~& @
; open ‘cmd’ in the current directory% ]" r8 y1 C$ x6 a! V* f. T8 G
;
) X' m9 q2 K/ C$ M #c:: ]& Y3 @! N! S; m. o7 x. B7 S
OpenCmdInCurrent()) x: _; _) J/ D: n# A; v8 D5 z
return2 D8 G/ [* R, ]! D8 s$ R, r
#IfWinActive! y1 K3 R! |8 X
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.4 L4 ^+ K [: `3 _
; Note: expecting to be run when the active window is Explorer.; D! C1 Q, j. q% z2 \; N/ j
;; o/ u6 _) A0 G
OpenCmdInCurrent()8 f2 n& t! R6 C. R; H* }/ V
{
! o8 ]$ j3 Y- e$ h6 Q ; This is required to get the full path of the file from the address bar
, v# Y$ p' v2 f! j5 y WinGetText, full_path, A. r) Q2 m( Z* ]7 |. B
; Split on newline (`n)8 Z* `7 a2 M; c
StringSplit, word_array, full_path, `n
) @/ L- Z0 W0 o$ f% A0 G ; Take the first element from the array9 W0 x4 y2 k8 u- w
full_path = %word_array1%5 x# b0 h: Q% G7 Y6 D+ p
; strip to bare address
3 ]0 m8 ?, K% v( W }: e full_path := RegExReplace(full_path, “地址: “, “”)
4 P! ~0 G/ N7 ~$ s q, E2 e ; Just in case – remove all carriage returns (`r)9 `# U8 w8 X% M# p: `! I
StringReplace, full_path, full_path, `r, , all1 f' i2 T ]) N" F3 {! x- A
IfInString full_path, \
. [: A! O/ }, W2 ^# R5 j& J {* x$ K2 j w: v, {1 ^" x( L4 z) ~
Run, cmd /K cd /D “%full_path%”
5 ?- u$ r; w- F+ ~ }
) d& r- s/ X/ b' O2 M else
/ Y# N( M) }7 L {/ _! T) w h4 |$ H0 V* g
Run, cmd /K cd /D “C:\ ”
9 c$ p) n; E7 I% { }
% |( t9 l& _% _0 o }/ y& A, n* p: W' A
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 r1 b6 m* R ?. x& ] 这段小代码肯能有两个你需要修改的地方! Q& ^' z* e! y; l, @
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& J! Q. x4 \4 q" Z 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “ S$ q9 N% p3 {$ d
|