此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' k1 [7 T6 v5 v1 |) w( |" T
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
( g' M; f* ]1 _+ w$ u$ { 方式一:* `9 d+ B8 N. E- J& u* D( ~8 v
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
; e G2 g: x( ^/ L 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 f1 q" P! s$ H9 M( g HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。. G# n/ S5 p |
方式二:
8 g+ c$ q4 ^3 j8 u+ I 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:8 S( m+ v h% N& z( C( ~+ @
SetTitleMatchMode RegEx
8 M3 u5 M) s- v! N8 R return1 L! M' V/ h1 ?8 ?0 {
; Stuff to do when Windows Explorer is open
* N4 Y0 B9 f5 @ ;8 Y* a j: w" M# b6 u! }" ]
#IfWinActive ahk_class ExploreWClass|CabinetWClass- l7 L; g3 p/ w+ @8 Q) G; l, _ @
; open ‘cmd’ in the current directory
( J5 Y+ ~; x9 e/ `5 I9 ] ;
" w3 {4 a G0 @ D$ d8 j #c::* J4 |( B* Z5 |8 c3 j
OpenCmdInCurrent()1 T }& ~0 `1 Z' [8 ^1 G
return
* e' G* A0 \9 _ #IfWinActive
: Z0 l2 p% r* ^- \ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer. z! ?+ D6 `3 m( Y' R
; Note: expecting to be run when the active window is Explorer.2 Q0 X+ s, \6 C% L
;
$ B/ @% o, [! v0 _ OpenCmdInCurrent()+ n C. Z( ], C" n
{
( Y: {. O {/ h7 ~ ; This is required to get the full path of the file from the address bar; N2 I9 r* T7 A9 X
WinGetText, full_path, A ], K6 x; Y& z5 B4 Q
; Split on newline (`n)
5 `. m8 u, A: N2 D, v' [- h7 J StringSplit, word_array, full_path, `n
' \* ^- m2 t: d! c ; Take the first element from the array& C/ X4 l$ ?$ t# b
full_path = %word_array1%" g( d5 O ?1 S0 H# T
; strip to bare address
# I1 Q/ n" {4 { ^ full_path := RegExReplace(full_path, “地址: “, “”)
( G }) o# J+ v% e4 `3 K ; Just in case – remove all carriage returns (`r); a; }' l( W$ L. ]; ]1 O
StringReplace, full_path, full_path, `r, , all% i# H7 _: G9 [
IfInString full_path, \. P: {- p! p# A) Q% @* p k0 ^. C2 u
{1 ]3 c. P$ ?) X5 _% K
Run, cmd /K cd /D “%full_path%”2 i5 Z* C! L# {( @# C
}5 A% _6 }. X) N* ]
else
: l- {4 c i `" d/ k! y! y- Q! m# A- Z {( K, W/ F1 [$ k) ?% j' N- r2 t
Run, cmd /K cd /D “C:\ ”+ c) L0 z; f0 X) o
}1 [& k5 W1 Z" P' g# m; G
}" I" X7 j4 H4 w! r
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 G/ l5 w5 b5 G6 K5 e7 W 这段小代码肯能有两个你需要修改的地方
4 W' u& `( X# X5 w! z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 d o, e8 U8 G3 f, R# R* c/ L 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" N1 u' B$ r M) P, S |