此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 F$ ~, N$ q5 e4 q) R 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 z7 o% H! W! u2 o. n2 z) d# m
方式一:9 E4 d5 `3 f/ B0 X
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 g* ?* ]% u: K, P4 c# a ~# _ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: G3 z* Z& O* k. ?
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 r1 [2 I; E' f& Y
方式二:1 C9 g% B$ D6 n+ @1 f( M
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:0 M! ] p% R Q& a! ]6 J$ ~
SetTitleMatchMode RegEx g9 O/ _ Z/ L& H9 Q5 F, |
return
2 ]" v6 G8 {9 K. ] ; Stuff to do when Windows Explorer is open/ v$ p# y' {8 t$ |+ V( I) i
;
9 B+ S# o3 ^0 ?4 M Z) \ #IfWinActive ahk_class ExploreWClass|CabinetWClass' o# n) `6 S' |3 [8 {
; open ‘cmd’ in the current directory1 u& ^8 K! k4 Q
;! v3 e$ G F7 n
#c::
9 v+ X- M' K+ i+ b( h5 ~, G OpenCmdInCurrent()
+ n1 K# e3 i% C( h return& i7 I6 K0 m& C7 m" L3 v
#IfWinActive
- X+ O. P) Z: Z9 u ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ \5 e0 l) F$ q! u
; Note: expecting to be run when the active window is Explorer.7 Z0 B( V5 k$ x/ S
;" Q* Q( Z% W* n
OpenCmdInCurrent()5 T( D& r. c$ y+ l" f( i
{, W6 R7 P7 F1 B; o1 d( b
; This is required to get the full path of the file from the address bar8 B/ F ?9 u+ r1 _& A4 a8 h
WinGetText, full_path, A9 G3 v6 j! m \1 S# e
; Split on newline (`n)
1 L" F* D9 L }+ K: d+ r$ \- Q StringSplit, word_array, full_path, `n8 }, W+ Y. P% w5 g* d, u% J9 H
; Take the first element from the array
2 n6 G* a9 Q- B6 _! ^ full_path = %word_array1%2 j& Z0 z; T7 L
; strip to bare address
: I( a! r9 `# Z2 O# n full_path := RegExReplace(full_path, “地址: “, “”): w8 P4 [3 J* y; h( o
; Just in case – remove all carriage returns (`r)
3 N" j" t1 m6 m7 M+ q% y StringReplace, full_path, full_path, `r, , all
: v8 Q9 u, f3 E8 d: C& s& a IfInString full_path, \
3 ~. ]& a2 a2 `0 q) k" r {" l& g/ }9 k' e' v# j3 t7 w- g9 P
Run, cmd /K cd /D “%full_path%”2 i/ E1 G! P# h. e& t% p
}: ^0 ~) N% D) k5 U
else
& l9 q" E1 u! R, Q& j {! l D/ y' ]) z- x$ e) t: b# ^+ O
Run, cmd /K cd /D “C:\ ”
% j2 Z; h S6 j# i }
9 C$ ?% Q: S; C5 }; B/ H$ X }' y }; @) v4 x; w; D$ |% ^& J! e* ]3 O
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 M+ y. m2 N2 ^3 {+ P6 D4 a5 u" Y
这段小代码肯能有两个你需要修改的地方( j5 z0 t ~$ j# i9 J9 w
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( ^0 ^; g, L" l; D; t0 A. ^
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 h/ p% L+ `4 A" [8 g# G3 j
|