此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( Q, I% @( d" P; j
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ S! F- b& H5 u7 | 方式一:
( _8 L1 F) v( `4 J3 ~+ l) {5 U! [5 d 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
0 W- f# j' x4 J 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和& |! k! V% H% L7 M
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。# ?" ?! l. w* R6 F/ E
方式二:4 e' G# u8 ]% U1 n$ Y# Z
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# |& b9 {: B. k6 u% m7 v0 Y SetTitleMatchMode RegEx6 f% z; @' s( ^1 U
return. E V8 V. N" U$ Z0 d
; Stuff to do when Windows Explorer is open
' [" }; i F4 s2 e/ j* c' B5 x' w ;
2 p% G; k4 y0 Q; R( b# w #IfWinActive ahk_class ExploreWClass|CabinetWClass3 G- o) j% y# f4 R- P L
; open ‘cmd’ in the current directory/ j3 R; K4 M6 i2 M
;: T5 r# j5 a* a" z, f! ], @
#c::$ s& f3 z# d) h4 p
OpenCmdInCurrent()" r2 I% I7 n& A" y
return
?4 F0 f* H1 X #IfWinActive
0 s7 { J t4 ]7 R- X1 F! x ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 k8 i/ p* \0 v( ?: U$ G ; Note: expecting to be run when the active window is Explorer.
! Q- a' k" D4 d |7 O% q ;
' d- C% ]8 X- s8 i" x+ C, C OpenCmdInCurrent()9 W& b4 N8 m7 A6 k3 \. P
{( s8 V: c. l. M2 K. C: I. P
; This is required to get the full path of the file from the address bar
% g6 E5 w3 z: I0 E0 j, k7 c9 T WinGetText, full_path, A
* K* s9 q3 P$ ], z" F ; Split on newline (`n), U) l0 R" P( ?2 N0 p8 V' s2 Y
StringSplit, word_array, full_path, `n
( ]9 ]* R7 s$ ?- x4 ~ ; Take the first element from the array" T* e. q. M* E" J9 V9 k) }
full_path = %word_array1%
* X0 {9 c- ?$ u. O/ W; t2 ^ ; strip to bare address- _1 s9 e! g. X) w) b. A
full_path := RegExReplace(full_path, “地址: “, “”)
* C+ u% W8 V; Y6 t ; Just in case – remove all carriage returns (`r)
) x. e) F" V# V% ?- e" ^( G' v StringReplace, full_path, full_path, `r, , all
$ I. |, W8 f) Q( `9 n+ a2 ^ IfInString full_path, \, _! D% B2 L! `6 }+ v
{2 c+ `. M0 c: x5 c. T
Run, cmd /K cd /D “%full_path%”7 A- ]& L0 Y# T' E
}
9 \! R8 o' o- \0 |8 C! h, O: {) D1 J else
/ ^2 q; @1 n1 c0 A6 R. A% u {+ b/ d+ S/ w! i( ~/ r& b; M# w
Run, cmd /K cd /D “C:\ ”& I2 f, w/ O5 m
}/ e% R" n h- N4 f$ f# Z5 F5 M9 Q
}
# ~, q6 X) j- U, v: n" Y6 R7 V7 f 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 x2 ]- z) U5 O$ I9 p. e. H
这段小代码肯能有两个你需要修改的地方
7 ]: @, v* `3 c$ [ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% f' ]* p$ n2 d5 [/ x1 I( p
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ H2 ?, m6 j) Z5 [# s$ y
|