此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。0 S4 U& N7 V1 S4 ^6 N
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。& S4 Y$ e* A1 @& e& K- A# r+ N' y
方式一:
- G9 j$ w h) @$ k* P5 [ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 b3 J' z# Q. D% [& ^ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和1 D, k9 P$ S0 D+ s, \- \6 l
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 l, w! W. p1 I+ M
方式二:
6 e v, J- A6 X1 [; i/ w c+ W 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:% e" }8 U2 c' V
SetTitleMatchMode RegEx
4 N6 M* Q1 o. |' O5 w ` return" o1 w, E& D; d. E2 M
; Stuff to do when Windows Explorer is open" p* Q! C/ l9 K
;' m$ v9 \. U1 a( ]6 s1 ]7 _
#IfWinActive ahk_class ExploreWClass|CabinetWClass
/ R) ]0 o$ ]9 `$ y; H0 { ; open ‘cmd’ in the current directory
( w! W; d: W3 Q. P! T: {* o ;
9 u& e) P Z5 }. H #c::
% R+ L% ?/ I3 e& G) `4 u OpenCmdInCurrent()
& _7 _; l* P& C5 A) T return' }+ J! R5 F a, n' P2 J
#IfWinActive5 P( D. D0 t7 ~! ]" q" A C
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.; R, t" [$ I7 z% ~
; Note: expecting to be run when the active window is Explorer.9 @& R' c' J1 P. X2 A
;
" U7 z; \6 y/ K! e- _ OpenCmdInCurrent()* B6 x: ?3 \# o* t0 m, q' E
{% l0 ~" m+ D' Y) | D4 W0 v0 [
; This is required to get the full path of the file from the address bar
7 v# `) W3 V9 x; K9 Z) L WinGetText, full_path, A# k; o9 U8 s" j+ [, @' V- @
; Split on newline (`n)
4 c; O) Q; |& f" n7 x StringSplit, word_array, full_path, `n" T! S1 k0 r- d( k$ t5 i; I
; Take the first element from the array. V; \0 V) Z! x+ E" }- |/ L
full_path = %word_array1%
1 |3 h+ e, q8 h+ Q9 |3 w* Q) R' z ; strip to bare address
6 a+ I* y. h! y full_path := RegExReplace(full_path, “地址: “, “”)
6 \ C5 q+ `3 S9 y1 ` ; Just in case – remove all carriage returns (`r)
5 m- x. N' P* T _: Z z StringReplace, full_path, full_path, `r, , all7 N+ {6 l9 R: q& w
IfInString full_path, \
% z3 I) w7 \/ K. y7 D {
+ M+ C* W4 s4 C3 ? Run, cmd /K cd /D “%full_path%”/ {) V: d1 J9 U' O4 F) U" i! T
}. q3 g2 a K* X( d
else/ `5 l1 s8 [- a; y
{( m4 s1 B: ^' z ?- R2 h1 w
Run, cmd /K cd /D “C:\ ”
5 V1 Q s* A/ x7 ?1 J }
- {1 B. z$ [! K* t: k2 J3 F, ~ }
2 q2 K) k4 |1 F! j7 U' O6 x& S6 z 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
1 n0 W; U& l5 T I* h( w 这段小代码肯能有两个你需要修改的地方
" ^& p+ i+ N( P7 J S& ? 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
* `3 s, M# E/ W9 V( E, q 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
Q0 q7 L2 }& W2 W" N/ f* x |