此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ s% q& ^2 y6 ?+ b% i2 d) Q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 r* A0 g8 e6 \: _5 k- b 方式一:% T; f7 N5 X# p0 I0 ^
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
9 R: \/ T% i4 A" Z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" k+ S1 A! q. q HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 a( Y' Q u) |2 V; ]
方式二:
; \! H, Z# G$ e1 K, y! _( \ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- n# s0 r3 m7 z SetTitleMatchMode RegEx+ J' J. L5 J4 N
return
7 ]+ t* I" D/ o ; Stuff to do when Windows Explorer is open
# g* Z6 |7 O* x4 t! I% o, | ;
/ y/ v* m6 U) R' E& S$ I# K+ a #IfWinActive ahk_class ExploreWClass|CabinetWClass2 N0 T6 j# Q- h( Q& M+ b
; open ‘cmd’ in the current directory4 H7 ~; Z2 {$ h0 R4 p, F
;
6 l- s d. i8 ]+ y# A$ ` #c::- M- N; a! h) b3 b* O' o/ L5 C" D. U4 `
OpenCmdInCurrent()
5 ^$ L! {+ O1 A+ z( o return
, g3 x& K! Z+ v5 [. N/ W8 [ #IfWinActive
/ {. R9 B8 s7 S/ {# l9 t ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.; E* a3 _% _+ X; g# a# S+ s/ U
; Note: expecting to be run when the active window is Explorer.( z2 f0 r" e* Z8 H5 o( O/ L2 ^% S8 n! W
;4 t Y# Z' h% Z E, V6 `) }
OpenCmdInCurrent()
# u/ p I0 j. K0 f& z {6 n/ B b9 g9 s( q9 R; O, n+ G9 p
; This is required to get the full path of the file from the address bar
, G { u( N+ N( ^ WinGetText, full_path, A
6 b: e8 q; d3 I L ; Split on newline (`n)3 q' l( t: y" g6 b0 O1 h
StringSplit, word_array, full_path, `n0 k5 @7 n9 _' y+ ~* e6 k# J" Q
; Take the first element from the array6 q! U: S/ a. p* `9 B' b
full_path = %word_array1%
5 K/ j1 t0 b0 T) i4 E ; strip to bare address
' g: j% s X3 j' ?4 W full_path := RegExReplace(full_path, “地址: “, “”)
- Q- Y: j! c* e+ H ; Just in case – remove all carriage returns (`r)+ O* s( i: b+ j+ x
StringReplace, full_path, full_path, `r, , all
/ n1 o/ O( M& e$ Q IfInString full_path, \
- z5 K* k- s6 t {; y/ s+ D3 b0 a# W' a/ E! c
Run, cmd /K cd /D “%full_path%”
+ ?4 X) F# N+ c& B8 d, Q6 } }! \7 C0 j0 d7 v7 c0 z! G
else
( V# d! j6 _* Z0 H! ] {$ O' q/ d& E1 S% n ?1 r
Run, cmd /K cd /D “C:\ ”& Y8 }' ^' s8 d/ |& E7 Y8 D
}
& v: \" A" E7 ]9 J0 l }
( `* ~/ f3 B5 [3 a0 y5 g/ ] 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。. i& Z. r) G3 W# t3 j( B
这段小代码肯能有两个你需要修改的地方+ K2 f, @ }6 T# }
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- a/ R: O4 H& ~$ s 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 ?7 r; S# T. s- @+ p0 W/ C
|