此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 U; Q% B h. E, P. n 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
" j1 z! x! ~5 h 方式一:2 d, i7 W2 ~0 K" U5 w" A
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# L, d+ G5 o r) W/ n( H
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 D8 _/ _# V, V2 y# h- Z/ D
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 T( E4 S( y) R! m& F' c0 ] 方式二:4 A5 v: |3 m8 o* e4 [- S. i1 A
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 \- r* o' R: X1 B# d$ d% `' z
SetTitleMatchMode RegEx
5 n2 q1 V( v& k h1 k0 S8 R. F" W, f( f return0 D# k( x% R6 s0 p7 E B8 D: c: D1 P) T
; Stuff to do when Windows Explorer is open& @! Y5 e: U: n
;( o, I- t$ H( v y
#IfWinActive ahk_class ExploreWClass|CabinetWClass7 D- u! A0 V+ \+ J/ g
; open ‘cmd’ in the current directory$ |: P" [; C+ H6 s
;
7 G5 l* r$ h# d% u9 ?* i0 }! N6 a #c::
" [0 n" ~6 e+ p3 G+ T: U; e OpenCmdInCurrent()9 g+ B) X% M0 g: D' L5 n2 q
return. `, p& N) Z( p" t
#IfWinActive- n6 q) I) h, y
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
# `5 G- J$ i; S: w. o ; Note: expecting to be run when the active window is Explorer.; U1 B! ]. _! G S1 B/ q- g9 r
;* R1 B# P8 ~9 T ^' \0 o
OpenCmdInCurrent(), A2 l$ C- Z- K) k: o' M8 e: E
{0 F7 X: ]! A2 G
; This is required to get the full path of the file from the address bar
7 t& T* J3 y ]% P2 ?( R WinGetText, full_path, A
, K, v3 V0 c9 Z) m ; Split on newline (`n)
* c/ D& S# P& ^5 o4 x StringSplit, word_array, full_path, `n' ^0 [8 v$ e5 B, S, O0 q. W
; Take the first element from the array, F* S( H0 ~& C3 p/ M) `4 C) d
full_path = %word_array1%
) Y/ p0 z8 M# R5 V ; strip to bare address
- G, l0 r* Y+ E( Y/ ~4 ` full_path := RegExReplace(full_path, “地址: “, “”)
9 z: l7 k, u- | ; Just in case – remove all carriage returns (`r)4 j C+ w- x& o9 B
StringReplace, full_path, full_path, `r, , all
* V6 ~1 A b. J IfInString full_path, \# Q& U c. z o
{
5 ]. C$ B2 ~0 J0 u* H( U% r! l Run, cmd /K cd /D “%full_path%”( E: M7 J$ i: N. ]* J
}% A- p9 J4 {( G8 t5 D- Z
else! y+ F: R4 B( V0 ]4 @0 r
{
+ d4 {# F1 |3 W( P3 s2 M Run, cmd /K cd /D “C:\ ”" S1 I/ u, x, t- ~
}
' ?) N1 s5 ?5 H" ~1 ~ }
/ t& l1 I5 d3 p* M, e 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( @: z5 }6 V2 D" ]
这段小代码肯能有两个你需要修改的地方
4 p3 u: m* R+ M8 a/ l 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键1 K0 N {$ N' d5 W) T7 y8 ^
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 g1 i* e. V& t4 V9 K6 }" s |