此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 a+ M' t! U. G6 s( i
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) i: X0 N6 c& s+ p
方式一:
s" `; o4 M' Z6 P+ g# f 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% p, Y8 q: _. j u* B7 x2 x 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和& F: }: l2 r9 o
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
8 V; G- ]6 S$ x0 h/ W3 [2 k 方式二:
! B v7 c0 {4 N% I. _4 a$ i 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ i( x+ f& [( Q2 J SetTitleMatchMode RegEx
" j9 c) `* O: j! u/ U7 { return* u( h h# e ?' x% {8 C: m
; Stuff to do when Windows Explorer is open6 _, T9 q7 m t* u( I! ^
;# [: U0 f" Z8 A, c, g! ~$ _
#IfWinActive ahk_class ExploreWClass|CabinetWClass
7 o2 }/ l) \* H9 \& K+ x3 d ; open ‘cmd’ in the current directory
7 Z D& q, i% R! d ;) @/ V4 {7 O1 Q1 l6 l- Y- i
#c::1 C5 [- `! n# g. T
OpenCmdInCurrent()5 Y* z# j' \) O4 ?; R7 @9 x* I
return$ S ?/ B! u. }8 d
#IfWinActive
- q4 j: H* L$ z/ Z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ a' z0 N) U( R; D
; Note: expecting to be run when the active window is Explorer.
8 P0 U/ p; t0 R5 e9 I. a1 H) c4 v ;. C. i( u9 m3 N" [* S8 }
OpenCmdInCurrent(), D8 G4 W( q& _; n0 C6 x
{. ^' v: L. ]$ ^8 ^$ p% h
; This is required to get the full path of the file from the address bar
; h6 E8 _1 X0 J% U4 t, k WinGetText, full_path, A+ a% d S# a2 U& D
; Split on newline (`n), p7 ]& f6 v }' c1 O8 D
StringSplit, word_array, full_path, `n+ h, C7 R5 Q3 F' V
; Take the first element from the array4 k h0 Z9 r$ f8 R" M
full_path = %word_array1%* l+ m; u9 w2 X* B' _7 n5 f
; strip to bare address
1 @* w, n! F% f% \ full_path := RegExReplace(full_path, “地址: “, “”)% J6 O9 V& Y. U/ H) F4 H+ g
; Just in case – remove all carriage returns (`r)
2 o0 a+ w, t6 I" T, x9 D# F StringReplace, full_path, full_path, `r, , all! K" Y* t% p) L
IfInString full_path, \
) V: X3 q1 u7 J5 V- ^; @ {- _, V3 a) a' L- \
Run, cmd /K cd /D “%full_path%”
! `& h! f9 L$ s7 W" D( U7 c' Q2 s }8 S# ]+ S7 Z" E& Z
else
4 o: m+ n0 T4 O {4 q5 @' T% I2 d. h& g
Run, cmd /K cd /D “C:\ ”
9 z8 O' d. b" A; R }( h5 T( {0 T8 M- m% D# y j/ g
}
. y. [- P7 m+ b+ S. g: l/ x: s 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。4 U$ c3 q5 Y+ R! v7 ?
这段小代码肯能有两个你需要修改的地方! Q8 D. Y; @/ J
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 {& B, c, j, X% t- G, u3 ^5 e 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 M2 U# l5 o6 c5 @) M
|