此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
* |* m0 a- P+ ]. c 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: s# c( W* s* ~2 \1 t# n4 \) \
方式一:& |; k" ^) g) `2 j$ P( r
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,0 k( O1 x: P- e2 {8 _
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
# l! V0 d$ s. B% p- b8 N) D3 `2 g HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
0 w5 S3 {" T2 S4 H! q' w; h 方式二:) Q3 _0 [5 X6 f7 M9 G7 f6 s
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, G' z c1 P2 a! M- t
SetTitleMatchMode RegEx
( R, g7 q$ ^2 h7 k6 l, a( ?+ X return2 _8 \8 q5 z0 a0 f$ D/ l
; Stuff to do when Windows Explorer is open
- M5 e' \8 k: I7 y6 }/ z% m ;
/ o& L3 h; c# b! N2 U# B# L; q #IfWinActive ahk_class ExploreWClass|CabinetWClass
& R0 _) W( v _: T0 T9 a' _ ; open ‘cmd’ in the current directory K* R# O6 F2 o+ i; ~; m
;
* @" I# r0 `! U% O( F7 [3 x #c::4 e' W4 |) L' C! E# Y! m; _, k
OpenCmdInCurrent()5 v+ z+ m% H* M8 I' R) P- G; w( i
return2 j6 c, E$ Z: @" L3 V0 y$ J' P
#IfWinActive x3 [. ]3 `, r% x5 ^5 [+ \/ z
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 U$ M; A3 F$ t3 V/ W
; Note: expecting to be run when the active window is Explorer.
$ @8 u8 q. V5 q& T) D ;/ ^% p# y+ o0 [ A& l& h
OpenCmdInCurrent()
( M! ]# `% W8 q% V2 L6 D- q {
5 G! p9 b3 Z3 S5 {. k6 _' O5 `: C ; This is required to get the full path of the file from the address bar
6 Y" s* U; u8 w- S' `# B T WinGetText, full_path, A$ c# p; `$ I2 J i
; Split on newline (`n), n+ k1 a7 f) y/ D; R# t
StringSplit, word_array, full_path, `n
6 ^7 K' O) R- c, J6 g ; Take the first element from the array
8 f8 [+ }# K0 O( X. l2 C3 I full_path = %word_array1%& B1 b5 n% ?9 E4 ~4 ? V6 x$ f* M
; strip to bare address
# h2 h, {* C4 A( w" e8 N& V full_path := RegExReplace(full_path, “地址: “, “”)
: i3 {0 J+ s- @9 Y) {. U5 U ; Just in case – remove all carriage returns (`r)
3 j7 e6 g1 @8 O9 @; A StringReplace, full_path, full_path, `r, , all
4 V$ O; `7 W$ O- d" x$ T' n' }: u IfInString full_path, \- n, E) a; S3 H* `, G- i5 C1 C. i
{
: X- b9 e* G, m: b: J, z- M7 a$ G Run, cmd /K cd /D “%full_path%”
$ P6 {" `) q2 M' C5 R% J w# m }
5 r9 n# s7 P, k# i& ^9 _6 i3 R6 _ else$ U5 Z" I. r. n
{# n9 o) C! {! y. {; j4 r
Run, cmd /K cd /D “C:\ ”
; T5 x/ V S6 T* t: d8 ] }( Y. o: }; @& G/ ]7 O5 E
}: V& Y: ^- o% e0 }) ?' l* J
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 p. l7 K* u2 n
这段小代码肯能有两个你需要修改的地方" H7 O- \5 n8 l9 m
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ i) ^! [ \7 f9 B7 _- a7 K 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! j w+ g/ ]9 L6 h
|