此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& E( E, G- `- [: _ T/ d
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。- w1 q' _4 x7 H+ H
方式一:$ d# x# c0 @2 B
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,' S% b" Z; | U4 v' N) P
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# x6 w+ b! w4 o A8 p* D! Q s0 P. H
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* U) X% L j( j1 \0 d* V
方式二: z" H" @7 @/ y. s' Z
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:+ ~5 ?: x$ f( q E8 E# Z; h! s
SetTitleMatchMode RegEx! b0 F+ K2 u" {) o; w
return
8 G2 O4 _6 w, ?& b5 ` ; Stuff to do when Windows Explorer is open
4 f# R! U4 k( _* v' O' {9 H ;9 Y# k7 z) J* b, z1 s
#IfWinActive ahk_class ExploreWClass|CabinetWClass6 w" \% D) r" D) |9 ~# s' I$ A
; open ‘cmd’ in the current directory9 @* v7 r! V$ b$ o
;9 z7 U% g4 P% i8 r
#c::
, S/ b" x+ v) j/ q1 Q9 W$ R* Y OpenCmdInCurrent()3 |/ A9 E0 }; v4 k
return* a2 Z. x$ ]0 T( ~: ~( M
#IfWinActive6 H# k* m9 `% ]) I' L% U
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 i" B! }) Q/ E% i
; Note: expecting to be run when the active window is Explorer.
g1 n- l3 s) K1 G/ D" b ;
# K2 Z/ j, [: P% _* C OpenCmdInCurrent(); q: W; ^9 ]: W; [- i# t3 p
{6 M5 R' B8 D* F
; This is required to get the full path of the file from the address bar3 c% A% y% x3 g: ~+ `
WinGetText, full_path, A" i! |5 W8 y! T' z4 t' p
; Split on newline (`n)
1 Z2 L& Y0 N" i/ K9 q% \ StringSplit, word_array, full_path, `n
$ F9 f L2 g3 M ; Take the first element from the array( R1 L, M# F6 l; k
full_path = %word_array1%
4 {) R$ S5 b' z+ s- S0 a ; strip to bare address
' X5 _) W9 k! y) @8 r: M full_path := RegExReplace(full_path, “地址: “, “”)
* P( h9 I5 G! G6 ]/ F3 q ; Just in case – remove all carriage returns (`r)
9 w8 J/ c W9 b9 P StringReplace, full_path, full_path, `r, , all
4 S& h+ z+ _/ g6 k IfInString full_path, \4 O5 o1 W. `$ T1 ~2 K$ B9 M
{; U: n: g, K2 t
Run, cmd /K cd /D “%full_path%”: Y3 k- s8 `1 c# B) t- k3 r
}
; N( G1 k: r& K. d: u2 K else2 `8 q: s7 f5 o; [
{
: p9 ~" J9 p( {: c. w" w Run, cmd /K cd /D “C:\ ”1 T; F& ]; x* s) n! {
}+ {, ~; I. w" @$ _
}
9 L2 |9 c; ?$ @& D. M$ p 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# A. X3 b6 ~. J3 K$ N1 r* i/ i, I! z 这段小代码肯能有两个你需要修改的地方: d4 x2 m' x6 n
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( b2 m: K* H; }) l' _ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
+ T% R+ I( U7 ^, P8 d |