此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( d# s3 T' }0 P6 M% E
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 c( l) _& i- H2 H$ Q/ ^: s 方式一:
9 T6 x' k; A9 R! E3 c' K* ^0 i 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 m( S* C" T5 Z h5 V7 ~. n 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
3 y8 C) @ F4 C% D7 u" ^/ N HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& @9 v# D0 l& E s8 C6 |) Z 方式二:2 n' l4 k; e' D% @6 p+ S8 z% q) [
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:& C; |' A8 B$ l l ~
SetTitleMatchMode RegEx* _/ y% |6 T& k( r j
return# _7 A$ C/ X) I$ Z% A8 y
; Stuff to do when Windows Explorer is open
, ]- x. o$ `$ r5 D ;
5 J' T: o2 p: j7 ~" g/ R2 Y7 t #IfWinActive ahk_class ExploreWClass|CabinetWClass+ K8 k+ C5 r6 f( Y8 H5 _+ q
; open ‘cmd’ in the current directory, K: ^, i9 V/ A0 D* ` Z0 p
;0 s# R! t8 U% o5 ~
#c::
& ]* u. z5 m4 j$ O1 F- ^, ? OpenCmdInCurrent()
1 a$ \+ W% [1 B. g% E1 a return
5 @' O8 K; P+ j* E& x- Q( J #IfWinActive
4 Z( S& d. G, |; e+ @ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.& [9 W1 |/ X5 ]; R
; Note: expecting to be run when the active window is Explorer.2 i0 m0 H" _8 y
;7 H5 }! C7 J! \6 {+ b$ Y% ~7 M( I
OpenCmdInCurrent()
' w+ X3 F+ A; J4 Q* Q2 ^: A {
9 I8 M5 e; T% r+ v/ O ` \ ; This is required to get the full path of the file from the address bar
& S8 {+ o ?# v+ d) Q+ r WinGetText, full_path, A6 m" E; s5 U8 ~& G/ Y$ Q
; Split on newline (`n)9 M$ b1 h: V8 n4 x
StringSplit, word_array, full_path, `n- I& ]" N5 v4 d2 _
; Take the first element from the array
' M% x, h, u; Z, h& m) W' L" [ full_path = %word_array1%
- ?7 q4 x, w- _: j, B; M ; strip to bare address
9 o7 ]9 H* f+ P3 E+ N: n6 m full_path := RegExReplace(full_path, “地址: “, “”)6 i: I) X5 P7 G& l, u, S; x
; Just in case – remove all carriage returns (`r)8 H( b- u, p4 J) O' N
StringReplace, full_path, full_path, `r, , all$ n; o- B2 P; \ f1 n( A1 o R, e0 O
IfInString full_path, \0 p9 K& e: F% B% X7 N4 h. S% L9 }. }
{0 \7 Y4 ]8 I) z" I3 v
Run, cmd /K cd /D “%full_path%”7 I" M+ w& _. E5 g' G
}8 k9 X8 t! `, {# D; d8 \$ t. p
else
7 U4 v% l0 F T {
1 ] N$ o- C6 a3 n. N Run, cmd /K cd /D “C:\ ”% T9 d y& U8 Y6 {' U% A
}
$ {: s) I" f6 J }& M; l# f% H* c# v0 ]
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ Z8 c2 V- ?+ X' p7 X) E
这段小代码肯能有两个你需要修改的地方
+ ~5 l9 A& U0 d 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 I; i! B! Y$ s, B& V; Y' |8 | 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “7 ~" B% \5 y3 [: Y$ G
|