此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ e. O* b% @" O& G1 U 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. [; n2 J: q; x
方式一:
$ a v# a6 }( Z3 x B 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,) n v8 P. f$ H! H; n
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: W, K9 s; e/ ~/ o% v9 b; g% Q
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。7 h8 e( H0 m" R4 P8 G0 O
方式二:
9 Y9 G2 B" u4 p$ S5 R5 }- ^ y8 z6 f 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 q0 _2 K. |$ {" t( }
SetTitleMatchMode RegEx
! I9 M/ d7 i2 S" n, f# Y! h return
; w5 B3 V; z8 B9 d- V5 `, K ; Stuff to do when Windows Explorer is open9 y' @1 v7 [1 }+ X, ?
;: k( H3 l& ?8 W# a& E
#IfWinActive ahk_class ExploreWClass|CabinetWClass ?) P( l3 Q* v1 @8 c. w! t
; open ‘cmd’ in the current directory
^& ?7 }+ B7 m( [& e- w/ d ;* C# C! k3 V2 B' o; ~" B$ G. r8 B
#c::; e( d/ Z$ E% r# x
OpenCmdInCurrent()3 B9 L. }6 h: }7 {* M) l1 I
return
2 Z) a5 n% Q2 y( H0 J( R #IfWinActive
( f$ R& E. Y- b5 ~ Y ; Opens the command shell ‘cmd’ in the directory browsed in Explorer." ?3 w" i/ ^. P* O% m
; Note: expecting to be run when the active window is Explorer.# X4 o: H8 K8 Y- Y/ @8 f
;
/ N: Y4 A1 W/ ^9 B0 k2 ^' {1 |& U OpenCmdInCurrent()
* _( J8 U* S& L8 p' M. ~* z7 ?4 ] {$ V7 Q3 i2 Y8 X/ p8 d: N9 |
; This is required to get the full path of the file from the address bar
6 `: U+ y% H5 |. K WinGetText, full_path, A
: F5 P* K& f& S. L8 n ; Split on newline (`n). w4 R' j8 G, H- _8 J& k" n
StringSplit, word_array, full_path, `n' f" C& n% B9 y/ E
; Take the first element from the array3 D7 Q' s' v, Y1 O* C& K
full_path = %word_array1%- E; X9 D8 g$ V$ S
; strip to bare address
# @0 K n ^7 W full_path := RegExReplace(full_path, “地址: “, “”)
; ^/ ]5 G, a4 L+ E: C, \8 T ; Just in case – remove all carriage returns (`r)
6 s% v0 V6 Y. O StringReplace, full_path, full_path, `r, , all
3 A: @- ]8 H2 E8 \, R IfInString full_path, \' W% J+ _ W b5 D3 f1 Z
{
. Z& t# }# R! E: u& Z, l Run, cmd /K cd /D “%full_path%”
- O" d; V4 w" r }8 M9 [% ^- P/ d
else$ R( c3 ]1 v/ K* ~% t0 v
{
8 U) p9 M" L' S d: P/ C$ Q Run, cmd /K cd /D “C:\ ”5 _1 F# E3 r+ w; s5 c& o
}
6 z; s; N& f9 G: c6 y }* J2 M, X* d8 ~0 z/ Q c% U* w7 \/ q* F
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) \ p* R, o9 J" l) t
这段小代码肯能有两个你需要修改的地方" p, Q' h& ?$ I" L& e$ J$ w
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 ~% {6 I1 y2 z4 t" @ c 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( O+ t! g( ?+ u% x- `7 x/ `
|