此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
: v2 C9 n* ]1 w 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 C# W2 d: L" }4 n- T
方式一:7 W3 `: T, ^* r: J, \. b4 m. [( G5 {
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, a, l. x [7 U
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' w( |$ k. @. S' C* G& X HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 x8 }6 C( A7 p
方式二:
" E4 I9 a0 Y& l5 p- t4 Q 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:0 L6 t& `- y* I1 e
SetTitleMatchMode RegEx) Z3 a( o3 n, Y2 o8 Z( c/ @
return
$ S* {+ [2 O. c8 b( a ; Stuff to do when Windows Explorer is open
2 k, T% E8 T* O& e ;) B1 o% z7 ^ V( Z1 U g
#IfWinActive ahk_class ExploreWClass|CabinetWClass
2 R& J+ ^7 z4 B# o) H6 Z ; open ‘cmd’ in the current directory
2 j' o* x+ [& a; K. q' x: E G ;
4 ?% B: G$ x, |0 H5 j #c::" ~: s* W7 x/ \0 i v* J
OpenCmdInCurrent()) e3 f+ m- H4 O4 }( F& g8 d
return: K1 E% ~* _' ], E* y# H
#IfWinActive
+ z2 v$ {6 z: |- m: M9 s: l ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
# @) w) Q; Z5 G' G ; Note: expecting to be run when the active window is Explorer.9 }8 Z' w' ?! h& P; P
;
2 N' u2 d* G" q6 g5 _ OpenCmdInCurrent()0 N9 S% e- W1 [/ z8 M' ?; E
{" |4 B) A; N, @' l/ G8 ~
; This is required to get the full path of the file from the address bar
$ E, Y( r' o8 y& Y7 M WinGetText, full_path, A" K# ?3 ^8 k$ \; p
; Split on newline (`n)
1 t6 V9 a% C" }) M+ R* ` StringSplit, word_array, full_path, `n2 k5 |; L% u! r: R" d
; Take the first element from the array2 Y" w9 z; i2 G- b; C) ?# ?
full_path = %word_array1%
8 L' p3 }6 D3 a+ a7 n' i2 K: A6 \5 L ; strip to bare address1 v3 x1 F1 W) F- t+ Y# ~
full_path := RegExReplace(full_path, “地址: “, “”)% C* l8 N/ }& @( L6 }+ Z5 `! j. h
; Just in case – remove all carriage returns (`r)
9 h" \0 |4 V* Y% n3 P3 t* r StringReplace, full_path, full_path, `r, , all# L9 S, j6 \. a* P6 X R4 ~/ i
IfInString full_path, \
1 G' o* @& w7 q6 l9 d; Z7 |7 s. s {
( o- T' S: F: ^9 G Z1 s Run, cmd /K cd /D “%full_path%”% m# C& f- Z I' ~
} t1 q+ {5 g" D- S: d O
else9 }; q/ d6 ?7 x5 k1 D
{5 y& Z& |1 P0 e6 c' E0 j
Run, cmd /K cd /D “C:\ ”
% u$ L# z9 U m* R- K, P) U3 ~ } q& `8 K! ?) }: k$ Z5 E7 _
}4 F+ M& x1 @. o9 `( g$ Q5 c0 c/ M
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! T$ t( G+ _8 K/ |( t& d+ R { 这段小代码肯能有两个你需要修改的地方
! p8 O' E/ P; T/ S# l) Z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键4 }! G" `; Q' \# {0 @
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 c8 {: X# h* h0 \! T' y |