此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 c9 s& Z- K, \& e 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。; s+ R0 F" L4 ]( A- \- Z
方式一:
% d# h# s0 |4 b; H/ x 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 n( D8 z' }* X% z* J
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' v) X( P8 D. \9 N4 ? HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。. _* K+ x+ T: b8 v/ }3 @9 i7 ^1 q
方式二:! k; h3 l6 b* t$ Y' K
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, ]: v: U% f. H) d4 R5 D
SetTitleMatchMode RegEx9 ?0 W# A3 |9 r l' \+ T
return
4 K9 C8 a: I" D# ?2 U ; Stuff to do when Windows Explorer is open3 z2 R8 h4 u% o
;3 r. S* X5 `" h# `
#IfWinActive ahk_class ExploreWClass|CabinetWClass
0 B9 | N' n( g ; open ‘cmd’ in the current directory
! _# |7 |+ C, N; {% B6 v) l ;
; U5 f6 i/ L% q #c::6 W8 C/ w' \* Z6 z: j' f
OpenCmdInCurrent()
9 D# ]& a" x' E( u4 B return
?4 y. K/ P L8 y #IfWinActive
0 R$ p' I# f+ f; ]) x ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* S, k% y& g" V1 A: _: i ; Note: expecting to be run when the active window is Explorer.
6 V$ z. P2 O0 I' h0 C! o- k ;8 G! C( g) f" ^. k
OpenCmdInCurrent()
- g6 t8 n! X; i f3 l. G- n0 a/ T {% `4 M. j( i. r
; This is required to get the full path of the file from the address bar
& _- R- _4 l8 E! e' M) B WinGetText, full_path, A- S+ {. q- N- ]! b, L% K: |3 k
; Split on newline (`n)
1 G" o9 E$ g7 `, K8 [ StringSplit, word_array, full_path, `n
5 V) \, T" V, E$ J3 } ; Take the first element from the array
2 j. Y' a: z% d' E7 h. p+ N3 u full_path = %word_array1%
( s) p' T: t l ; strip to bare address2 c. K% Y0 P7 ^* u3 W2 _9 @
full_path := RegExReplace(full_path, “地址: “, “”)
2 o: \/ c8 Z+ V- P ; Just in case – remove all carriage returns (`r)
# s( _5 y( @4 O/ o2 s4 n StringReplace, full_path, full_path, `r, , all
3 ^7 s, j1 g. c, z' B( l IfInString full_path, \8 I* X6 D" T! [6 K: o' ^ a
{/ i9 P! I! }/ D/ |9 r9 { ~
Run, cmd /K cd /D “%full_path%”4 m* p9 e ~# J7 n, `
}
0 r( ]. T( P; j else g# A9 H# p# J9 c; L4 l, V! n
{+ j" |+ m( E: ?, o# v
Run, cmd /K cd /D “C:\ ”
8 y/ E* ]! s) q& x. J }
1 r3 |& O- P R4 ~! h }8 M$ W' l" I% L, h# ` [
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# D% k; g* k/ v" _9 F4 o9 ^8 b 这段小代码肯能有两个你需要修改的地方( r. ]! }; Q ?, N
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 P0 X2 m( {2 G) H 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 C8 V2 P' z1 C! H1 U: j |