此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。0 M& S4 d& Y" G- D3 Y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
G4 u% O- m9 ? 方式一:
: k% i& y: f2 R5 I* k. b, P 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表," a- T' M: Y0 c& }+ \. b9 B( n& U% f
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: G8 J$ ^4 o8 u. R* r" O6 a
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 A+ X; m/ X4 }& Y5 A 方式二:
8 J. B/ v: V j1 b0 Z/ L 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 u @( `/ t! q! q- O' O A" k
SetTitleMatchMode RegEx8 ^4 B5 U: Q8 `7 q; w: b
return
4 |1 H3 u$ h5 B- H1 d) E ; Stuff to do when Windows Explorer is open
7 i( u0 l" D; E ;8 z3 E$ g: f: D4 p* F* ^' H6 ?
#IfWinActive ahk_class ExploreWClass|CabinetWClass3 `6 ~& y! |1 s( y
; open ‘cmd’ in the current directory
% {, M$ B+ U. x* @ ;- L O' r7 B0 o4 W4 L
#c::
# g S( |5 i5 \9 v3 Y OpenCmdInCurrent()4 A% v* c8 Z0 C" t
return' D3 m; Q' X" Z& i0 B
#IfWinActive
, L( [/ @: q8 F3 ? ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.- A) f# m' |$ T' a% U
; Note: expecting to be run when the active window is Explorer.
& q* F& _) P! v ;1 `% ~. O+ ^/ v" h, F! i
OpenCmdInCurrent()! @+ v7 g4 G: s4 T. U$ B0 V% B
{9 i, p0 u# q, @; m" `* @9 u& ~: v* V
; This is required to get the full path of the file from the address bar
# |" {8 T4 o3 n$ p' c" a WinGetText, full_path, A1 U# f7 g* l, G& b) L! t
; Split on newline (`n) W3 L' ~* W0 W3 G% e# f2 O% ^
StringSplit, word_array, full_path, `n
" \# Y& V5 ]# G9 X! K4 k ; Take the first element from the array; M. |) r3 g% L
full_path = %word_array1%; L* P" J1 V' C" a9 K' L' P5 G
; strip to bare address7 Z) w" E( p' ~% C6 y# }, H
full_path := RegExReplace(full_path, “地址: “, “”)- {! A# Y* v2 Z. ^. L4 F3 s+ v
; Just in case – remove all carriage returns (`r)
& j/ u4 z0 Y. }3 _ StringReplace, full_path, full_path, `r, , all" K/ C1 i( ?* a) O" [6 i
IfInString full_path, \
, O& X2 }5 N* O) w% p {/ k. f6 x6 Y3 b6 m! ?# h
Run, cmd /K cd /D “%full_path%”
/ i: K) t0 ~& i }
0 j% e8 O$ S- n/ `/ ^5 [ else
7 N5 U/ ~" y# e {( i" y& j- w' T2 N% Y
Run, cmd /K cd /D “C:\ ”4 e; G9 e1 P- |5 y8 g
}. q4 H/ }! d# a% ^; O6 t( a' m
}- }& T; @) D0 s' g
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! c G$ E+ I/ N0 s j
这段小代码肯能有两个你需要修改的地方* B9 ]% P+ I3 ~
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 L9 A q' q! z* f3 P
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “8 ?9 w8 U1 Q4 A# i& ?
|