此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 t5 v& }. X: K8 q+ \
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 a0 q+ `" h2 i E& S% a+ A( M
方式一:
4 N$ p t3 J! g 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 A0 C7 B2 z5 ~ N& V
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
L3 t/ f: m: ]# y# s: f* c HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" W! m, h+ N" q0 u6 C
方式二:
% p4 S. ^' s8 k& R 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* d! S# F8 n8 x' B$ o1 a6 i' M3 d% y SetTitleMatchMode RegEx
/ b/ q7 r# M; W" i return
. f/ S2 l: Q9 o" D) S" J. ]) X% D ; Stuff to do when Windows Explorer is open
6 L/ h# T, A3 J* S/ ]& f ;" D; p" J/ t. J8 [1 M! X
#IfWinActive ahk_class ExploreWClass|CabinetWClass
' x" E1 k7 k' f ; open ‘cmd’ in the current directory
* P% h5 I3 P" {$ g, u1 G# u+ ~ ;4 _" G& c- E! D$ g) {2 s
#c::+ y% O; _/ w/ A2 _4 Z
OpenCmdInCurrent()
! {- D: P! g. h4 D. x2 g return: T, \8 u. S7 C/ M2 }8 m1 z7 \! i
#IfWinActive) s& c6 K, I7 e ]/ J1 [+ r
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( r- T" W# e' D$ Z& D8 H
; Note: expecting to be run when the active window is Explorer.
. R; \, g) ]5 _7 a' ?( c ;
7 E( a4 D; |5 P$ V- q- {& h0 a OpenCmdInCurrent()6 z! W# G" c v8 i) u9 b, I3 u
{3 @2 _) s% w0 T i, Z
; This is required to get the full path of the file from the address bar
" D8 B' L/ y6 Y- e* V$ } I; {, p) C WinGetText, full_path, A
) m5 T8 [! c3 b* w/ }1 ?! R ; Split on newline (`n)8 s& ^0 e: [$ n1 K& @, E
StringSplit, word_array, full_path, `n4 {3 A/ H4 F' A% S7 k8 I9 `+ M
; Take the first element from the array" @6 l8 | E' x, S# G0 R
full_path = %word_array1%6 {$ ]4 i0 Y: ~7 m
; strip to bare address4 a5 w3 j7 l# n6 Y* E
full_path := RegExReplace(full_path, “地址: “, “”)
% ~: W8 u9 N8 s9 v2 ]. [( m4 Q ; Just in case – remove all carriage returns (`r)7 R4 L& [- r9 {9 e; }0 k4 K$ _. v& f
StringReplace, full_path, full_path, `r, , all# |% u3 ~6 b% L! U+ P
IfInString full_path, \
& N; u: s+ T2 q$ F2 g {
2 c# P- E* R5 V3 t$ S s( a+ b Run, cmd /K cd /D “%full_path%”
# t$ N2 f- P- {0 Q }7 p$ B, n* C) z" ~( M- s
else
2 U7 I9 C2 s# _% w+ S {
3 {( i$ f7 \7 W3 }; |) W Run, cmd /K cd /D “C:\ ”
& p& E! T4 R5 ]! K }5 g* r Y& z# o2 Y% f
}
' ^! d, G' U/ o0 p1 A7 |) ]! K 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
+ l1 F" ?( L" B! G0 v3 [9 { 这段小代码肯能有两个你需要修改的地方* }7 R0 H4 v7 r1 S! L9 R. D& U
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ E: n* w+ `) r. `" s3 A: i 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. d) Y, Z4 J% A* J4 J1 A
|