此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 j0 Y* L, v* W; D 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* q# J- `% R9 W1 o
方式一:
5 j" p0 A! J4 D% z6 S; k 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
0 Y) d& Y% u9 b) n7 D5 w 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和% A8 O# C1 M0 t ~( ^
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 Z' h. j0 \4 a
方式二:' u* E. e& r% t8 w' e
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:) f- J3 @3 h# z& K
SetTitleMatchMode RegEx
: K% L3 m& b" B/ c" O% p* b return
' b: e5 ]2 w# V2 m! I! K1 { ; Stuff to do when Windows Explorer is open- J& {; K, I" x; _2 Y7 z
;) X5 T6 F7 C {" U
#IfWinActive ahk_class ExploreWClass|CabinetWClass! @% _, L7 i9 Z& p3 K" P" r8 e" P
; open ‘cmd’ in the current directory
4 W. B h! i& ]2 | ;
, c' `% j; }. ~( m #c::
% y4 j& @2 i- a& s$ g OpenCmdInCurrent()
; r, \0 }- u+ d" K" S# S+ g$ C return8 a4 X+ _1 I0 n T* }' S$ T% c( N
#IfWinActive) j+ s) e% ~" a! W( V# m S0 w
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; T0 z# q+ p+ R6 ?- {: ~0 c ; Note: expecting to be run when the active window is Explorer.8 W/ n" C/ g& C" ^8 |2 x: e
;9 s- y, `% F+ m2 H" j
OpenCmdInCurrent()
1 {5 z& a+ b- M) r' ~ {
* O0 X- ]0 [2 t' s ; This is required to get the full path of the file from the address bar& A/ I4 H4 X- `- ?: r; j. Z" u
WinGetText, full_path, A
! x0 Z G4 `" Z0 O# {3 u' S( e _ ; Split on newline (`n)
6 `' A+ S3 i9 I6 {; ?/ T: i StringSplit, word_array, full_path, `n7 w3 G# T; }6 z# P+ y
; Take the first element from the array2 j" J$ I3 N: ]& r" S' S; W
full_path = %word_array1%/ c+ J, T0 @. Q6 s& g
; strip to bare address) f3 p3 Y- Z3 H4 H6 D
full_path := RegExReplace(full_path, “地址: “, “”)
: X6 h' F4 x( y: R- {* S7 F6 o ; Just in case – remove all carriage returns (`r)
3 q: b% i" d2 l" h: ]9 B StringReplace, full_path, full_path, `r, , all6 N% b3 _6 }2 z# m* Y1 K+ J: j! W
IfInString full_path, \
2 C1 f! z3 c1 d& e {
3 f! E( G) Q- l5 a Run, cmd /K cd /D “%full_path%”
) ]. L9 u( Z2 ]+ u% n* c2 a" | }
- }* T# v+ i! F0 L" t" Q) a' n( i J else
0 J6 t% b, }3 O {
( b9 r E# |& m1 b; q6 m* Z& c9 A( Q Run, cmd /K cd /D “C:\ ”
* S! A. S& d( c0 T- |6 G }; i& M! g& Z/ I. K$ S. r
}5 j. f5 l4 J( J: N3 A: V
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 L+ R$ A4 `4 F( @: C 这段小代码肯能有两个你需要修改的地方
1 c# U% V4 `4 Y- s3 f 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( [# w J# w8 F/ D$ S! [! q
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 x: `! r1 g( k! t
|