此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* g1 z1 v% \0 h9 y) H4 l' ]) `
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& E, o# J! o! g/ R6 K 方式一:
- u S% R: a" _7 [ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 M V2 L; N5 I8 y: z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和. v3 |) ?! o- Z9 l4 j. X
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
2 f, p$ Q0 Q& M1 s3 K3 r9 ?( X 方式二:
4 w3 S* |6 U) k4 I 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:) e8 ~6 H8 r8 \. X7 u) ` Z
SetTitleMatchMode RegEx, @4 ?0 S4 Q: }( y
return0 e+ ]8 {7 I% v+ s8 a
; Stuff to do when Windows Explorer is open1 [9 H) H/ a6 a3 K/ Q# c
;* ^7 p' E( Q# c$ Q6 o. ^
#IfWinActive ahk_class ExploreWClass|CabinetWClass1 p7 v/ ?# ]* l0 i7 L9 X
; open ‘cmd’ in the current directory, G! O1 a h7 @- P* P" W2 F
;0 J' F; K3 O- i5 x
#c::/ A# K, g X# u3 ~0 i
OpenCmdInCurrent()6 W+ O- B4 g. \ U3 x* S3 C
return
" [5 M9 G5 Z) X1 L #IfWinActive8 w& V/ N" ~, ]% ~/ I D
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ o% r% H# ^3 H; n
; Note: expecting to be run when the active window is Explorer.
0 P' J2 V+ E( Q( b ;
2 O2 b" h) a! B9 o) r% r4 s OpenCmdInCurrent()$ f4 s& r) a- i
{" q: D y! {3 ?$ ^: M
; This is required to get the full path of the file from the address bar
6 j: f5 A! v( j2 S2 r WinGetText, full_path, A
6 m; D1 [$ h# z/ t; R8 f* f( h ; Split on newline (`n)4 F! Y& W! B! o% q6 y ]- q9 P5 T4 g
StringSplit, word_array, full_path, `n
6 {& z' B0 x% ]$ |; [ ; Take the first element from the array
: M8 C" \7 O) l; M# F: T full_path = %word_array1%
4 g/ r) E: D1 _" c, x' U/ a ; strip to bare address @+ a8 j; Q' D; C2 T& l. y2 U
full_path := RegExReplace(full_path, “地址: “, “”)
6 j: g. L5 N2 k- s+ k% W G ; Just in case – remove all carriage returns (`r)5 T6 @) G7 t) i2 _. `
StringReplace, full_path, full_path, `r, , all
6 G5 C2 N. l/ t9 } e IfInString full_path, \+ W/ g' X+ Z. s- u! L$ ?
{( T, u/ s. N' M6 H
Run, cmd /K cd /D “%full_path%”
$ K3 ~# X1 J) ]7 p# A$ ?& ] }
# A* N! r6 S& S4 T" z else
! s( J2 V0 e P {( F& y4 \. G9 W: P; p. h
Run, cmd /K cd /D “C:\ ”
, f! @7 R& S1 T }
$ ]! H. ~$ D( \; j I* r' R }, T( {0 s m) p$ R& N+ [7 Z4 _
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! C+ R7 ?5 r1 x: ]9 y+ Y
这段小代码肯能有两个你需要修改的地方
0 Y6 {7 n6 J9 Y$ [9 `9 o ?$ P 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' q7 ^4 [/ {3 r6 G) N8 G" o, } 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ Q) n& e2 S' a |