此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' Q% R& k; D! f: `* B& B) a% V7 u
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ Z6 O! D7 w" A
方式一:5 K6 A; g: M" D0 U8 @! R* W
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 D6 a$ V& P% Q Y" L% T$ n6 e" K
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 m' Z* q& T1 B4 ~) t( h4 B' t( z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
- i! t( V2 ^0 H- ~ 方式二:1 V/ `6 T% s4 X5 H
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 \$ s: y" x0 D$ \6 ]0 i
SetTitleMatchMode RegEx; {9 C* O1 ]$ y! @: `1 V3 I
return& Z! g! |- l8 c3 H; K. S* a( i& n- g* O
; Stuff to do when Windows Explorer is open
' d9 U- b. [- ^6 o3 ^- g6 W$ a ;
* F6 h1 i, `8 |9 v* f #IfWinActive ahk_class ExploreWClass|CabinetWClass7 a) G, r- W& Q( J- }1 i
; open ‘cmd’ in the current directory
5 h9 h& B0 s3 O3 V# }( v4 M ;
+ B0 t3 X J: N4 S7 C. \! e #c::
" }' o. q2 g: Z O7 L3 l OpenCmdInCurrent()
! Q) z' ? Z) P$ _0 d0 [7 \, T return- H$ x# [( B/ c
#IfWinActive
! j; i, ^$ B: t, H ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# I! i; T4 D& O7 m3 e
; Note: expecting to be run when the active window is Explorer.9 C* ^5 p" ~5 \" Z5 \' p- z
;
5 z8 A# o# e/ @. ]6 J OpenCmdInCurrent()6 Z2 l( d/ F, M, O1 f
{! a! r& _* ~: [4 T7 a; ~
; This is required to get the full path of the file from the address bar
, Y G0 }7 O9 p; o1 g- n WinGetText, full_path, A
1 {1 p& N- y6 S- G ; Split on newline (`n)8 h. d- \+ A q" d0 i
StringSplit, word_array, full_path, `n5 p( T: ?* t/ I. C
; Take the first element from the array! W: v6 Y$ I' p6 A d" z0 O2 k
full_path = %word_array1% B) b3 K! l1 \# P0 G
; strip to bare address9 L8 L# d) C, G9 h2 ?. l9 g. ~. s
full_path := RegExReplace(full_path, “地址: “, “”)! f* [5 [% N A3 [
; Just in case – remove all carriage returns (`r)
0 |3 X/ b Y) ^0 h" c- g StringReplace, full_path, full_path, `r, , all
5 F* m% n8 e* A/ D# }7 q. z IfInString full_path, \
! b2 p9 ^. Q: G7 {$ S {5 l2 j! r" ^7 [" _8 Y4 ~
Run, cmd /K cd /D “%full_path%”% X- e, V- F# z0 H& H# p
}0 y' h/ i8 i. P, m2 m
else
J( ]) Q5 p5 }+ D" k% n) G {
# }& s- ]( c# f' [ Run, cmd /K cd /D “C:\ ”8 b/ ~1 g5 E8 `1 v
}
7 ]4 K$ b/ C: Y# R }' | J1 q8 j+ M- u0 ?- U$ Q& D9 n
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
W" C5 Q) N1 Z 这段小代码肯能有两个你需要修改的地方( \' Z2 S5 N: t. _
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 R$ d# J8 D$ |1 [/ \0 _& _6 u 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 C7 n9 D/ i, s* l# `
|