此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。7 U, G: g* j5 a# i0 ~3 q
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。( G* z; z- S% h' F7 w
方式一:
2 |" r6 }/ \0 T P: o 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
8 T7 ?% D$ @" \9 Z7 q0 T 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和; [ ^1 D! x" \! v( o( Q0 ?
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- {2 l) |# ]; l+ f* U
方式二:9 W$ F! [1 Q+ k4 q k" v6 N! P7 o
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: M4 a8 A% M5 |, i8 Y
SetTitleMatchMode RegEx
8 s; K# o2 y' W$ L; q+ \6 v I return
# K1 C6 P* d# z3 U ; Stuff to do when Windows Explorer is open# p( C& Y# \# o) a! w& F) u d! O
;: v7 b+ y. m( g- e3 Y4 W+ A; f6 t; ?( [) _
#IfWinActive ahk_class ExploreWClass|CabinetWClass
/ _" z0 m' A" |' m- W ; open ‘cmd’ in the current directory* c9 C, O9 {/ v+ @: P5 x* p. Z
;+ G8 H) ^. z7 P# U3 _
#c::
" f1 w* X" x& l3 b" ~ OpenCmdInCurrent()
! M# L: B, s! T5 i4 X! K: _ return
' z$ {5 P; s# S: L# U+ u #IfWinActive
: w9 M0 C6 N' C4 I ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.; P1 o' x O# B! t- U
; Note: expecting to be run when the active window is Explorer.
0 S1 N( r/ y, F& ~+ D+ m, Q ;
% ^0 h& F6 ~% c* p R OpenCmdInCurrent()' G Z- Q/ t: G) G
{
, A3 v4 @; k" t3 n d( j2 U ; This is required to get the full path of the file from the address bar1 j2 S8 _ u6 w* {( h& c/ V: B
WinGetText, full_path, A/ h' G3 ]" T5 H" }+ t
; Split on newline (`n)& L1 P- Q3 \- p+ a
StringSplit, word_array, full_path, `n5 }$ Q' L& ?6 \: K7 l$ b S
; Take the first element from the array
1 C: H/ D _5 } full_path = %word_array1%+ p+ [1 _+ p7 I2 P `( g1 T# ?! @
; strip to bare address& d) S9 T6 l7 p. ?. L
full_path := RegExReplace(full_path, “地址: “, “”)
/ S) f# F. j/ R- P ; Just in case – remove all carriage returns (`r)
+ ~1 h0 O3 v3 E7 \; X9 j' i StringReplace, full_path, full_path, `r, , all5 h- I5 ~# K/ X1 O. z6 [
IfInString full_path, \
* d* ]: P6 _7 h: J {" f# P3 `( N6 c; Z( K; h; A
Run, cmd /K cd /D “%full_path%”
8 z6 c0 P+ A& N0 l/ a }
! `* @7 n6 T1 M n/ [, {/ z9 I else6 W% z- r& E. a1 ^# O( K
{) A7 A! m7 ?4 C. w2 b3 j
Run, cmd /K cd /D “C:\ ”
* k+ ~7 F( P. m' S }% h* k! x: f+ N2 n/ t
}
% b5 \" T( |2 ]1 L9 L4 { q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
1 c- c- }# ~" `9 S2 X+ M2 X* { 这段小代码肯能有两个你需要修改的地方
& ?. U: u+ z; A" q# D 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键2 b% L6 [' O7 D
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 q* R9 G; h- x) y |