此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ b! Z' s3 S" E4 A
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% U3 }4 G l$ l% Q8 |- e) O
方式一:! p5 D& s# g$ k6 I" Z7 c* c5 Y& G
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& S+ L' p2 C$ w: I8 A8 E 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ }# d1 V7 m1 [ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ S( \! X+ K9 D! k7 R$ b- C
方式二:' Y, e' Q4 X+ n" m3 b* w* B' J; s
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:% D. e' Q8 V3 J: N p
SetTitleMatchMode RegEx
3 }3 r$ q1 D0 Z5 a) R8 F return" c& @3 K2 i& l0 r) t7 a
; Stuff to do when Windows Explorer is open; {, S1 U, P. x9 J% B
;5 m/ F& `6 d/ F
#IfWinActive ahk_class ExploreWClass|CabinetWClass4 w: w9 V) M/ |! Y% p, y; h& s; ?7 y
; open ‘cmd’ in the current directory) G" m) {$ i$ R
;
- p6 t3 m' M0 {' s3 Z #c::
- A3 h1 k/ M) w5 I3 u; ] OpenCmdInCurrent()# M" B8 C0 q* Q6 I5 d
return* K1 m- j, L" o7 I! g* F
#IfWinActive- k7 S( P( b- X6 t
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 T0 |$ x/ _* h) s8 l+ |& B ; Note: expecting to be run when the active window is Explorer.6 f% k9 L, N2 _' o6 A
;
( X; q2 j% o; u& Y7 Y+ R OpenCmdInCurrent()
" C, W+ x! f. y7 {/ |6 _0 C2 w# u {1 p, k/ t9 P7 l9 a6 F I$ e! B. |
; This is required to get the full path of the file from the address bar
8 G: h2 q& K% E- \( c WinGetText, full_path, A% L: C" [: o' G& E
; Split on newline (`n)1 r8 K/ v* a0 b: S7 A" g
StringSplit, word_array, full_path, `n* L7 @4 E, E! L
; Take the first element from the array: u! h2 N6 ^/ W+ t% [( h5 m
full_path = %word_array1%
8 L( c3 k) t7 e ; strip to bare address& _7 v6 m4 j. c2 e/ _. ?$ e, v y& Z
full_path := RegExReplace(full_path, “地址: “, “”)
! B3 z6 l& S. o/ {$ H6 Z ; Just in case – remove all carriage returns (`r)
& Y# C8 i$ {# g) n. ?; Y6 m StringReplace, full_path, full_path, `r, , all+ R2 K, _1 z, j1 H- ^. {
IfInString full_path, \/ _9 f7 F% R6 `4 V; `6 \1 z
{
: Z* n# k/ r* Z Run, cmd /K cd /D “%full_path%”
; N2 W5 @ u% A% }' r# }6 y$ M- v }. [8 Y6 h, `6 D+ s; S5 A! P6 s
else/ N }& J" K3 R
{
0 \ T. C" x5 O; q Run, cmd /K cd /D “C:\ ”, I& ~- l5 E/ p
}
# D- J: S6 ~) j0 g' B* e) l# s0 z }
" [; }7 o" d3 j 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( Q$ W- f! }4 X) p/ H 这段小代码肯能有两个你需要修改的地方
+ s- B D7 H( O8 {- e7 o 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ }. s) [6 ?$ M* j" o' u' }/ a 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
( _- y1 ^- s( P3 e+ f& F# b: E1 t |