此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' p5 ]! p6 y1 `; b) H' X+ V( J6 p X 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 f. J. o3 f% @ S5 d" E
方式一:
; U' q! m0 R9 C9 J 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ S8 c. Q1 c0 }4 w; j
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
0 Q5 {1 P9 \) l$ Y( r2 h, M HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。: a4 |( e1 @1 j% Z* F. f
方式二:8 \2 y" j+ N$ W: w1 t$ P2 u
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 j$ t" Y$ {% m! b) K* R
SetTitleMatchMode RegEx0 s3 z. h9 [7 U! E, Z
return! M- }6 V! E- U/ k3 W. G
; Stuff to do when Windows Explorer is open' W5 V3 F5 v" N& a' v
;/ l4 c* \ ~ j; W
#IfWinActive ahk_class ExploreWClass|CabinetWClass
. N- G" y9 E; I* w( B ; open ‘cmd’ in the current directory+ K }% x) u$ N# x2 J
;
( n3 E }" s- v5 Z( p, A #c::, j3 \4 }2 W4 h W3 w) F- K- X
OpenCmdInCurrent()
, {5 F' P/ I' u- V return- M5 ~& O& C3 K' \0 T9 g: z9 u
#IfWinActive
( f2 ]1 G! T; s1 x8 d1 P ] ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 X- O H, k# f# k( d% S
; Note: expecting to be run when the active window is Explorer.
8 q1 h3 |- t8 V* _, L9 X s& c' J ;" A w( p% B/ V
OpenCmdInCurrent()
# e! r" @4 }$ J5 y4 D {5 ?) {7 w3 \ R5 M
; This is required to get the full path of the file from the address bar" K* |) |8 B3 q
WinGetText, full_path, A- c' g. c$ G& g) {% J6 K& ~
; Split on newline (`n)
% L' }: I" T+ A) k' t StringSplit, word_array, full_path, `n# ^6 x9 Y5 s; j; d3 @$ A
; Take the first element from the array! H" `& A5 [! \ Z; A3 U
full_path = %word_array1%
. M% E$ N6 Q5 Q1 Z- i& K ; strip to bare address
3 b9 i1 G7 d2 R) u u' M, G5 R9 p full_path := RegExReplace(full_path, “地址: “, “”)0 R; P1 s# Y9 Q R6 t- _, v' M
; Just in case – remove all carriage returns (`r)6 p8 m" r0 D5 ^; @5 A
StringReplace, full_path, full_path, `r, , all
8 U) }5 z7 m {; z IfInString full_path, \
2 x0 K) p2 ]( w8 K {
$ e5 o& r2 ^! J# Q7 w% E0 e o Run, cmd /K cd /D “%full_path%”
$ J3 J" t1 S% y- {! ] }0 M( b' Q% r) y& H& x, G
else7 e7 m" T: @9 n d3 n
{
2 B- o5 N3 J9 V- Z4 V9 l Run, cmd /K cd /D “C:\ ”
! q; c/ U0 J: c' k: t% Z: o0 w }4 }. R+ x7 Z6 s" s$ y W
}; _" q) q6 q+ L# S$ x9 w, v8 p
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。# h# @9 g1 S/ L
这段小代码肯能有两个你需要修改的地方
7 {% _6 `4 E, }1 S8 ? 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 c0 h5 ^' ^7 J* l# ^ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- U# V6 v7 r2 `2 w
|