此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 S( K! S" o: D2 i$ D% O
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
l6 A* _% N# m: R3 }4 ]; G 方式一:; s6 V1 I; ~( P' P0 g1 w
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 c5 P$ d. U& q2 C* X9 P$ g 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 `, H# M \- V* D6 F$ v, n' N0 v+ O
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
2 r% N) `: g3 A9 H- I0 w, | 方式二:" y2 } w8 P( U1 U3 b, b
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ A5 O+ A% p: M: t$ p' ^& t3 v SetTitleMatchMode RegEx) l( d' o3 Q1 s- r5 K
return
* N* r" |+ w' ]1 {# S5 b) A ; Stuff to do when Windows Explorer is open
% C$ e6 D6 F8 Q7 u0 ~, g$ o( \ ;6 _- h* ~% [* W- k4 W; F
#IfWinActive ahk_class ExploreWClass|CabinetWClass; n" F3 Z8 X& o' q# C; d+ {& P
; open ‘cmd’ in the current directory. x O( o9 L4 [ T
;" u2 i l- r6 S/ ?; u l
#c::
* {+ E4 S) k/ ]8 f1 G: M OpenCmdInCurrent()9 g$ h+ f, t" K! c# _: f; S
return9 _, T F7 V8 Y8 L
#IfWinActive; i, F: Y' T" D
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ _1 |- a; U& b4 z; B% K2 m
; Note: expecting to be run when the active window is Explorer.( [- d; d5 C2 X) f y" Q4 Z7 H
;; j+ |7 i2 H( f9 Y- B& l+ @2 N
OpenCmdInCurrent()
7 E1 v# B; w- _3 w8 y9 { {& H5 h8 u4 N4 }( ^
; This is required to get the full path of the file from the address bar% v; k: |- p4 x# b8 |9 k
WinGetText, full_path, A
$ q: V( Q# {; ` q ; Split on newline (`n); J; M0 R- C/ P6 }) c+ \
StringSplit, word_array, full_path, `n
( p0 M9 y7 T9 d- z7 U9 g ; Take the first element from the array
6 F; [& J- n4 ~- Q: O full_path = %word_array1%% }9 c$ Y) e3 H q' O
; strip to bare address: b- ]8 p _4 V, g+ {$ \
full_path := RegExReplace(full_path, “地址: “, “”)
5 R r, j9 s8 ~, U/ Y ; Just in case – remove all carriage returns (`r)
* a5 o" m" |" `# N, G$ v$ r: z- }9 ^ StringReplace, full_path, full_path, `r, , all) l; ]1 ~% c- u. o+ e3 @
IfInString full_path, \9 t+ u* W6 Z2 h1 u; z: Z4 e
{
0 e# F* K q2 H4 k i5 M Run, cmd /K cd /D “%full_path%”
: F" f7 K8 d" o# C }
$ K& U3 S, R* N2 G0 K& P- H( Q' r else8 K; J. I- X2 y: C
{
5 ]: }7 P( n) B Run, cmd /K cd /D “C:\ ”7 s! B% W3 v" u: q3 b( L/ Q# U; {3 {
}) y9 }) L& f" D. v5 V
}
. N' |- t: X/ q# a 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& |3 k& O7 {2 E( x+ U/ N8 D2 q5 H
这段小代码肯能有两个你需要修改的地方, V0 a4 A) b! [# ~& ^. m5 ]
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 `( L0 ]' ^$ O4 } 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 q' W8 B& G% t7 T$ [ |