此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 D- W8 p* U' ^1 t5 j, I. p 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。0 K4 _4 r; E j$ F2 l% q
方式一:1 @/ i' A! F% D% V! N+ s
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- m3 | r5 s1 M- h' y, z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 e# H8 D! h, d- J( E& p HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) J# Q+ V5 p" b) L+ V5 V$ @ 方式二:0 p" R- W" Z8 g, `0 y
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
% K; S! j O6 i SetTitleMatchMode RegEx+ i. R4 z3 C7 J; t
return
; l" X% E2 _( j2 V5 p, F1 D ; Stuff to do when Windows Explorer is open u: b6 P7 B* w: y3 A j! U" J/ W) ^
;
3 F& U; J) T7 ]0 _- ]' ^& z #IfWinActive ahk_class ExploreWClass|CabinetWClass4 ?$ @2 `. n0 c( U
; open ‘cmd’ in the current directory
I/ b# G) z2 b- M3 E* e, K ;
) i# d& V$ |: o1 _: {% f9 ]/ V+ H #c::* P# [& n3 ^- m! a: G9 I% j2 v
OpenCmdInCurrent() W; v1 s5 i. v ~4 r1 D
return2 A9 r0 H/ Y0 M" ^( E! {
#IfWinActive
0 u; @# H4 ?) y ^- P& i: M7 p" y8 ` ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 H, w# V$ M$ F( p, p3 S
; Note: expecting to be run when the active window is Explorer.
. p" I) Y+ L+ V8 c V( q8 ] ;6 I: j! w5 q9 ?' u- e& l- G8 D
OpenCmdInCurrent()( E5 O; p% t+ J# ^1 @2 g
{) j: q5 V# r$ |$ c* W
; This is required to get the full path of the file from the address bar) o7 D- z: o7 B1 o
WinGetText, full_path, A
2 Z5 k) ^: `+ t ; Split on newline (`n)
8 b) ~, S4 T( |# F StringSplit, word_array, full_path, `n3 _4 X6 K; b P2 a4 c. P/ [+ B+ R8 b
; Take the first element from the array
* i& L" J1 _4 T ]+ k! r3 |# U1 \ full_path = %word_array1%. p# h( b f7 K# [; B9 B
; strip to bare address% R- G* V( \7 m5 W2 s4 e
full_path := RegExReplace(full_path, “地址: “, “”)
3 G0 k- A! B2 g8 q8 L2 } ; Just in case – remove all carriage returns (`r)
( n. E: l; K0 r2 L+ K/ @ StringReplace, full_path, full_path, `r, , all: n3 J7 ?/ @ u' z- M, H. H$ c
IfInString full_path, \
1 @5 J6 p" }+ V3 r {- u+ B+ P2 h# m) k( v9 o7 H$ }
Run, cmd /K cd /D “%full_path%”7 S) A5 F% \, `
}
5 p1 }' A0 Y7 @. ?1 D else
3 U; p+ Z" R/ }4 G5 Z {
& B0 r/ T# Q1 E5 _4 U. ]2 x Run, cmd /K cd /D “C:\ ”! _9 f# S7 c6 c$ [. G0 b" {( U
}
1 E L! i: b; i, ^ }
" ?1 @$ n4 i8 i* r: @4 f. k6 f 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
5 R# z# H, v5 P1 L& V# ?2 U1 d$ ~9 W7 Q 这段小代码肯能有两个你需要修改的地方% g: e$ T; l! u5 T! |
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ a3 i- r1 X% k6 y 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ J2 X# G/ w/ H& A9 A
|