此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 o0 W; ^# y" K, o 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 n2 w' v) i: k1 \- f
方式一:7 x5 }, K; A1 g8 L! F6 j
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* z$ a* m2 e' K7 D5 ] U 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* n- B# K% W5 S8 v! ^; L8 \+ p3 A
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( |0 S9 Q, N& P2 x
方式二:
" A. y* r2 R5 b, D$ B/ [ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
1 E$ G q4 @$ S* V4 Y9 m SetTitleMatchMode RegEx/ ]6 K8 U0 |6 M0 r6 P9 f8 l
return0 a5 L o$ k/ i! B8 x
; Stuff to do when Windows Explorer is open
1 P) F F0 @, D+ c% _! Z$ A ;
9 z& X1 Q# r8 q3 F& I5 F #IfWinActive ahk_class ExploreWClass|CabinetWClass
/ q2 h5 f g0 l2 {$ Q3 E ; open ‘cmd’ in the current directory+ J- R4 f; r6 ?) ~9 m- ]
;
x# T9 T; R0 p* @ #c::/ E7 K9 `. |3 W. l6 z2 i. B
OpenCmdInCurrent()
" ~4 i! Y1 B A' { return
9 E! D! N, v9 f0 J" |- h #IfWinActive/ X: J) Z- h6 T* k" ]! a5 d* a- d" m) ? [
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 {+ E9 Z" m# |8 l# G* ?: J
; Note: expecting to be run when the active window is Explorer.8 r( U$ R( S- Z8 u, ^' ~0 @$ c
;8 A; [* n( O! z% d
OpenCmdInCurrent()' { x4 ?0 r: b% m9 T8 j/ G
{3 X: R) g: T D% h6 r: _
; This is required to get the full path of the file from the address bar* ]% i/ H% k/ z9 V
WinGetText, full_path, A
g6 V+ v$ o( l/ H, Y ; Split on newline (`n)
2 A9 C7 i6 @. J( O( C% T StringSplit, word_array, full_path, `n
$ ~$ t' c! k5 F$ y- i1 W# w ; Take the first element from the array/ D3 E- X& w0 N0 d' B4 E* l
full_path = %word_array1%
4 t" i2 J7 e3 ^( v ; strip to bare address) t' V! D1 I% v& l& z
full_path := RegExReplace(full_path, “地址: “, “”)
- @1 n0 V1 Q, ?9 w: | ; Just in case – remove all carriage returns (`r)/ G/ `4 \, x9 [; u( s9 C- G/ ^- y0 [
StringReplace, full_path, full_path, `r, , all7 V, ~/ Y1 Z) l, G* ?
IfInString full_path, \
: J* V4 r# V: r* o8 L& x9 { {- k4 c" F+ s/ K' E
Run, cmd /K cd /D “%full_path%”
2 h1 Z1 E5 I7 B }3 K* N0 z* s8 ^' d+ V
else2 a3 Z& Q+ p5 W0 s- E
{; B. N9 p6 N$ n! _& L
Run, cmd /K cd /D “C:\ ”/ w0 N) |# o5 k) ^' A
}
y9 t" S3 k9 H( Q, R }4 W9 S) e9 }1 L$ E# ~
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ K" U& Y) s5 ^! m
这段小代码肯能有两个你需要修改的地方' H h4 j! ]% J5 w$ ]3 ^
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键1 P6 A& Y2 V1 n4 g( c4 A
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 b* @' @! [6 P |