此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! e- i% F: z! N4 _
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
/ n0 E/ |8 u& F8 _! S Z2 { 方式一:+ i) }8 D7 Q. Q$ V/ i7 |3 e* `1 |
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 D! W q) p3 A( \/ _& C" G 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- m' l4 E2 a; @3 d n HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
, y0 P! r2 }; Y3 \$ ]5 J; U( d 方式二:
- ~4 K) s+ P% v+ I" X 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:+ Z% W$ ~$ k! B$ z5 b& ~
SetTitleMatchMode RegEx
$ \5 T* W6 }- ] return3 t( ?5 J4 R, S( k
; Stuff to do when Windows Explorer is open4 w8 [% O, ]# w# r4 C; T
;
9 L8 s* O- S' V! W7 E' w: ~ #IfWinActive ahk_class ExploreWClass|CabinetWClass+ n; p2 `5 v1 n2 M
; open ‘cmd’ in the current directory$ B- U! D/ y4 @. \8 C- e b
;
: v, u) \2 O' Q. {. J X3 R7 g #c::
} r* l4 x, W5 l, B OpenCmdInCurrent()( d$ `& I9 Z9 x, |) N
return" O6 V U% x7 X' c7 S( T; w
#IfWinActive4 M5 k% j$ {3 o1 G S2 f! m
; Opens the command shell ‘cmd’ in the directory browsed in Explorer. q) g0 P2 N4 E: _" x
; Note: expecting to be run when the active window is Explorer.: b! @& z6 f% M! _; K; ^5 o
;; [8 p# r! U( I- X7 L
OpenCmdInCurrent()
; R5 \4 u3 W; S) \ {; |/ L8 j0 O8 I8 Z+ y
; This is required to get the full path of the file from the address bar' Q: s. v$ `& n+ e2 l8 {# a) L
WinGetText, full_path, A" [5 D9 d [; ~8 Z9 v
; Split on newline (`n); i2 c& `8 A. }! e
StringSplit, word_array, full_path, `n! h( U+ u) v7 B3 J E& ^4 v2 S1 Z
; Take the first element from the array& L0 a4 i" E. @/ M! B% b1 r
full_path = %word_array1%% d5 t4 W& i7 O* s2 T
; strip to bare address
6 }5 y4 y6 ?- J. [# m; H, I full_path := RegExReplace(full_path, “地址: “, “”)
! o1 \# \% T" Q* ?' V ; Just in case – remove all carriage returns (`r)! F& o. S* g( m6 \9 F$ ^
StringReplace, full_path, full_path, `r, , all
3 s' c: @) \, q" @$ I& V4 @ IfInString full_path, \7 b/ I: e j4 q1 D
{7 [9 ^$ X$ M0 I
Run, cmd /K cd /D “%full_path%”
+ _% b7 ?1 `$ E5 a }/ T3 \/ q$ r* ^- j$ @: x. @
else
4 C. P. l/ b) J7 O" P {
6 b+ u' r6 a. `! T; {' }1 P1 E; X Run, cmd /K cd /D “C:\ ”1 J' i- O+ a, X8 z5 L
}
8 d( b( C' k# c, D! } m0 f }
. t5 f0 \ D/ E' u 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) D7 E* f' T4 W: f! A# {. }
这段小代码肯能有两个你需要修改的地方" q% i4 O* u+ W! j
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, G- ^# B6 C, c/ ^/ w 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “7 E V- _1 _3 I
|