此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ h% Y T% y% F& L$ {
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 Q. I' S& b1 J9 }5 }# a% Q- W# J4 { 方式一:% r0 C% L' P4 ^: v& F4 T. u0 c& a
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
' `' Y K# J2 `# ^; j d9 ^ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和0 ]$ p% p) u" z# v1 v4 j: x+ C
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。3 R+ [" J! q. m; o" X; }
方式二:6 S; k( F1 C2 T+ D
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:0 X2 t9 r& U5 B+ ^6 o6 n- _
SetTitleMatchMode RegEx* S6 o: z: @9 r1 {
return
0 |9 ?1 K6 h$ q0 o1 h ; Stuff to do when Windows Explorer is open+ [2 M+ w! V6 D7 f/ O
;: K% p* c1 Q/ Z/ j3 e8 n* O
#IfWinActive ahk_class ExploreWClass|CabinetWClass7 j( S4 T2 [" o( y4 d* l' x
; open ‘cmd’ in the current directory0 N8 O$ U& p1 z9 e
;
8 l6 c9 i/ P2 j5 w# i #c::
2 }, }, k+ B# Z* A- b OpenCmdInCurrent()& X; K" _! z( k7 L' j
return
2 J6 Z# M3 ~5 n$ R1 T+ z #IfWinActive7 U6 V. z) O P/ o
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ { j5 M5 e& `' R ; Note: expecting to be run when the active window is Explorer.
+ |$ N+ T2 R; X4 F- v5 x6 ?$ `7 @: T ;0 K! h9 N- }& n: U% \6 x$ I
OpenCmdInCurrent()
7 l# e, Q% A& F {9 m: p& A% y( y6 g4 j0 {0 z0 ]
; This is required to get the full path of the file from the address bar$ H: r, y8 X. h7 a
WinGetText, full_path, A. g% d2 X5 u6 l
; Split on newline (`n)
( x7 c; O' {1 M+ ?6 C0 }4 h1 J StringSplit, word_array, full_path, `n
0 x3 O7 I4 B5 I6 O5 ^! j ; Take the first element from the array* `$ A5 G6 j' _2 {! a5 W9 \5 ~
full_path = %word_array1%
A9 \$ o8 P" P6 {$ x ; strip to bare address
. W& h* k) r$ P {% ] full_path := RegExReplace(full_path, “地址: “, “”)
6 E0 H/ {: E- `) t7 ` ; Just in case – remove all carriage returns (`r)
1 W5 P4 E, i: z2 A7 {- R StringReplace, full_path, full_path, `r, , all& l. C. Z8 u! P8 ~; _3 `8 M U% l
IfInString full_path, \: E, N% b$ Y- H+ }
{
S7 j! ~, k5 N- p Run, cmd /K cd /D “%full_path%”
- o6 U8 K( I* l8 }- }; R& Q }+ |% k: i& f- }) c5 l' q4 e% L/ D1 I
else
) m7 {4 n, F' m; S3 c* @ {; |& w1 F" R6 B& C
Run, cmd /K cd /D “C:\ ”
f! t" O( R/ D& _. e: N& s0 U }
, D* p; P }3 f% g6 m6 x9 m }, p" u0 X+ f1 f' q# ?& z
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# O- o, T7 e3 b( ?* e4 `, y# o. u 这段小代码肯能有两个你需要修改的地方
" Y& O. Z# {; P- [ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 n ^, Z; Z2 n9 c4 u" M
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: P7 X$ b4 }& j. m
|