此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& U4 Z$ j1 H$ K. y- B
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 o5 n# {8 x( a, |" S% c) @7 D 方式一:
6 q" G. d: g1 I3 |2 p3 K/ U& y" e, i 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
9 {2 K& H0 h7 @4 L 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和 q7 {) M; p' O- z1 p! S
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
, K+ t: R0 e4 `* G% t7 S3 c 方式二:
- p" _. g ?, S6 A, A 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 `3 E6 L7 j4 |) i0 l+ a, G
SetTitleMatchMode RegEx. s( e3 p1 _3 Q3 a3 R0 v8 M
return/ b0 Q5 Y D3 `+ n
; Stuff to do when Windows Explorer is open
- i' k: L, l4 j ;
% C, ^8 G8 F( u( ^" i #IfWinActive ahk_class ExploreWClass|CabinetWClass9 x3 P0 e! s. r; @ [
; open ‘cmd’ in the current directory: y0 T% Y) B0 o& q( V
;8 v+ I1 N: o/ f( y' a6 x
#c::5 @ H" a5 `, j* A6 q q0 k
OpenCmdInCurrent()
+ g- S3 _2 ]2 g return) U! z$ l, n2 c4 n" p, _
#IfWinActive9 x4 _* B6 a, s& u( m
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 p- d7 Y/ h T4 _) V, d8 y) C
; Note: expecting to be run when the active window is Explorer.: c* Z2 s7 @! z7 a) ?
;! A1 j+ h5 [, Y- ?
OpenCmdInCurrent(); \( I1 z* U5 q/ k; c
{& U' g. u2 }1 M
; This is required to get the full path of the file from the address bar9 Z6 s0 D& `, q8 ], W3 _1 c3 ~
WinGetText, full_path, A
7 e% o' g4 e0 \# J% h9 e* @% s* l: O ; Split on newline (`n)
' t* m, A% W0 D+ q- m1 @' ~* o1 q StringSplit, word_array, full_path, `n
0 ?% x. t+ O5 j3 W* J ; Take the first element from the array
% n. D: l$ O- n6 n. r1 ], e: L( P9 c full_path = %word_array1%2 {' Y7 p' L; ^' L% W$ {6 J
; strip to bare address
9 d- C- O; q o/ m full_path := RegExReplace(full_path, “地址: “, “”)
$ T$ z7 P; u& U' x) a ; Just in case – remove all carriage returns (`r)
0 k# H6 e' |' z2 V+ x StringReplace, full_path, full_path, `r, , all
+ C) A/ c. l8 b* v, I9 ? IfInString full_path, \
, I0 T8 x# G2 r5 b {$ X5 T Y! T2 _: @ [6 M
Run, cmd /K cd /D “%full_path%”2 m+ N" ]2 p. Q! |* E8 l/ I7 _
}7 t5 w8 l6 f: b# M
else& S* v1 i2 q: ~
{
! p+ L {. h/ }1 N; L' R7 z# ~ Run, cmd /K cd /D “C:\ ”# h' P: F; X5 a. t) \0 C% t# e, J
}
4 |' d- S5 e3 | }
$ \9 x2 X5 Q% I3 B; f$ J, ~ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 b, V& u: L+ W. ]* @/ L3 v 这段小代码肯能有两个你需要修改的地方3 g1 |( K+ l6 z: r- B
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, o8 c$ P! i: ~) d 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ H9 x% K6 B$ Y0 A3 M; \( l
|