此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* j5 }( t) @' h6 B
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 r8 b& n) R5 B+ c 方式一:
. X; F3 X, L: g8 i! E 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 T/ j5 W+ U9 z% L! f5 e
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" H& N; W# J4 x
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
; Q; O0 t0 w% G% _' |0 M+ [ 方式二:
r. Q2 C. f( d9 A9 O- o+ R; R 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! m" H; d) u% |
SetTitleMatchMode RegEx
4 V5 E6 G" o9 k; r5 i9 w# m. L return; |( s1 I1 ?: ~& `% ~! d+ S
; Stuff to do when Windows Explorer is open
# X- h; `& H; F ;
3 k+ F6 D/ ]8 l6 E; r: ~5 J9 U/ q #IfWinActive ahk_class ExploreWClass|CabinetWClass
& \* a. ~% v7 \4 B ; open ‘cmd’ in the current directory/ n! U2 B2 u9 C6 y/ j$ R
;& C4 z) J3 V6 w9 _% g
#c::
, P2 I+ I3 X# S7 d OpenCmdInCurrent()
: r. ^7 x' ]% i return. {: X6 N4 F( O% l
#IfWinActive; Z6 {& x: D: v* Y2 _
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
S* p% q( X9 O ; Note: expecting to be run when the active window is Explorer.6 L5 E7 l& g& u8 s/ Z
;
$ t6 Y0 E. u5 f5 q OpenCmdInCurrent()
5 Z& b6 f; ^2 V. \1 h4 ? {) t, U1 f$ W3 \- o
; This is required to get the full path of the file from the address bar
9 e4 G; R- t% P0 }+ Z' b. R/ I3 `6 o WinGetText, full_path, A
; R% Q `' |7 F! a( Y0 I7 _+ E! G ; Split on newline (`n)
' e5 K) {+ ?0 s- T$ G StringSplit, word_array, full_path, `n
6 q4 a5 Y% `! a. M$ h) V1 j ; Take the first element from the array
! Q+ z6 Y) L, o! R3 O2 s. H( {# J& S: ~ full_path = %word_array1%
; R" T& ] x+ r x ; strip to bare address
) {. o+ X- e ^% _1 E, J: q% i full_path := RegExReplace(full_path, “地址: “, “”)
2 k! X# y1 T4 e! { ; Just in case – remove all carriage returns (`r)
( ?$ A5 k) k7 m0 i; Z StringReplace, full_path, full_path, `r, , all
H2 @8 k/ Q$ N$ \+ y; g IfInString full_path, \
4 S; _" `4 O$ F) ^2 }( q& h {
) z7 y/ ^1 @+ o" }1 X9 t/ Q* T1 h& @ Run, cmd /K cd /D “%full_path%”
5 _ _5 T$ R3 u }9 W5 g2 V, g/ W: a& ^/ Z
else
; N: w A" g, A! C7 s- P {
! [* `/ t: u0 j3 |) G, u* O Run, cmd /K cd /D “C:\ ”
* V r9 d7 y4 v( @ }
' s: C% t) f. q6 P6 a3 F! O }
l# G+ Z7 A$ w$ n0 j) F, `; V 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
; }; }' G7 ^% g7 F) k/ C$ q 这段小代码肯能有两个你需要修改的地方1 a" W# Z, `4 Q# S) d/ [. b& Y
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& T) P) p7 z8 H' X. d- b3 \1 y 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* N/ f6 V0 k% h2 y/ l |