此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 T9 f) g: E$ _# w8 n
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
5 O8 ^) V- ?" N 方式一:
4 ^* w9 L1 u+ E* J, p 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 ?# n. X9 p3 J4 `% [ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! `2 q* W8 }3 n+ _7 Y; h# e
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。; M1 B( p" s. z" Y! z
方式二:4 r# f& o" {/ V& z) Q. D9 n
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:$ S( [6 ], e4 y2 D2 U1 A
SetTitleMatchMode RegEx% s7 A5 U# W( O4 ]4 w
return; J" p5 u+ x7 x* O+ ^) z) T
; Stuff to do when Windows Explorer is open* I$ G0 S7 i+ `' K b3 V5 j
;! }" o. O( C0 u5 F( ^9 J
#IfWinActive ahk_class ExploreWClass|CabinetWClass: Z! M% c, _9 N W* f( w6 b% r
; open ‘cmd’ in the current directory
- L- M/ C' Q' I9 f; _4 v6 D& ] ;- d# ^3 r5 a' v- R7 S4 {
#c::5 v! T6 L1 k; D& V* A
OpenCmdInCurrent()
) e8 q- U( m0 b2 s$ n2 o6 X. i return. a, Q w& x2 s1 N0 P+ B3 E
#IfWinActive/ j" [' W1 h) T6 ]* b( \0 A
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 H* g6 c6 v9 ?: Z1 |' F ; Note: expecting to be run when the active window is Explorer.1 b! c) G) n) G/ z3 y$ [
;/ H7 a8 E5 J( v& f, b6 C. m
OpenCmdInCurrent()
- @3 A) ^* c# b/ m) \- Z% @ {
& }) K$ _8 n' S* d/ c" { ; This is required to get the full path of the file from the address bar2 t9 g- D# k) F4 q% M8 X3 ~% B
WinGetText, full_path, A& ]7 u. u/ a7 ~- F- b4 Y: R
; Split on newline (`n)/ {; m* T3 K1 c* V
StringSplit, word_array, full_path, `n
0 {% K" [; q: B; T ; Take the first element from the array1 F. H1 M" [, E$ y# V
full_path = %word_array1%
% d* z7 c' `& M- L( H. v ; strip to bare address9 q& D& m& c3 g* f, ?3 V' e& e
full_path := RegExReplace(full_path, “地址: “, “”)
. z; a" Z9 K0 e* N& f* U3 G f ; Just in case – remove all carriage returns (`r)! S6 Q2 c' e2 o
StringReplace, full_path, full_path, `r, , all
6 F2 P* r* }4 |! X4 r4 A IfInString full_path, \
0 b! ?( h) h P {
6 M! E. d3 A: j. R4 } Run, cmd /K cd /D “%full_path%”1 W$ A) s# M4 s9 e8 S" Z) ^
}5 @, z: W6 L$ ]
else. b" x: m7 A$ O' q5 S# K
{0 K+ V6 I" E' V n
Run, cmd /K cd /D “C:\ ”
4 K7 u2 \: A# N4 x }- F2 V# T% M: o7 e7 h" K- W
}
0 v5 I5 }9 W( @ b 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
+ W% [% {% F: H- {9 X' s 这段小代码肯能有两个你需要修改的地方
. z( D' E/ C. e5 B1 H# v& V+ T) @ i+ y8 T7 r 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
2 o/ Q x- ]6 t6 Y0 ]0 [6 z6 s+ D! x 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
( I. U( X _! c/ t |