此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ h( l# O c" O/ g2 a+ G J 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。- ^; @: r7 o6 c8 Y1 a" r
方式一:. q. W# D, |8 c! ?) O' r$ A# F+ W; @
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
, r" {; ^: ~5 M: K7 D 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! P1 T* f4 S- [0 h1 L) @6 W6 ^ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* }( S3 d5 }' N5 A9 X1 m, ~
方式二:7 a- F4 k- k0 i# Y* f
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 f4 k& w3 R' q: f! V5 ]- @
SetTitleMatchMode RegEx
: m5 \* t1 ~/ T5 F; h return
1 f& N& z" a' o* `1 R ; Stuff to do when Windows Explorer is open6 R( M& A2 E( ?+ u, Q
;
, z( j" w' S9 [. n1 u& d; ^/ v #IfWinActive ahk_class ExploreWClass|CabinetWClass/ \% a$ [& ^, [! ~" p
; open ‘cmd’ in the current directory/ B4 [+ ~9 s- c2 _7 _9 b- O
;$ ~6 O5 m8 f$ c9 j2 n& T6 ?
#c::9 K4 V, K' U( T) L7 H3 r
OpenCmdInCurrent(): p) s1 M6 E% G
return
/ _5 z J0 S) j- F0 R #IfWinActive( U+ l# q+ D: q7 ^
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 _+ u" b( P! Q$ \$ f9 v: l ; Note: expecting to be run when the active window is Explorer.
4 z8 F8 A$ q2 C8 C H ;6 l h8 G9 D& h7 x# a; x
OpenCmdInCurrent()
+ T$ P% M6 X3 I7 c* v( Q {2 l1 N( M& O* H9 x4 {5 r# L
; This is required to get the full path of the file from the address bar
( h2 s9 T$ P6 M2 o7 d2 | WinGetText, full_path, A
1 ^* Q* ^8 h; W/ h ; Split on newline (`n)
/ V0 _1 Z! L& u# g$ C9 {0 R" z3 `3 _ StringSplit, word_array, full_path, `n
& x: S4 o: Z- f+ P; K, O ; Take the first element from the array- t W r9 u3 n9 E
full_path = %word_array1%$ S8 y( M) A6 I7 ~
; strip to bare address% T9 J% I* E$ ?
full_path := RegExReplace(full_path, “地址: “, “”)
% ]- R+ n: ^6 n C; R ; Just in case – remove all carriage returns (`r)1 R$ j8 D; u X5 F V2 A' {
StringReplace, full_path, full_path, `r, , all: w' y0 c& ]- x% |1 G. z0 X7 K
IfInString full_path, \
/ Z. Z3 y- h; ^: S) L( ] Q5 i {
8 Z6 A. f. Z! H \' E' G9 P Run, cmd /K cd /D “%full_path%”' A, h* N: ^/ p) e: n4 p
}6 h# K( L; h% {$ s1 @
else
' D7 _- E* E5 s( K0 I9 G {- ~/ M8 V$ S' ^9 J& J2 L$ O
Run, cmd /K cd /D “C:\ ”
# l$ M2 R6 N4 N4 n7 |5 V }5 R2 z9 g- H) B9 r
}
9 C. w, L0 n$ V/ T" | q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ D$ _3 s; Z5 e7 b
这段小代码肯能有两个你需要修改的地方
2 ^: z' j2 k# Q( ^: F 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 p# s8 K& b$ o* K5 o% s- S% u2 U; A 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
, p) }* {, ?/ j. }9 {4 Y/ V& }8 f |