此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 |% x, U& [2 Q! n 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 U8 d7 M; ^/ X$ r+ r
方式一:
- ~ V# [ ^/ k; d7 i g% G 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* Q- O+ B) P. b9 ?5 A! `0 R 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和- {5 O/ O/ Y- m( c1 U
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* U" \% J# ~3 ~' v$ [& q* d6 d 方式二:
: C% P+ `6 |! y+ [8 @ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, G0 E0 R9 r. p+ {, H( ?5 R9 r1 g) x
SetTitleMatchMode RegEx' c6 @) Y/ ^" o# o" n3 G
return# h( F) b5 F! B% V
; Stuff to do when Windows Explorer is open1 n% j- n( t. G& b9 }
;% ^2 A) @* J1 ~8 M
#IfWinActive ahk_class ExploreWClass|CabinetWClass
* ]/ _ y$ U) X/ x0 ^7 K ; open ‘cmd’ in the current directory
0 }" \* L5 i9 k) l/ V" f2 a0 Z ;
3 g* R5 J0 T9 u# e #c::$ Q: a) y9 v! Z8 {7 y& f" M
OpenCmdInCurrent()* {% u9 F( ] {/ h& x \1 L
return
0 p5 A l# ~( b( r #IfWinActive- X; z; r4 z* }7 \ Y) b$ I* [
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) h8 g' V& C1 h4 |" ` ; Note: expecting to be run when the active window is Explorer.& ]$ H5 ]8 c8 B) X; N7 y
;
9 [7 u/ ^2 z7 Q! [$ r: }: m. Y- B6 D OpenCmdInCurrent(); n7 p( }% W+ z2 X* A; O
{9 y# E- l# h' L( Q ~( z6 z0 z
; This is required to get the full path of the file from the address bar' y: M2 x1 N$ L/ S) N* I
WinGetText, full_path, A
# h6 A" n2 q7 y: t3 v' g: V ; Split on newline (`n)
) Z7 n1 H3 g2 Q StringSplit, word_array, full_path, `n( N2 ~! s! [9 U/ w5 S' U/ }/ R
; Take the first element from the array
* t6 |- q1 D: V; Q. x p full_path = %word_array1%( s( K. `5 z% ^( m" r' }
; strip to bare address
# m5 J/ T8 Y$ V" i% D0 I- o/ \ full_path := RegExReplace(full_path, “地址: “, “”)
0 o6 k( |& S. n W8 l ; Just in case – remove all carriage returns (`r)- f! {5 \3 F, q5 S
StringReplace, full_path, full_path, `r, , all1 Q, y) @1 w+ {
IfInString full_path, \
. k4 |5 x* T0 d! u {
) k4 p9 E* J- G: n, ? Run, cmd /K cd /D “%full_path%”
- H9 g8 y, d& f1 e- G }
( P e" U8 w+ G3 O else
/ Z, F$ f3 j2 l3 F { u( H6 P' y% \
Run, cmd /K cd /D “C:\ ”+ y0 Z# P7 r+ X# V2 N& C+ A: a
}' f' [5 h1 h) x5 q# q6 K/ r
}( D0 s4 @2 Z3 }
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 [' T; e6 r' E! O5 m1 n 这段小代码肯能有两个你需要修改的地方) e3 c3 [* M2 U) p' y1 f
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ ~! M5 i4 Y" u; l" ?' T& D7 Y 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: T0 E0 l2 e0 {2 [% n- |
|