此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 g) N$ d( ^% l# H+ n' Z5 K
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
z, A! c; c' a: V" s3 b) r 方式一:
: r& n5 s" w; h8 J/ d 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 p9 @' D# p* N) a3 a6 [ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和. X' T( t$ m/ n- ]: w) {- F! [
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 Y, W0 p! [) t1 p N& T+ O4 C
方式二:
) d/ W8 N/ L* `% K 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:- z/ R3 s: R- ?4 q
SetTitleMatchMode RegEx6 j- A! q) Y1 f( s
return: j+ n/ u3 i C2 C3 C- ?2 x
; Stuff to do when Windows Explorer is open
- w" ~% D) I/ Y+ O, c& p1 ]# w, w ;/ I c, q/ @" j6 \8 \! H
#IfWinActive ahk_class ExploreWClass|CabinetWClass/ h5 n6 c& @1 P! m- B" y: p
; open ‘cmd’ in the current directory
9 B a, Q$ p _: i ;" T* l, a* w' c3 L3 L1 s
#c::
- n2 f0 ?' G- ^# |( m OpenCmdInCurrent()) J; v) [- D7 |8 B
return4 w! `6 U7 p& b# E- f' v
#IfWinActive, I. ]5 N9 z3 [3 d- ]
; Opens the command shell ‘cmd’ in the directory browsed in Explorer., R, ^2 z |7 b5 y& B8 R
; Note: expecting to be run when the active window is Explorer.- M, o( t* R |- }' k9 T; a' S
;8 m8 A; S; j3 k' l: \
OpenCmdInCurrent()
1 z- ~' o0 W7 o6 ^1 d y {4 R' D. d9 o! ~; U* o$ i
; This is required to get the full path of the file from the address bar- @& Y% {0 g+ {. C
WinGetText, full_path, A% t0 L% [, J0 |0 k6 ~5 H
; Split on newline (`n)# H1 W$ |- N( U/ O8 e( _) J
StringSplit, word_array, full_path, `n
; A F' E; _, u7 ]: c+ \ ; Take the first element from the array/ v) N0 j$ Z( y" y
full_path = %word_array1%
2 [. G! f$ K( d2 Q0 v( G ; strip to bare address
- f( }. ^' [! t full_path := RegExReplace(full_path, “地址: “, “”)
1 g* A. c! u% B8 |/ _, T ; Just in case – remove all carriage returns (`r)
% P% i$ n2 V! \0 B) b \$ c StringReplace, full_path, full_path, `r, , all: b0 s4 p' o! d
IfInString full_path, \
b' n2 |% x( m W! h& j/ q3 y9 K6 Z) U {
" I& P: [+ s5 @" F Run, cmd /K cd /D “%full_path%”
' e! v- x8 C( H7 g: U x }9 m1 _2 t0 o! T5 L% X
else2 F; o( }% v& Q# u5 R0 X X
{6 H8 m1 x' k* z' P1 k
Run, cmd /K cd /D “C:\ ”
6 `, x4 a# [+ E3 n" j- F }; a" U5 C K0 T. p5 F
}
4 X* s5 r" y. z 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
' u! [; P5 y/ t) R. s8 W 这段小代码肯能有两个你需要修改的地方
0 q- |% d6 X! h6 } 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) t+ x: |4 i* i- x
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 u9 ^/ ~/ K3 J* o& e. _+ \ |