此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, d& L8 j: g6 B0 d
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: ?8 w0 G4 [$ s) ]" ~# {
方式一:$ |+ `1 I: K, A. h; |
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 o& {0 ]1 v9 m K
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# k2 N3 M3 K( r
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ \) v m# E$ {* G; E8 I: z: T
方式二:
v- r$ l9 c( J+ R- l: ] 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:- q0 @0 j) j) h' G% _+ a. I/ }( Y
SetTitleMatchMode RegEx9 `( W C2 w$ K& b& c
return. W! C+ p: y( A2 o5 I5 G
; Stuff to do when Windows Explorer is open
- F; A) |$ E; x/ ` ;
- P% J7 T W5 `3 y! q: e. o% V #IfWinActive ahk_class ExploreWClass|CabinetWClass% i8 y0 e4 W. G0 @* C
; open ‘cmd’ in the current directory
9 {! t' A* {% p3 [$ ? ;/ t# {* m5 s5 M$ A) N# S
#c::
. w0 `2 g4 B5 V OpenCmdInCurrent()
- N) U# c3 h3 O: ~$ V$ F; a return1 i1 P) F- m$ Z H9 }
#IfWinActive* N# l2 M( x* `
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 u- m" W4 h/ M9 P% ~* o* f: u ; Note: expecting to be run when the active window is Explorer.. _! _' ~/ g8 [" a+ K& P
;
) x. `* s1 x1 @2 h* ` OpenCmdInCurrent()- X! F$ o4 g3 l- g
{
8 l+ A2 M" m3 F ; This is required to get the full path of the file from the address bar
( V) s5 `/ n: I) i- H7 n' P! L- d WinGetText, full_path, A& w2 m/ [7 ]% R; ]5 S/ G
; Split on newline (`n) G0 m6 M" Y& h" k; m& w& e
StringSplit, word_array, full_path, `n3 B1 J9 o5 A; S# a: x
; Take the first element from the array
6 e1 k, A; I5 V; Y; u! [ full_path = %word_array1%
$ z5 t/ X; e+ y) @ ; strip to bare address
5 [& } c3 e/ g2 f5 Q full_path := RegExReplace(full_path, “地址: “, “”), j/ P. X' U# v8 f& N8 @
; Just in case – remove all carriage returns (`r)
5 l, i. u5 {4 ~2 r StringReplace, full_path, full_path, `r, , all. w: a+ e. o5 ?7 I
IfInString full_path, \
: A, V9 n* t/ Z! r% Y9 Y {- x. w2 m0 X' Z& v) {. p
Run, cmd /K cd /D “%full_path%”, O2 ~+ B$ G# b9 d/ y3 p
}
1 d/ n# N# ? W, x7 Y9 m) n else
: p# }, m0 l/ ]! J {' j7 S' W; |. ~/ F& T: J6 M f$ Z
Run, cmd /K cd /D “C:\ ”! v0 F3 Q F a. O
}/ {/ ?, \& C3 s# j" d- y. T
}+ U) x5 Z, l) q3 K
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# j4 Q4 |1 S7 Y/ t4 Y 这段小代码肯能有两个你需要修改的地方% ?! V$ t" Q4 m& ?: p) q
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. t% w3 r4 ]- H9 f! Z* { 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
% a( {. [7 P% W/ I1 V |