此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 Z* j# G8 T' }2 x$ A, E g% V0 t" H
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
: v3 X+ P7 {: t/ f( a! w# ^ 方式一:+ a4 B+ K0 i5 ?% ]* u1 q5 b" {% L" e" H
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& i0 W+ F' w Z) P! X2 o$ t 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- l$ _3 B! A& J2 u HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。. \& `4 o* J" H* z+ y' r
方式二:
+ z5 G4 ~% \" [& d6 z! J 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ U: d9 |9 O& k. C+ n, u% o" X. N$ M SetTitleMatchMode RegEx# F. A6 Z! @! N& c2 `& I
return
- |! d) V2 @9 Y( H3 s( F/ \- x ; Stuff to do when Windows Explorer is open
# A+ X k& D2 p. n- D* q& V2 M ;; h; \# [/ C" A7 P; a, z& m/ q: M1 J
#IfWinActive ahk_class ExploreWClass|CabinetWClass
& N( J0 Z" y0 p; v; B- v ; open ‘cmd’ in the current directory
o+ n2 {7 r# G- q+ M6 m a% p ; |6 k9 U" ~3 l) Q9 |, k5 u6 g
#c::
( W; n$ ]6 R, ^2 J. O OpenCmdInCurrent()* `2 [$ M6 E' w. y1 k) d
return
1 }. t8 ?' z+ r# U #IfWinActive. t6 O. `+ C$ K4 J: \
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( B$ E: B2 c$ Z6 P; E( ^0 \
; Note: expecting to be run when the active window is Explorer.* w. Q; F% ^; V' e
;( m$ ~$ x7 r# G1 Y' e
OpenCmdInCurrent()
0 `# a5 Y# B0 K {
1 o# b g2 t; P8 n ; This is required to get the full path of the file from the address bar6 v5 V. [* f0 M5 u, ?
WinGetText, full_path, A- g; \$ F1 V* D
; Split on newline (`n)
$ g+ C" Q3 U8 T8 |3 s3 Q StringSplit, word_array, full_path, `n
1 o0 ]+ V/ E: d1 `$ q" U6 d ; Take the first element from the array
6 { m) J; J, P1 }3 U full_path = %word_array1%$ Z! Q0 C2 Y& [/ P. @/ C
; strip to bare address
9 u- w6 Z4 E# |: P full_path := RegExReplace(full_path, “地址: “, “”)
+ }( d d; E! n$ d4 G- J ; Just in case – remove all carriage returns (`r)
, i2 F$ r% y9 {- l$ @ StringReplace, full_path, full_path, `r, , all+ ^' p1 l N* M
IfInString full_path, \+ ~7 a4 D' i% t- B# p0 I
{1 G: p- D3 j! S. A
Run, cmd /K cd /D “%full_path%”
9 `; p8 ]* C3 L) n( | }" m& U, M6 n! S& x8 ]5 F
else1 O" _4 t6 U9 \/ b& m& Z8 C- F/ P
{
7 \9 R) L7 o; g/ I1 a, R7 f" n$ x Run, cmd /K cd /D “C:\ ”
9 n& O e# }( k# _' f/ P+ Y' m/ ^3 y& } }% h; I; [3 b$ S `: V( C
}
+ ]$ R+ H1 G v) O% `, d 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: p8 ]. M0 p" [4 P3 {8 J
这段小代码肯能有两个你需要修改的地方
- `6 ?% z0 O9 b 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
U* V' v) R/ [1 l7 d 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- w5 M8 ?- ~$ l$ N! ~$ L ^
|