此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
: r. s5 U! Y* X( o2 q) Z& Z( C0 Q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
: Y1 A1 X* v4 M" [9 b 方式一:
6 ]3 o$ T; V5 v& R# I$ e( V 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ W4 p9 \" e. p8 g7 j& X 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! M3 `* o; _; @8 h; T/ m3 F7 h2 }
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 W/ `" m4 u9 R* ]- n! k* X0 Z
方式二:8 V9 L7 \; i9 a7 [ E3 d
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; n1 Q6 O; b: z! k) V SetTitleMatchMode RegEx8 A" f& O: ^; C3 c$ `
return
* t2 A% [1 f! C. `% x ; Stuff to do when Windows Explorer is open3 D* ]6 h6 p4 H! ^5 k8 K& j; i
;) ?5 x5 H1 m3 c
#IfWinActive ahk_class ExploreWClass|CabinetWClass
, n4 ]* G R7 o5 s7 ~ n ; open ‘cmd’ in the current directory
. R. p [) Y4 E9 t- t ;* ]7 C) C% l0 X% r
#c::
; e; E9 l" @% T OpenCmdInCurrent()
1 l6 s% M" d$ s& c3 b- K" Q return
. l: D2 a# \8 Q8 B' c #IfWinActive/ o' W$ q9 r5 d- D( ^! N# U& n
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 b% {( G, B3 F8 @) P/ O ; Note: expecting to be run when the active window is Explorer.
! T/ s! ~" G) M# Q2 h( q1 X ;
+ r( `8 S* Z8 \" e3 b OpenCmdInCurrent()1 O6 g5 _4 w8 e9 }$ _+ `( R' `
{9 E: ]: m* i1 z9 a M8 {
; This is required to get the full path of the file from the address bar: B' b& g/ `1 S4 k# O& a6 R
WinGetText, full_path, A2 l* t0 F8 r+ S2 E0 O! n
; Split on newline (`n)1 F9 [( n; C: C7 f1 `
StringSplit, word_array, full_path, `n
$ f n( n) ~4 } ; Take the first element from the array7 Z+ u6 [ m! \. q7 V7 Q0 N9 D
full_path = %word_array1%
7 P$ C2 ]; e4 u5 B$ h D! s ; strip to bare address: p) j! \3 s" f
full_path := RegExReplace(full_path, “地址: “, “”)' E! }* B& L5 @- G+ J
; Just in case – remove all carriage returns (`r)
8 v0 S) m6 s2 X' H' c" s( E& B StringReplace, full_path, full_path, `r, , all9 ?* e4 }5 s1 i
IfInString full_path, \" a) N* r9 o. M5 x
{5 E! C* e# ?4 Y* Y% O# Q1 p" D, `' P
Run, cmd /K cd /D “%full_path%”0 K7 g+ |+ P, k- v1 y
}
$ y) m8 l! }/ A% d% z else
, C6 m2 p' \' g7 n {
$ l0 u) r# D# j Run, cmd /K cd /D “C:\ ”
% T/ r/ ^/ T+ { }
( _* X [" F# h. B" d }
r) _: n7 o. }- f8 V! L7 D1 \0 A 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
, E: X7 a+ f |/ W 这段小代码肯能有两个你需要修改的地方
% }' Y" a; e2 Y& ?& T 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键8 W8 z4 ~2 R4 l/ s' Q% L Y* o* {
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ |( f# q1 [' S$ E* W |