此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. K! j0 V* t& q0 f- E- x$ T
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: E! q! D- L! p; ~. b# S+ u
方式一:
y2 W [9 Q3 W! |- S3 \4 J 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ c) r7 x* h, k
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" w) e. S) x* M
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 M, K Q% o% k2 N8 x
方式二:0 |# d: m# M) s t% o
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* j) ~. c2 `1 ^8 ^ A2 k9 | SetTitleMatchMode RegEx- w) J: N& {" [. M/ I* F2 f
return
9 |0 D6 A! n+ Z9 y" R1 Z# u ; Stuff to do when Windows Explorer is open9 W1 D+ Z7 A, I; e) J5 M
;4 ^$ p1 ~& H2 n$ @: I
#IfWinActive ahk_class ExploreWClass|CabinetWClass
& ~0 V" B C, y7 O+ I4 {' G( k ; open ‘cmd’ in the current directory' C- W3 Z2 |7 N" G% W$ P4 g$ ~
;# k: J, t/ s( K/ o- [2 p: Q; x
#c::
9 z" f. z( r% P2 L2 _7 S OpenCmdInCurrent()
$ J2 e8 J& N+ c/ Q3 Y! _ return' p- o; m1 K- G* O# ] C
#IfWinActive
- s% \3 ^+ v. n% q5 a) w& g ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. T+ O, S" u5 a/ d! y7 [+ N ; Note: expecting to be run when the active window is Explorer.
4 q5 x2 J/ j- i, g! c ;5 i0 V! _. P* L; Q, a- E9 w
OpenCmdInCurrent()2 i& ~5 G8 n1 S" z( _
{
& P5 n9 a6 U' \2 W6 X7 M+ F3 e9 K ; This is required to get the full path of the file from the address bar# \( b- ~ s# t3 m2 A
WinGetText, full_path, A
8 K4 {, N) N1 }( j& \* o% C ; Split on newline (`n)
; g# I6 x6 U3 ~ X6 l1 p StringSplit, word_array, full_path, `n4 M: y" `) @! m. Z- @$ q5 E
; Take the first element from the array0 D1 i, e6 @6 O$ A0 ?
full_path = %word_array1%
/ t& [: R2 ~4 S. @. y) b ; strip to bare address
9 Z% E1 g4 }% i9 ~ |. g full_path := RegExReplace(full_path, “地址: “, “”)
( r. r4 g- H, ]& r( h& `0 b ; Just in case – remove all carriage returns (`r)
: U" c/ z1 H' n8 Q$ Z, J: T( ~* _ StringReplace, full_path, full_path, `r, , all
3 q3 g! W y9 \; j IfInString full_path, \. Q8 ^# E/ u" g! m! k+ J
{, T3 v) ?3 ]. X/ j$ n) n" g
Run, cmd /K cd /D “%full_path%”
; E5 }) v* f4 {, ~( S }
0 E6 l. _- n" ^0 b else
# T3 P8 J+ Q0 D( H$ {% L {! _% G( i$ Z5 l
Run, cmd /K cd /D “C:\ ”. E. J3 Y3 [8 O- C- ~! d
}$ b, i1 J; r& m# B) A, e! [
}- D f7 [: Y# C9 Y
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% |% g8 U+ k# K- B& a5 K5 Q
这段小代码肯能有两个你需要修改的地方! D( f7 B( H1 r- r+ k
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
2 z2 ?' U3 P$ d; w+ x% L 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 k3 i% i% l, c+ ` |