此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, w2 @. d6 W$ C
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. F6 t0 ^3 K1 q- I( _- ^$ f) A2 D
方式一:
8 S' D$ O& g- k! g- Y! j 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. y: z! H# J% E/ L4 L8 H
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
9 X+ G" X, l# P7 C. I9 m! ^ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' e- ~ b3 V6 _6 j1 o) r1 | 方式二:
O: w8 c6 `5 {; w! A- \3 b6 l 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: G1 z" _/ u' F7 E9 y2 Y
SetTitleMatchMode RegEx/ s8 W% R" }9 y" N6 N( D6 a
return
4 d, Y0 |! y! @! l* X ; Stuff to do when Windows Explorer is open: a6 \, {3 K2 }5 K9 o
;; ^: `: E0 j, Z- M9 t
#IfWinActive ahk_class ExploreWClass|CabinetWClass' h/ j, o2 x+ W( n: s! [- T8 D
; open ‘cmd’ in the current directory
4 W# T. k- j- d+ a# h ;
& Z2 F/ R- [1 m, E' m #c::3 V* v/ C% S* I$ P) p: I) A
OpenCmdInCurrent()" F1 q0 w9 g5 n8 B$ Z8 s% X/ m
return; [8 Y# v7 `7 d" ]' G( ~
#IfWinActive7 k5 M$ b" T9 }6 E
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- T. a% K: Z. q+ n8 R- L( Z+ C ; Note: expecting to be run when the active window is Explorer.
) O: q3 V# T! N( d ;# v: a, W2 U# J2 `# e: h7 ?* v
OpenCmdInCurrent()
1 u+ d9 M& A0 u+ v4 M6 ]1 h1 ^ {) C9 g* G& m5 v# @% g8 s* z& i% A- [
; This is required to get the full path of the file from the address bar. f. n" |! W7 |. e8 F: f4 O# V
WinGetText, full_path, A
+ n2 W |7 v0 f% R2 z( e ; Split on newline (`n)8 ^/ D+ i* Z+ u
StringSplit, word_array, full_path, `n
) I5 T, J' H [ L; r) R ; Take the first element from the array
+ P" H/ o+ G4 s+ E1 C8 ^. \ full_path = %word_array1%. j0 ^1 a8 I' q
; strip to bare address
, y3 x% r* Z4 K, n; d: j full_path := RegExReplace(full_path, “地址: “, “”)% `2 ~; l2 g" `7 d9 b+ q
; Just in case – remove all carriage returns (`r)/ e$ O* b% ?, `/ n8 u
StringReplace, full_path, full_path, `r, , all) E7 d s& s0 l+ ^* u7 R: a3 p
IfInString full_path, \6 e3 x' _, \3 g2 |
{. |0 ` T3 ~/ c4 I
Run, cmd /K cd /D “%full_path%”
* q- |6 ?5 d Q; _2 i }) m! {3 R) x6 _- ]
else- C* b/ Y# c: t, _1 |
{- a+ d5 i$ q/ M V9 e" J
Run, cmd /K cd /D “C:\ ”6 y7 b$ n( i i
}: `! K4 v8 f5 w& A. y8 @
}( M5 b5 V- Y$ e) F T" U; b
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* ?- _ A ]3 ? u$ ~$ k8 k$ {
这段小代码肯能有两个你需要修改的地方+ b. b% K' z% W3 K5 A" B
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键6 H$ S. G( G, j7 g
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
& B4 ]* U: P$ [1 o( ]9 O |