此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 @7 K, k4 w" E) P2 D! K6 h+ M' | 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 C( P6 P6 J( T* m% p7 X$ v: ~) D( r {( d
方式一:) C1 j$ d. a/ Z R9 h
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 R6 R3 Q) ~2 ^* v) F 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和- c4 g* x2 V( F) j
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ b+ E5 _0 p/ g2 j) o
方式二:& T+ I0 k" J! e, A7 ^; E
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ P# `) s" T- g7 ^ q: r7 n1 `$ z SetTitleMatchMode RegEx1 }3 L' o2 R @
return+ r7 q }$ Y A1 U5 {" i
; Stuff to do when Windows Explorer is open
+ Q& b3 @1 n/ Z* N8 H ;
3 r" i) I( w9 A5 m& O #IfWinActive ahk_class ExploreWClass|CabinetWClass
2 Z! ?& A+ Y6 H( C ; open ‘cmd’ in the current directory
% J5 ~4 n+ L) _1 Q& J ;
4 `8 @( R5 [7 H$ P, l9 N #c::: H. A2 f: o- A d( Y, P. G/ c
OpenCmdInCurrent()- V e1 e5 ^7 j1 ~
return; |# b w D3 l3 {4 d& t3 I% [
#IfWinActive, K4 h3 g7 O+ Q! w3 Y; W
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 j( m3 h8 Q/ j+ m9 A1 O
; Note: expecting to be run when the active window is Explorer.5 y6 J6 h( L& `4 m% T/ H6 [
;
# M, O0 ]! k0 ~! [4 E OpenCmdInCurrent() C& u( c$ {; B6 P9 q
{
0 ^& z& k7 ?& E ; This is required to get the full path of the file from the address bar
" F3 x, ~$ Q8 C4 x WinGetText, full_path, A
6 d4 B1 r3 r( G) S) J k ; Split on newline (`n)' x8 g' U5 N7 l7 j2 e
StringSplit, word_array, full_path, `n& Z3 y7 U8 H: e' M; K
; Take the first element from the array
7 ]# ^- L: f. E. m2 K4 D" ]- W full_path = %word_array1%3 ]4 c6 N) a. m5 u
; strip to bare address
/ S4 k( p& c5 {% N, _: Z full_path := RegExReplace(full_path, “地址: “, “”)) q. y( k9 T2 X+ ~* z
; Just in case – remove all carriage returns (`r)
' v+ g. H" n' `3 F: h2 f) G c StringReplace, full_path, full_path, `r, , all5 E/ G$ L5 y) S/ t7 {
IfInString full_path, \
& _. c- E/ \3 v& h1 m; h/ B' z {
7 T4 y1 f4 F+ z- k" B5 L" T Run, cmd /K cd /D “%full_path%”& n7 L- C9 l5 S+ E0 F
}
3 E6 e6 ?# E4 ^: u3 ]3 n j else+ V: g3 X1 ?- e- x% k# h3 d
{
* z4 O/ j7 ]* E! E Run, cmd /K cd /D “C:\ ”
& ^; F! T* g* q5 ]7 p2 E6 e }
* \: `- {0 _8 D- W4 E3 F5 ` }7 h# C+ p8 K4 X- i( Q; Z: B: p
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& O+ c8 e% v4 b3 ?3 B
这段小代码肯能有两个你需要修改的地方
* b& d7 \9 s+ t+ \. [& Q0 b* O 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键8 V; E7 r5 Z3 l# X" S5 R
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “* W7 y2 q) G* J, N, }$ f1 ?
|