此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 n' B) V6 Y7 E; P; Q# d7 Z, p
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 u1 X7 ~9 ~5 d7 B# B& x% B0 }# K 方式一:" u1 O- l8 F1 b% Y! @% B
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
' k- m3 Z; x: R) Y c 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" o9 ^; b9 g2 g% _
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。' C* s; W* R$ u
方式二:- q5 l5 _: m- N1 A& {8 e* i0 O
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 Y0 G8 A( \# t$ A
SetTitleMatchMode RegEx* A% R* T4 K" l: }9 |# X0 y
return
; `9 k" y% Y8 C+ D' p9 P" \7 l ; Stuff to do when Windows Explorer is open
* x' d! N: r% D5 |' R ;; R8 g1 _1 z+ z$ K1 G
#IfWinActive ahk_class ExploreWClass|CabinetWClass1 q& [2 K% }0 G2 \
; open ‘cmd’ in the current directory- q @+ h* ^9 ]% n% O# ]
;
# m; s1 q7 C0 M #c::" V2 ?) u ]( G: N, y' [
OpenCmdInCurrent()1 t+ M# _; W5 y* r! w" w
return1 J! |; A! ^2 E1 J( s: \
#IfWinActive
& d y; J4 O% j3 H3 W/ i* R1 v ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
# @! S8 M3 D, o/ B5 D0 K: o ; Note: expecting to be run when the active window is Explorer.
4 O+ }3 l- {- @. n c1 |9 \$ [ ;) k b1 {5 G) L
OpenCmdInCurrent()
$ o) S& f( V- n, p, g Q {6 e1 {$ R, Q1 }$ ?! E
; This is required to get the full path of the file from the address bar; j) s/ R9 Q3 Y* b+ K: J
WinGetText, full_path, A
: L3 F/ ~, r0 G ; Split on newline (`n)0 i7 ~. }( C3 u
StringSplit, word_array, full_path, `n
( p4 R! e1 B: ]5 G) A: z ; Take the first element from the array% k9 D8 x+ B! ?* G- a
full_path = %word_array1%
8 F7 i+ K; y+ f A& [9 E) i ; strip to bare address, ~. ]! B$ j* z1 q b
full_path := RegExReplace(full_path, “地址: “, “”)
& J n" g5 H$ s* Y( b4 F+ s/ o, I ; Just in case – remove all carriage returns (`r): z2 Z0 O3 `7 ]
StringReplace, full_path, full_path, `r, , all
8 S% Y& ?0 q% J IfInString full_path, \0 \: p( w5 ?0 g* J. R
{
# W8 @% L9 F! r* ] Run, cmd /K cd /D “%full_path%”
& ?- _8 x8 E1 B; B }, y2 S" u+ B1 y# J0 s, g
else
2 V7 {7 p4 B# K, y {) S: Y, [4 ^, W7 M8 h$ ?4 x
Run, cmd /K cd /D “C:\ ”0 V+ P" }# B1 |) ~, @, @6 N5 W
}
; X) J) P. H, {! j- y* V }
7 b1 o g- Q3 I% j 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。+ j. X9 n4 O% T: E# I* J
这段小代码肯能有两个你需要修改的地方
/ j( o! [, j% U" } 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 ^. @. R% V9 Y9 E# u0 ~. j 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 i- X, {: I; v9 `
|