此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
6 r: Z; |! G" o& c 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
7 s! Z0 O% c: h2 t3 @2 r 方式一:
1 L3 ^$ `8 X+ q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ N) G" I6 {4 E7 u9 Y9 {' H
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 P0 k7 {. l& r3 v8 X/ J- ^ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' k( b4 M0 D6 M7 b/ C1 s 方式二:# [( R2 b: F6 N4 W( K( o
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:# \5 [2 t' d2 R
SetTitleMatchMode RegEx
4 L; u, c5 C3 w3 a4 _* f return
2 T _& H% }' }" q7 V1 z ; Stuff to do when Windows Explorer is open
9 U5 y& V* O$ E: ^1 w6 z% { ;
h0 ?9 b! N4 o( m7 \; g6 U #IfWinActive ahk_class ExploreWClass|CabinetWClass
4 O0 D# `8 y4 O3 C! D! C) P ; open ‘cmd’ in the current directory
! [+ i$ `1 {( o4 w1 t" p) p l ;4 E" o/ L% Z% M+ l; }
#c::
$ N* ~4 z$ s, D ~+ f |. Q6 e OpenCmdInCurrent(): O; G# o- |7 o
return
$ l5 t0 L5 V2 i9 B* q #IfWinActive9 {: j+ O# l/ N" K6 r' ^5 Q. `
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- @. K G* D+ U; L% s ; Note: expecting to be run when the active window is Explorer.+ I- @* [3 l. C7 h R) h$ i
;
- ]: z1 Y9 ~4 o. o1 \9 T( n1 i OpenCmdInCurrent()3 ?1 l3 s8 d! e' x6 r
{1 _' s1 S, S4 [: ?2 F" ?4 |
; This is required to get the full path of the file from the address bar
" M, ]. a* ?* n WinGetText, full_path, A
# \0 y" d1 S/ a$ H: ]2 D3 O0 O, g ; Split on newline (`n)) P1 Z6 ]! _. M$ Y0 H A& u' Q
StringSplit, word_array, full_path, `n, D6 ? N% d# y# d) r
; Take the first element from the array/ D: R: V+ u* H- [1 B' w
full_path = %word_array1%
/ t% }1 h( g/ c# b) n/ I ; strip to bare address1 B" S. w- N! z/ M- K
full_path := RegExReplace(full_path, “地址: “, “”)" ?8 {9 X5 ?% J1 B
; Just in case – remove all carriage returns (`r)
x$ r( d/ w9 o8 b V9 b* C StringReplace, full_path, full_path, `r, , all7 M" h& r V( e7 _5 E
IfInString full_path, \
& u H( C- H. G: U: Y* B {# _( z+ {% a2 x- L3 a) G
Run, cmd /K cd /D “%full_path%”
1 C& \$ C. C# r }- P) |9 b+ @+ Q0 r* J
else+ R# y" M% K6 f
{
# f t) z4 E. g, {# g* T: S1 { Run, cmd /K cd /D “C:\ ”4 x* Y B) _% L% q
}3 i$ u" r. V- M3 d% ?1 K+ F2 ?
}
- h. i9 m6 ~" P 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
+ u1 T$ ?1 _% q8 Q2 }- I' h& B 这段小代码肯能有两个你需要修改的地方
) G" z7 z# a- v, Z8 @ i 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 h! N+ |. v: n* d3 i; w
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( F$ l+ Y' X% S. ]
|