此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 }+ S5 f) V4 m& @0 Y7 f
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% y+ V7 @# R& `8 V
方式一:
+ l. E4 T4 z+ @ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% u+ q/ ]) \2 @2 q, Z
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# G+ z7 U6 K/ Q- W5 n, k ]9 `4 Z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。% F1 J4 I% }2 d+ n, J- e
方式二:
6 w! N/ u* c: R! }; e 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: j8 x" V# B/ Q2 p& j& u2 R
SetTitleMatchMode RegEx7 _; S( @+ W& |- a; S
return5 c: b0 \& N( O- A3 y
; Stuff to do when Windows Explorer is open
l& }0 E% h* w$ D& H- @0 g- D ;
/ d- u5 |9 F0 a #IfWinActive ahk_class ExploreWClass|CabinetWClass
; W1 k) o2 \' ^7 P% F' W ; open ‘cmd’ in the current directory
+ J( }( W. O+ k ;+ g8 v5 g( p$ \* x
#c::
- M8 y0 n# F0 {' e OpenCmdInCurrent()
3 u1 F; `& \$ v) I3 S$ Q' L3 ]/ G return2 @. H8 Y7 S2 q( k! @
#IfWinActive
f h: L. ?, g/ l, \7 E4 w) n ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) s6 }% f4 a) A% J, ~' N. E; t
; Note: expecting to be run when the active window is Explorer.' P6 p/ } |' C- ^
;
- D; d w$ ` H7 u" f OpenCmdInCurrent(); n! O1 T+ F3 C3 ^
{
* ~0 k7 q. J0 P% S5 F/ s ; This is required to get the full path of the file from the address bar
; M, g" |4 i- {* D+ D1 p- \ WinGetText, full_path, A
$ l$ @$ p; c4 v+ o4 v4 q ; Split on newline (`n)
2 q4 |% N( ]' j7 {' Q StringSplit, word_array, full_path, `n2 ?+ ^4 J; e3 l- s
; Take the first element from the array
* w/ w$ W& q b5 F2 j5 q full_path = %word_array1%8 n( C, }$ H" ?, J& o3 f
; strip to bare address" w( \4 W# v2 `2 \6 ^3 c
full_path := RegExReplace(full_path, “地址: “, “”)" c% s8 L+ @9 ~: J
; Just in case – remove all carriage returns (`r)
' g+ \0 S* R( Z# q3 z- \# w StringReplace, full_path, full_path, `r, , all
2 r/ @! U0 g3 G! F% D IfInString full_path, \: j* l, A( b2 e2 v* `9 P% k1 e- j1 e
{. e. f' D* I+ B. A! J8 w! I
Run, cmd /K cd /D “%full_path%”0 C0 B3 w# _+ u" Z) \7 ~
}
4 o8 f3 h" e( A/ v" y3 s' B6 B else
& w; Q9 ?, O7 |; X) u) t {
+ B& z; `$ h" D# k! D( x7 [8 | Run, cmd /K cd /D “C:\ ”9 e" M% Z) B+ r' T
}
: z: n! M5 s0 r: T; ] }. W5 s; b4 k( q: {; }2 c( D n
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 B5 d& z8 H- b; m$ Z1 h4 E4 p# I
这段小代码肯能有两个你需要修改的地方
9 O' y: }% H& ~; j4 H+ \; j' Q 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 ?6 R. R% Q7 ~1 H5 ]/ A- [! I 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 l e; J0 ]! e' e+ Z1 @+ M1 b7 e. T- c
|