此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% V" t* x2 Q0 |1 o# Z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% l7 z! Y! f' ^
方式一: a4 v8 x: x' t' L5 J
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 S* I) Y* p. ?1 Z' o% t 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
E- V+ i" S* M" o' N: K HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
- W& [/ _, c$ b K4 c 方式二:! C9 |* x, n+ D0 K
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
0 Z, g" _9 |% y$ U4 w( d5 p: b2 ~ SetTitleMatchMode RegEx
D' L( L' n' h, N8 E( L+ D8 D7 D1 X3 ? return
, a1 X7 B \) g9 n ; Stuff to do when Windows Explorer is open
; b2 E) u9 y# A ;* x' _* x1 h0 b- z: b
#IfWinActive ahk_class ExploreWClass|CabinetWClass6 h7 t; i& a4 G( l1 f' e, a
; open ‘cmd’ in the current directory. ~$ I2 {7 r2 C- p) v6 d+ a
;3 j4 ~! C. F" @9 L3 F3 q" V. I
#c::
# Y0 y8 x8 V }: ~8 { OpenCmdInCurrent()6 y j, X8 m% l f/ }8 e
return: r. }& |+ `% w6 L9 _/ y
#IfWinActive* p9 f6 N/ Y* i/ y0 Q
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
0 } I8 f) D2 b ; Note: expecting to be run when the active window is Explorer.3 }* B" f# |: m5 c% q. F% L* K
;( Z) W& ~3 }/ ]* D& P; q
OpenCmdInCurrent()
/ A; N8 H8 f( @2 j {
* N: P* K, U4 ]! `' l$ p I2 j ; This is required to get the full path of the file from the address bar
1 g/ o6 L" d R WinGetText, full_path, A4 j# P# g2 G c* | N; q7 {0 D" @# N3 p
; Split on newline (`n)- ?& N) ~$ z+ s; |
StringSplit, word_array, full_path, `n
2 t$ U4 f! A6 y& l# P ; Take the first element from the array4 I! [" R; a- l# ~
full_path = %word_array1%& @/ G0 f3 x! }+ j+ O2 F |& o2 H! m
; strip to bare address4 G3 }! x0 y, j, l. a% x
full_path := RegExReplace(full_path, “地址: “, “”)
2 f- ~* F/ F4 \) C* M5 ~ ; Just in case – remove all carriage returns (`r)
' l$ N( a$ ]! W Y$ K. o9 @; Q StringReplace, full_path, full_path, `r, , all
; o& B2 l# [8 N' i1 i IfInString full_path, \( n# E0 e$ }, L4 Q2 S% {, n8 b
{
! a7 A5 |! a" @( Q" c- d2 V; M+ q Run, cmd /K cd /D “%full_path%”
# S; g4 j/ V _0 G }
8 V: M ]% p6 r* ^0 ` else
# D+ W% s: I6 C$ b* {2 P& i {
6 [6 ~1 K9 h: A1 T9 g% C/ p Run, cmd /K cd /D “C:\ ”
$ f9 b1 ?" g) g }4 \+ R4 L" V" X
}
/ D; x" E7 Y7 I 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- R4 X& R U2 J) O0 }4 w- K
这段小代码肯能有两个你需要修改的地方
, V: u/ b: O3 T' Y0 L; b! W$ E 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ N2 I8 e/ K9 B; ?$ `; z# q' s4 f# Q 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “& e0 I/ y. P! A$ K9 L4 s1 }
|