此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, d) a& x- }6 a+ | Z9 }2 S
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 F, N. @( ^2 j6 D6 x
方式一:% K+ d: V! ^$ d
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ t: i& Y, P2 `- k/ t- }
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: b+ A" B% f( K
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ s! k; [& e. `$ V% f 方式二:
! N7 Q$ K% [4 w0 {* u& s& a 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" H( t' U7 p: D: z0 ]. M
SetTitleMatchMode RegEx
+ k% j2 O# E$ ~9 }/ d5 \1 ~& J a return( X" W% i. S% v9 E
; Stuff to do when Windows Explorer is open
0 Q7 k4 F2 b- e% J7 E6 C ;
: S! i1 R( P& S1 z$ M9 p* e: y l #IfWinActive ahk_class ExploreWClass|CabinetWClass$ e8 v; d( A4 p% l8 O, P" q" M
; open ‘cmd’ in the current directory( K) f% d- f3 l: k! h
;' ~8 }2 _) b7 E
#c::3 S+ w9 \% A# E& c% _
OpenCmdInCurrent()
2 I2 o7 g- ]2 X; @ return
$ b4 ^" C" B- U" k: K #IfWinActive' _% \: m8 B3 J% B& `: @% ]$ J
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ |( V9 v. A- N$ P/ G2 j0 w ; Note: expecting to be run when the active window is Explorer.
e2 A6 D1 u' v! L9 c ;- a0 q5 P( N. Q, H0 o6 V4 g- s
OpenCmdInCurrent()
8 L' _' Z/ @5 t- ?% k% L8 m {
$ X5 W" u6 H4 s$ _% r ; This is required to get the full path of the file from the address bar
* W) i% i( ]+ m9 H0 N. C, x1 v WinGetText, full_path, A. \+ g5 B) z: N1 M7 P
; Split on newline (`n)( l' p: p% i W7 F9 U
StringSplit, word_array, full_path, `n
& ^5 o ~4 a+ \( ` ; Take the first element from the array
* |4 d. ~1 g! E% o" I& k full_path = %word_array1%
1 X; y+ k7 E0 l5 g7 u) t6 W# ] ; strip to bare address
' I, _7 Z( y4 b2 Y; K; w4 d* p full_path := RegExReplace(full_path, “地址: “, “”). T5 G4 d Z5 }. S. w# X* o
; Just in case – remove all carriage returns (`r)
" Z3 ] v2 d& M StringReplace, full_path, full_path, `r, , all) V: l G) I/ g- W2 F; W2 {
IfInString full_path, \
& R2 _! q" x/ t6 I {
* p' t/ [0 I: {# m7 W Run, cmd /K cd /D “%full_path%”
" P4 a u* H D, s }
" B4 ~% f( a/ }! b2 f else9 g+ y% E8 s+ f* ]$ F& U8 m/ g6 K
{3 Y* D* d* ]) q, }# x
Run, cmd /K cd /D “C:\ ”
0 f. r$ C8 Q. b w! c }" N0 f4 V+ T$ B5 @3 I1 \. q& o
}6 e& c2 w4 v |" \
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" ?* c% {! x0 x 这段小代码肯能有两个你需要修改的地方
5 S# G7 E# d7 G) Y$ x1 E 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ T% n3 S0 h: ~ z3 l) q 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “% F+ S- W( U+ l. m$ F# \3 Y+ I& k1 U
|