此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% S" M) b5 `# p0 W0 | 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 p; j$ q1 S- s7 {6 G2 u/ Y 方式一:) d4 c/ |9 C) L1 t a
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,0 a* C/ x! q* a; B( F2 b: n2 \# f3 y
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 J I0 Z2 _* C4 L HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! I9 m; _6 m* O9 w
方式二:
6 O% k4 |+ x `" e. n; U 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) K/ P6 N/ O9 ]- T SetTitleMatchMode RegEx, {7 Y5 A( A; U1 N1 N
return2 F; m/ |* R4 R3 D5 A7 Z
; Stuff to do when Windows Explorer is open- n4 b6 Y2 z1 L- _
;
4 d9 e. ~6 `% m$ o #IfWinActive ahk_class ExploreWClass|CabinetWClass
. A4 [1 q' z- t- Z, g6 \ ; open ‘cmd’ in the current directory) D3 O& m8 R# ~% R" ^3 P6 U
;4 D& X5 H) K" c" m% N( A
#c::
- C9 C" v8 X: z. ^3 b# @ OpenCmdInCurrent()
0 P1 C- ]7 m6 d' k9 k return
& _/ f4 ]- }) h: Z2 t1 ? #IfWinActive7 {4 S" Z5 Z5 q3 Y: w& b; k
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 M) U! g9 c7 q3 `- c, r' j ; Note: expecting to be run when the active window is Explorer.4 d7 f9 ?" D5 X2 Z
;, o* G' T& s# e
OpenCmdInCurrent(), Z$ L- i8 A/ m4 a" ~3 E, C
{! R9 H1 @8 P' o- V
; This is required to get the full path of the file from the address bar3 j, G; \3 R. Q) r1 M
WinGetText, full_path, A
) o" `: H/ I; a& {+ x- I ; Split on newline (`n)
8 i/ l3 E& Z% [- e) l7 g/ c1 i9 U, N StringSplit, word_array, full_path, `n
" ~/ r1 Q3 D2 A" g/ `6 | ; Take the first element from the array
& G) D3 Z& `, w, ?: m full_path = %word_array1%/ L& G; U& H; B2 {0 e6 I8 }0 ~
; strip to bare address' i+ [; c, D; T9 A
full_path := RegExReplace(full_path, “地址: “, “”)
! h) h) S& n( K a1 _2 F ; Just in case – remove all carriage returns (`r)7 b! ]$ Z" Y# x
StringReplace, full_path, full_path, `r, , all
; c) c6 w7 t# w! P; k1 _ o% D% e IfInString full_path, \
/ H5 \$ G3 `1 Z6 | {
9 X# C0 D" b/ o4 ^; P, |. f Run, cmd /K cd /D “%full_path%”
* E h; E4 W+ R/ E }
" ?/ Z5 {! }( E4 h else7 j* z1 t' o+ x6 U4 N; V/ m
{
# g6 j8 |7 n& w! }* ]' ^' t$ A0 n Run, cmd /K cd /D “C:\ ”* m3 F5 `* U( L( k
}
* R. F& d/ D! j4 ]* t9 p }
& z9 p' W5 {' J3 H: J 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。# j2 e# M% `4 _5 o' a3 U
这段小代码肯能有两个你需要修改的地方4 r7 A: z; Z$ c$ F* |3 i
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
6 W% Q |4 d! W( z0 ~& S, k! _: Z 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “7 Y$ A% i! J& N1 S/ ], F) \
|