此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
# D5 @2 n( p4 x9 b& W" g3 z6 B+ i 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ L- q& o! Z8 Q8 q 方式一:
1 L: S3 R$ x$ C2 ]$ O 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,! ]+ v+ I( k# d8 ]: j& r7 k4 m
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
* t: v6 ~+ a+ r4 F$ v! ~ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。3 X$ ^. T9 y/ B2 A3 V- h0 [+ X
方式二:
6 S) @: u$ n. V& s& ` 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- D6 |- g0 O# u6 a, g e SetTitleMatchMode RegEx
3 z# Y; c0 c0 D' C5 r2 O" M return! S( J- e) A6 t& ^, T- h7 J- P
; Stuff to do when Windows Explorer is open+ [0 n( }5 t9 a9 ?' n
;
8 }0 ^: K* g$ {+ {$ `% c #IfWinActive ahk_class ExploreWClass|CabinetWClass
/ \! k8 m' y8 a+ v$ g. w5 B( H ; open ‘cmd’ in the current directory- {8 E4 I6 ^5 P- N5 z. @, x; l
;
' l4 ]; ] C( D# [ #c::3 Z; _+ G3 U1 C1 d
OpenCmdInCurrent()
3 F8 h6 f' T6 m. S8 O" g return d& T, B, b5 g6 H N5 \& V
#IfWinActive2 V5 `% _* N3 a% B
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 @; { |2 c, |' C$ [ ; Note: expecting to be run when the active window is Explorer.2 J! V! K. ^+ ^# ]& n" A
;
* m% x0 D9 V+ s4 q OpenCmdInCurrent()& L5 q4 w* b& G% ?2 R6 K
{% P! ^+ F; W/ |6 b, p3 w
; This is required to get the full path of the file from the address bar3 v. V4 i& x! R5 J% J# k1 R: T8 e
WinGetText, full_path, A
5 U/ K% {& p& J: X" U ; Split on newline (`n)
8 ~$ r1 U* A$ J) ~+ e! z StringSplit, word_array, full_path, `n7 K. V6 a+ G( v# a" s q0 ^, D( {
; Take the first element from the array2 k3 B. c9 r) i- f3 u0 C0 ~
full_path = %word_array1%- J0 D4 m4 w Z4 f5 U- w5 Z
; strip to bare address& j+ w; [2 P) q& k$ w1 y/ t. k. d
full_path := RegExReplace(full_path, “地址: “, “”)
8 ~- k+ U5 i, X: q ^1 ^ ; Just in case – remove all carriage returns (`r)/ l$ g9 M O+ z# O# X
StringReplace, full_path, full_path, `r, , all& q( y4 L& x1 G4 d7 ~# g
IfInString full_path, \* G) J" A k1 s- O) I
{
0 k8 K$ U) C* r. C, v" C: ~- G Run, cmd /K cd /D “%full_path%”" o/ l# K9 C' a! K9 p) v2 k9 r8 Z2 g3 z8 o' p
}& `' p& c9 g! ^. _
else
' j5 r5 F: X; S- g2 C {
" {% w( ^! l/ v, b9 h+ k6 \ Run, cmd /K cd /D “C:\ ”
- Y* `% d8 o. d/ ~3 L }% R. ]! F$ ?) ?; g. r' x
}8 ~- F8 l' t& C. H- o- C: X# }" ]" B! A4 ^
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
9 _# p) _; O2 O) ^ t% l 这段小代码肯能有两个你需要修改的地方
, \, ?+ o4 H" D, M/ ^" L 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 J6 k ~6 _. M e* ?* k( x5 n1 Y2 W 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ x1 _; a d6 \' R. A
|