此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
( a$ g' y9 T) j: R" _# Z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 A8 b ~6 L* s& j, G
方式一:; }9 ~# w) s$ s
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% s( m# i# O E 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和; V$ r3 N+ I3 s% @8 t9 k, @
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 i/ A" d6 g) i ?
方式二:
7 w+ O3 ]" _& o/ p: j9 q1 \" c 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:+ ^5 w4 a0 a3 g" j6 U) S
SetTitleMatchMode RegEx V; ]" }( c; [3 c% R9 n1 l
return/ u4 D, Q. X1 ~/ y; x
; Stuff to do when Windows Explorer is open3 L+ R4 S: i5 S" A
;
, A: `" w' c* S: V+ v* [/ } #IfWinActive ahk_class ExploreWClass|CabinetWClass
7 U) s+ U" ?4 m" l ; open ‘cmd’ in the current directory9 J1 t) T: _' C2 A: w0 [# j, V' H% P
;
+ {. }* T# p( A1 [# q" i% C& c #c::1 h5 y3 l5 P$ i& G6 i
OpenCmdInCurrent()
9 T8 i8 K7 ]3 g. }8 [ return, t- P0 [( P/ v( E
#IfWinActive
3 A$ {/ v/ i2 k) q. s ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 L% }( m T3 ?/ J: q ; Note: expecting to be run when the active window is Explorer.
3 a5 V* |% x3 E, ~/ [! S! E1 Z, E ;* ?3 n: I9 \( `" A0 a* `8 q8 n
OpenCmdInCurrent()
' J; |$ G4 b. K) m { A7 R* W1 ^6 B/ w. N. D: N9 L
; This is required to get the full path of the file from the address bar
/ B6 ^7 X! J2 `; T WinGetText, full_path, A
5 M5 n `- ?& D! d5 D) n5 ~' J ; Split on newline (`n). n) c) e) {7 S4 w, Y
StringSplit, word_array, full_path, `n/ W0 z# E' b1 q% p
; Take the first element from the array, [ U& I+ ~, s, I
full_path = %word_array1%4 r: {$ F. D# @( F
; strip to bare address
" x9 s7 q8 b8 q; `5 y full_path := RegExReplace(full_path, “地址: “, “”)2 z0 n% N8 u7 {+ c9 Y/ l
; Just in case – remove all carriage returns (`r)
8 M( B3 ]* s' ~8 A5 e StringReplace, full_path, full_path, `r, , all: c+ m0 D0 `. G" A+ J
IfInString full_path, \
0 L- g* J% P, _& P- M( v {* q, v$ d5 k7 I) U
Run, cmd /K cd /D “%full_path%”% F7 ?5 }7 R' f+ R7 g, T
}- Z0 b K: o) b" d
else
! s& v9 m2 l. {4 F: Y4 h' _) a {! o( a+ C( T; e$ T2 e \% X
Run, cmd /K cd /D “C:\ ”
& q' c+ |& Y/ T1 J6 h { }% v8 j% C0 L s. t% ^0 _6 h
}
1 I4 {( W$ W3 Q' s& }3 F( T0 ? 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
+ I5 A' b1 S* T. ` 这段小代码肯能有两个你需要修改的地方0 h4 `+ [# k4 _( i/ ]$ T3 v
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
: t% r! ^4 m! v 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 A/ F0 G6 u* G. v4 i, S8 U |