此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% g$ `0 H9 F. p8 h9 h5 J9 [
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 g3 H* T1 f! r7 {; R u' s2 f 方式一:
8 Q& f1 @5 P9 x 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
0 Y/ n9 E. T" S& w" q, u/ M2 E 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
3 m( _$ M8 ~! [; ^0 w HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 Y; [5 B+ ~# ?$ E! `% w0 {
方式二:$ v& \( `, b* M2 M0 E; n7 I& s
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:# S1 g# b; T5 A7 n
SetTitleMatchMode RegEx
" h, u) F; |$ n' |& C9 K6 w return
( _' H. t" `% s7 b ; Stuff to do when Windows Explorer is open
$ O Z$ s" _+ f+ j/ g ;6 @5 {5 t* H" q5 _* t
#IfWinActive ahk_class ExploreWClass|CabinetWClass# t. Q8 y/ J' u
; open ‘cmd’ in the current directory3 z! N1 d/ z, _. |6 H9 O
;
2 g4 ]4 t' f8 D, k6 _& |' i7 o3 v #c::1 H* ]$ w+ g. b5 `
OpenCmdInCurrent()4 P0 f; q# V0 M6 s0 W7 _
return2 f9 h2 D M( v' ^; O8 Z& y6 u
#IfWinActive5 [7 |. g0 v/ M! E% P
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 @) f% Z. R& }6 m5 m ; Note: expecting to be run when the active window is Explorer.
( b1 y# C/ L/ L, r' c0 |1 V' L ;' Y U E/ ^" M0 X
OpenCmdInCurrent()
) `8 O2 M' s2 b A( n& }. |: h. a {# ], B, n8 m3 y* l
; This is required to get the full path of the file from the address bar3 c+ B' `, Q' M. r. l7 M
WinGetText, full_path, A$ v$ z4 G! C5 f+ X0 d( o7 u) Y5 {
; Split on newline (`n)
" h6 {; E: A5 P1 U# y9 J StringSplit, word_array, full_path, `n4 c, @! z, j4 r+ u* Q9 D
; Take the first element from the array6 P" T( }+ t* \. Y; t/ u9 r& z
full_path = %word_array1%; a" V* l; E$ z2 T, P2 h: R6 M0 Z3 Z
; strip to bare address
) |( i" ]2 l5 O: u9 J- H5 D full_path := RegExReplace(full_path, “地址: “, “”)
5 f, {' x# j; P' H* _ ; Just in case – remove all carriage returns (`r)
. G4 g: w" M' A" P B1 ?! I: E StringReplace, full_path, full_path, `r, , all
" X' i" N: q4 Y I1 J0 P* z IfInString full_path, \; Q' [9 h' @! v% a* u( n. x
{) v2 A4 Z3 _8 y3 m5 G
Run, cmd /K cd /D “%full_path%”
% ^( B. q) T5 ~" A2 i }- J: I1 J! q% j2 O4 k2 V; [5 i
else e$ W( s( M2 |& g x/ @
{
8 ^1 d; X- \# e1 i h; ? Run, cmd /K cd /D “C:\ ”
) W& B, w: Q9 b3 S) ` }
, h* v, w3 n' x }9 k. |$ z M7 D9 R/ L
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 ?. c7 b: n- T
这段小代码肯能有两个你需要修改的地方
. [+ P, |$ p* \. `1 f N7 V2 z$ Q 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ {3 J* z1 @% s) K" C7 i6 t" a 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
J8 S* G' B6 u+ P' y |