此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% s1 {$ u% o) [; [# d
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: B. C! w" h" _! t$ m
方式一:% A b `2 T; {6 L7 }
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( W5 M: |7 K$ c& Z% [% x7 o
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和1 l/ J+ N% f& `$ h p8 Q4 }
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。$ g* z5 Q2 M- _) n' q+ I
方式二:
8 B. S, H5 B3 F) t5 w! o; I 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" m: O( B& M8 x! L% [, N
SetTitleMatchMode RegEx
, R$ h" C/ e+ F5 \! G return
( O3 v9 c# r+ L7 B( C. G. B ; Stuff to do when Windows Explorer is open
9 y; i% X5 y' w2 h' d4 H8 ^' q$ e ;: ~7 w B# }& I6 H
#IfWinActive ahk_class ExploreWClass|CabinetWClass' B9 A! L& G/ K
; open ‘cmd’ in the current directory* q7 B8 W9 p7 e! q# ^5 G
;
+ w% U$ k0 H' M- [2 Q1 Q- t% Q #c::
) \7 n n6 V0 n" c. C) e OpenCmdInCurrent()
- i& Q r% O1 U return
2 n: g) ~3 t8 y! \2 Y; P: _ #IfWinActive
6 o1 G3 U7 T* W7 M3 }! I: c, \' s ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 b5 _9 q7 P b7 C1 J$ \7 Y8 M
; Note: expecting to be run when the active window is Explorer.
: g* w( T8 V* [( d' \' ~" m ;
( m9 i+ c& K7 U+ g) B OpenCmdInCurrent()
9 z N4 d% W: r" m {
2 E4 f! s' q' M+ [7 Y! n ; This is required to get the full path of the file from the address bar+ v/ i' y2 P3 T1 p6 L! a5 H
WinGetText, full_path, A0 V7 ~. v: ]% ?% U5 K2 k6 o
; Split on newline (`n)
9 H4 i1 y" [9 Y* [ StringSplit, word_array, full_path, `n
7 z1 [( V8 g$ j( W- G; u; Z ; Take the first element from the array
- O) L9 J$ d. q, _7 \, ? full_path = %word_array1%
9 Z( @1 B+ [9 e) s- U4 x+ x. z ; strip to bare address
% Z' J i" E* a3 T& c full_path := RegExReplace(full_path, “地址: “, “”)
3 f8 d, O. C8 a ; Just in case – remove all carriage returns (`r)
' x( ~# O% T; Q: k% W; b' n StringReplace, full_path, full_path, `r, , all
$ C4 E5 I6 W2 g4 o+ a IfInString full_path, \
! e* w" G' z" O$ ~1 p, T {8 P! ^3 z1 k$ h( J% r: m7 L' y
Run, cmd /K cd /D “%full_path%”9 Z) `3 t& n4 Y. l+ \' D
}4 s; d0 a* }) d% X/ i( O4 K4 w
else
! L6 G8 P) w, c O5 z! v {( U0 L% }0 p6 ~& ~
Run, cmd /K cd /D “C:\ ”
! Y! ]" @8 G5 J( k1 ~1 H' S; [ }7 _/ O* M6 p% q2 U. Q/ g! J1 f
}3 f3 E# e: C/ \% D. g9 b3 J5 W" a
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 T) V) Z( A a' w' q! S- B2 e 这段小代码肯能有两个你需要修改的地方
7 f0 b. M% S. p V" W, W; r$ M 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) Q5 T( p/ f- L8 u \4 I& R
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 k0 ^( d4 A6 R
|