此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: y7 b c8 w |; o% g! M
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。0 N) k* V9 Q: y! \
方式一:
- d' k# S& l4 r" S 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- T2 t, ]( D6 _- c) N( p k9 N
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 p6 Q6 s8 j3 e0 J0 O! [
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 Y4 \! m" ~ C& @* B 方式二:
" ^; u8 H2 U3 W$ l 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( g. p# l5 O4 a. e2 `2 s
SetTitleMatchMode RegEx: J2 U! J0 T* W8 S9 K
return
6 w w# _& w1 ^2 F ; Stuff to do when Windows Explorer is open
5 i! V; b( g/ e# _9 U ;
1 v; t) d4 p r8 [ #IfWinActive ahk_class ExploreWClass|CabinetWClass
4 [! }( ?) x) n8 ~ ; open ‘cmd’ in the current directory4 a) C+ T" ~/ v$ g5 |6 ]6 L/ k
;- o- v6 o5 ^+ ~* ~1 F9 `1 D
#c::9 W: y# N3 B" t; O
OpenCmdInCurrent(). H3 j/ u$ ]3 V G
return
. H* z4 M7 C. ]5 Z6 \1 ]$ g# r #IfWinActive; _7 H3 ?$ f% S# g) t! n
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 l0 O t1 X0 {
; Note: expecting to be run when the active window is Explorer.' d( z4 m; _8 T6 I: Z3 [0 c
;
- _/ u3 i; c, P: y/ F+ p% n OpenCmdInCurrent()! z% _' _9 {7 C9 R
{7 O. z& N$ C* E1 h
; This is required to get the full path of the file from the address bar
* @$ ?) {- ?9 X- { WinGetText, full_path, A
& U! T% |; S4 G! E ; Split on newline (`n)
F0 y% W! ?7 w StringSplit, word_array, full_path, `n* V/ E$ J4 @9 X+ X
; Take the first element from the array
I5 E" e V' z7 F! l full_path = %word_array1%
! d1 W. ?! |1 L5 B4 ? ; strip to bare address
: w* s8 o1 Z% F7 p( A full_path := RegExReplace(full_path, “地址: “, “”) Q( f- D, k' ?6 f8 o) k
; Just in case – remove all carriage returns (`r)3 z4 D6 n: O3 I8 H( L' x
StringReplace, full_path, full_path, `r, , all+ e) J5 S9 l8 d2 P& _6 c
IfInString full_path, \
1 Y) C) w* H; I6 S" B {2 `2 \6 b) Y5 ~* f: x# r
Run, cmd /K cd /D “%full_path%”3 l- R" c0 @& Q: t, y
}5 Q7 o6 ~7 N, k5 F' x$ t
else- x$ s# e7 I1 w# b4 e5 z
{9 e/ `; h7 u% r# u8 T' \& W6 r) ]
Run, cmd /K cd /D “C:\ ”
! o8 q4 r# c' G3 e: I2 H }
3 o& |2 e) }2 F! S5 u; Q0 Q0 S }& l7 L4 |* U# `& X, t& }" c
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! W" A, e! g) Z3 y9 E5 y. e# S 这段小代码肯能有两个你需要修改的地方$ N- k+ r, h* W6 A% U) H% Q
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键* X2 e2 J/ D9 ~/ } m9 e; G
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “' O! n8 x+ t. {. K$ U; ~
|