此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ ^7 g M, x/ ~, D }8 L8 Q6 N
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 ]% F4 \. d1 j2 ~3 i) L 方式一:! h# A4 y- U2 R* U5 ^( |' H
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 s& a$ J$ u8 ?7 f
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- T( w. C8 v0 b$ }# h, W HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 J% ^$ ^3 a3 g. @3 `8 P3 r9 [
方式二:! M/ X* b0 G& t3 ? J7 v8 A+ n) _/ H
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 e% ^4 e; a! |% Z% ^. P
SetTitleMatchMode RegEx
x5 ^' j! O+ R1 @, h5 v return
& t4 P' Y1 S8 P1 g, G" s. j( H ; Stuff to do when Windows Explorer is open
, K$ g1 Q& c$ X* u# B% i! { ;/ d( K( w7 _2 H- j2 c4 p
#IfWinActive ahk_class ExploreWClass|CabinetWClass# c- r8 P O! E, V2 \! P
; open ‘cmd’ in the current directory
" U% ]" y) P# K) G9 m* I ;7 }) k& w9 v$ p! ?
#c::
0 d( R h$ X9 A' e9 f OpenCmdInCurrent()4 s. Z: P4 m$ C3 }9 _8 r# ]* c+ U
return
" }( X8 ]* Q8 r8 O; O #IfWinActive) y; ]0 U, b m
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: a9 n w7 k/ Z. \
; Note: expecting to be run when the active window is Explorer.- |: v0 H/ S2 O# z
;" m+ j A) t( g# ?
OpenCmdInCurrent()* Z0 ~3 A0 z: ?$ |) B/ F$ J* P7 `
{% Z/ r2 h5 \* t) ?" V5 N
; This is required to get the full path of the file from the address bar
8 ~% c" l+ A! K9 x WinGetText, full_path, A
0 }2 O! E- ?. A: K ; Split on newline (`n) B6 Z) r/ o9 W
StringSplit, word_array, full_path, `n1 z0 d Y! J- [, j& G
; Take the first element from the array! C7 e! o3 h3 p8 W
full_path = %word_array1%9 u1 F. V3 I2 G+ u7 W! f
; strip to bare address) `9 ]5 k- s* ~! M0 U0 B
full_path := RegExReplace(full_path, “地址: “, “”)0 t0 o8 `* U1 A/ g$ x
; Just in case – remove all carriage returns (`r)
4 x& g, \. ^1 N StringReplace, full_path, full_path, `r, , all* G+ @4 q/ {( l
IfInString full_path, \" b& V3 Q* ?: K
{
/ ^& j) Z# l/ f9 f8 ` Run, cmd /K cd /D “%full_path%”/ v* d: t/ D( F5 _; B7 n
}
8 @- Z( X9 E* e/ I' J else ^$ p0 u: J1 {2 c$ D Q* Y
{+ V* k7 i h! _) C1 V- L
Run, cmd /K cd /D “C:\ ”4 X3 o0 t& D5 @: @# ?% f$ U5 I
}
$ S% j/ |7 [( G0 V' n }7 U( j5 U/ B W0 N9 O; M
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 k, K! Z( P& \9 q8 m1 v& q+ ]+ _. n
这段小代码肯能有两个你需要修改的地方( X) e) y0 X m% V7 V# f
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 ?- B) C8 @' s4 k3 s7 @: x 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 |( K: h- x1 K3 _
|