此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
* R' `8 z8 w6 v# w) ~( ? 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. g1 v1 W( S! X5 `4 J6 ?8 i
方式一:
1 U* y4 l2 Q# G0 F% G, a& W2 p( c7 t 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 b5 H: c, j1 u" x
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: [* F- l+ O0 D0 K
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! E& U+ |, B7 E# B0 d 方式二:
1 r! `$ _$ U* G: W( Y" ` 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! q* Y# u: |! N F
SetTitleMatchMode RegEx( x/ q# }' W9 E6 z6 A/ s0 W* ?
return; m' u: F! K; d p* R- Q; o* l
; Stuff to do when Windows Explorer is open1 d P; P. @. s( w3 i% X
;
! X: S- ?% Y, j$ F+ @) d #IfWinActive ahk_class ExploreWClass|CabinetWClass
: X* b4 ~7 ]% O ; open ‘cmd’ in the current directory& \. a% Q3 A' _, K1 y$ \6 i% n/ \/ E
;
* y% I' ~0 \9 w1 ]9 t- ?' _' d #c::
( r+ R( Z+ U0 L% V# ]5 f+ }- \/ M OpenCmdInCurrent()
" i& v; J/ B, k# ~" W9 K return) k) L$ U6 L R2 v
#IfWinActive
: k# U G. }( K' V9 e ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 p8 f" z0 O2 h7 E0 F6 ^- | ; Note: expecting to be run when the active window is Explorer.6 D/ M F& g# `) d+ ~* i. m/ K' n8 U
;/ p4 `2 \: w' g. x K6 ~
OpenCmdInCurrent()
3 b; {+ e( P- [0 X {
6 ?5 o9 J- n9 v( F: z ; This is required to get the full path of the file from the address bar9 \: i9 v% D! o* m; ?8 w/ I" l/ l3 B
WinGetText, full_path, A2 k# b! f' e) o9 S
; Split on newline (`n)3 s$ U; `& C2 ?& `
StringSplit, word_array, full_path, `n/ K' c0 S: B& D/ e. l, b
; Take the first element from the array3 c: ~9 I2 b& U- \
full_path = %word_array1%
" C1 W B# R3 z! ~$ H ; strip to bare address* w7 T2 t2 R5 R; I( t! B
full_path := RegExReplace(full_path, “地址: “, “”)9 O; P- E7 J" o- D* z
; Just in case – remove all carriage returns (`r)2 t( {0 i6 K4 ?
StringReplace, full_path, full_path, `r, , all1 f# E9 p' C! Y6 g9 Q
IfInString full_path, \
3 X) j H: L; W. o! M7 T {- g( B i" A( b& w \! V
Run, cmd /K cd /D “%full_path%”
' G' ?9 _, q% a7 _9 o0 f }1 c! N* D1 p4 f
else$ E E/ H0 Y2 T
{
8 O6 M8 U3 S) g/ _' f' [6 e Run, cmd /K cd /D “C:\ ”
, f. W i o8 c$ N$ l0 [$ D) Z }9 _. z! h- u [2 x6 b$ L4 ^0 R
}
7 T+ q8 r, Q" u) G3 O 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 h( j. h8 N. Y9 u5 [
这段小代码肯能有两个你需要修改的地方# J$ H H% l/ J! ?, h2 i
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 O3 c: t6 E W7 }5 H5 n
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; ~& w6 Z5 G6 V, V
|