此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 I, d6 ?# u& a3 @& h% K
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
: W3 H2 X3 R, {( k% m+ ?" m' D$ y 方式一:: v' y) B! l; g9 J2 x" u
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 @& z5 |. L- |# }
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* {! K( P0 w8 c8 K
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。3 f+ _* ^" h Y
方式二:7 b5 F; b, R& R0 ]4 L2 h
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
! p" L! | F. Y" j) w SetTitleMatchMode RegEx
* b1 j3 n# m: h9 i" Q8 X! b return
$ m Z2 @: I: c; u. K+ q+ w ; Stuff to do when Windows Explorer is open" P8 c) y) L% `7 d$ V1 i* E( P
;3 P7 F. v8 ~- D" |# C
#IfWinActive ahk_class ExploreWClass|CabinetWClass
5 c0 {& X+ q( ` ; open ‘cmd’ in the current directory8 S$ E( D; v* C) e
;
* B: [+ c' X% J* t& V& O #c::6 c7 h$ k9 |5 J/ d
OpenCmdInCurrent()
3 a# e5 ?3 ~/ V5 Y8 A4 y return
& ^5 ^+ T3 u4 Q* z #IfWinActive
8 U* I F% u; W+ ~* T ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: C2 U4 y' A. P
; Note: expecting to be run when the active window is Explorer.
2 W4 u- A7 B" B) E: B2 k9 s- ? ;4 l3 u. a7 O, Q2 I! I [- b
OpenCmdInCurrent(); B& v- O/ o) ]3 K! [ P
{
' r5 Z9 I2 _5 u- M3 b ; This is required to get the full path of the file from the address bar2 z3 E1 z* C$ |3 z* o- z$ l
WinGetText, full_path, A
1 v# ~1 p% C& V7 g) F0 \ ; Split on newline (`n)
* H# O- g1 ^: \ StringSplit, word_array, full_path, `n" S0 m6 S/ U! ^" {
; Take the first element from the array
q, C2 [& }; G, l* n) u7 P full_path = %word_array1%% y( u; e2 T8 Q
; strip to bare address: X4 r: f: s& k7 V; d E
full_path := RegExReplace(full_path, “地址: “, “”)' N9 x8 ^ g* e+ j4 U1 t
; Just in case – remove all carriage returns (`r)9 l5 {& j: F- ?' f+ a
StringReplace, full_path, full_path, `r, , all
W3 L, {9 ^+ u6 _2 \- d IfInString full_path, \- S' S: z9 E. y* ~# K4 d
{: r6 {5 W7 C m! i5 j! E" o8 H5 E
Run, cmd /K cd /D “%full_path%”
* h. L! N, e$ W f6 E% \" a }
+ G9 M, O3 b$ `0 q- ^9 Q else2 f; S/ z0 h0 c# a
{
) Y1 n: w Q# L Run, cmd /K cd /D “C:\ ”* @, C3 M$ U" X$ {# N0 E: C y
}
$ o! k( y! [+ ?% m }/ X; G5 r* E& }+ T+ o
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 }: _) b5 W; z/ a8 s
这段小代码肯能有两个你需要修改的地方( E9 p; `2 h3 F" P' ?
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键 e8 k# F3 h) T! s% t6 X
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
, R( x5 y4 ]4 }; j: ` |