此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. P- b: S% }8 T+ M9 i
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 E/ C5 V; `2 i5 d8 E+ t; A
方式一:5 B" d) a; y) S& M, z
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) J2 I: S1 Q3 z; _/ w* j 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和1 y/ o' a& z* X( y
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
$ @" F. g0 K4 m [; p* J' E 方式二:
: P( v O4 V; g. S 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 o" \; F# S) U& i
SetTitleMatchMode RegEx! V( Z6 M3 }8 u6 F# c( ~
return
0 x' B* f& t" X ; Stuff to do when Windows Explorer is open
4 y! j+ B/ E1 D9 \) x ;; u: M, k2 F- v5 S" f5 O
#IfWinActive ahk_class ExploreWClass|CabinetWClass% N" g3 W7 a: |0 E& v) `. X. ^% A
; open ‘cmd’ in the current directory, T2 {# J/ |, ^8 U9 i0 E- B& a+ h
;8 p$ ~, F/ C$ V
#c::
, ?6 a ^9 W- I4 w) ~3 [ OpenCmdInCurrent()
' N, o' X' J. _% k3 a( p return4 D% V3 G1 [+ j$ C4 _. k
#IfWinActive
g; X+ x% q4 }: Y% U. Z( g ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 h* J4 ]; X" H$ E% A* k3 i3 s ~ ; Note: expecting to be run when the active window is Explorer.
/ ?) n% D: N3 r6 z/ `5 y ;
$ `* L7 N# g5 f# C( n' A OpenCmdInCurrent()& x8 Z5 X( N8 D6 Y. L& Q7 z9 u
{% S6 I# M% r: E7 w% {4 [) M
; This is required to get the full path of the file from the address bar
# @5 K" ?; t- Q" J WinGetText, full_path, A
' B7 X: z+ v" h9 n* t! | ; Split on newline (`n), y: Y( [, P- r( g c
StringSplit, word_array, full_path, `n
1 }3 W- E/ i5 t) H- N ; Take the first element from the array
! H3 n3 `% R+ a( W8 x" L y full_path = %word_array1%
" M! ^7 Y4 d) g" `( z3 A# u ; strip to bare address
/ M" E3 a/ x0 L full_path := RegExReplace(full_path, “地址: “, “”)* m, G6 c! y5 j# O
; Just in case – remove all carriage returns (`r)
6 I3 }! v( P' Y) q; a4 V( i% s/ h StringReplace, full_path, full_path, `r, , all+ b% O/ Q6 C. v0 \' D. _
IfInString full_path, \
3 T4 ]/ ~2 D' L- U6 o {6 [6 \# i9 x; j9 d) P z; j6 f$ j" N
Run, cmd /K cd /D “%full_path%”+ I' Y" _: M, U4 j- a
}* h* V: p) K: r1 O2 x- ]" f
else* j5 d |/ @% u* j
{$ {( D/ m; f! S' X! |& s, g1 c7 `
Run, cmd /K cd /D “C:\ ”
/ S: r+ H& Q/ ` K, n G: _ }
5 Q _+ Y( A: c* o) |) O }
' }+ f2 [2 \1 }7 y1 o5 q$ W3 H 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! K1 ~* y- z; F 这段小代码肯能有两个你需要修改的地方
* y o2 H) t( F" a 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 `) p+ B$ a% ]; E 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( V1 \: M% L; ^# I
|