此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。3 Y2 w! j, Z2 h8 g; p2 R
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。" X, _7 s% `( L3 K/ \5 x6 O8 F% Z
方式一:
5 W$ L, A. t& i0 \& L1 ] 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ B9 n' f1 ^$ W7 t+ n9 r4 n 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 o6 ^- M( D& Y3 X
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 T. N7 B# d2 X5 N% `: _
方式二:
9 L* y0 J, P1 C' V! A6 N 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ K8 C2 `2 V) O+ d; e SetTitleMatchMode RegEx, T9 X% C; d& Q/ o+ X1 z5 q$ G
return
* R' b3 l% ?& h: J ; Stuff to do when Windows Explorer is open
5 e a3 E( D6 B0 d- u2 G+ D% o ;
1 Z( J) L$ p2 L+ ^% \/ ~" {* } #IfWinActive ahk_class ExploreWClass|CabinetWClass
8 \8 h1 S& r0 t' l! _" F) W, X0 S; F ; open ‘cmd’ in the current directory
/ a$ n1 k! _; p$ e9 g ;
! B: U: `4 k; | #c::
' i3 O- z6 r1 [5 P; L5 l: b$ c OpenCmdInCurrent()! Q6 J9 W; `0 B& r: q
return
7 e+ {1 u) P4 F8 w$ {; |: |$ { #IfWinActive
$ P6 S) Y: L" A' |( \: B H ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- `* g1 H ]- h5 B" I ; Note: expecting to be run when the active window is Explorer./ X6 M A) o% P+ p# I3 r
;- i3 b% r, v( B+ p/ O& W% h( }" D3 g
OpenCmdInCurrent()
( V! a7 F3 t% K+ f3 k/ ` {
$ k3 |2 Y/ | f) X( C# C O1 O+ z ; This is required to get the full path of the file from the address bar& o% d' w- ]- A9 S5 C- u) R
WinGetText, full_path, A
/ v% W# v4 r2 ^- ?! ^" ]/ B ; Split on newline (`n)
9 i: C4 k1 l* i* M. o0 A% o4 o- e StringSplit, word_array, full_path, `n
5 e$ E- N; x( w# x ; Take the first element from the array
. W0 o4 n; l. c9 l full_path = %word_array1%5 k7 X$ Z* `3 B; [* X8 v8 d
; strip to bare address
7 l6 Z/ g# b1 G6 x! ^ full_path := RegExReplace(full_path, “地址: “, “”)
- G; ?5 {, c; [. y1 `7 e; e4 j S ; Just in case – remove all carriage returns (`r)
2 Q# x+ c% _5 j* V: B/ j StringReplace, full_path, full_path, `r, , all
5 K0 H! I5 [& Q( A* }! \+ y IfInString full_path, \4 M; t; J9 ?; k/ c
{
4 _# G4 i) a4 e Run, cmd /K cd /D “%full_path%”& p6 {7 X' G% R+ [! j% c& M* U
}
' A& T* ]2 G8 g" z* d W else1 y) b% u3 p% k
{$ `- p% `) `; |2 [
Run, cmd /K cd /D “C:\ ”: ?1 G F7 ~$ u
}
; z, A2 m! n1 P# @) T! M }. _ b6 H$ R6 F. G/ s
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- \5 L- g+ b* U- g% C4 f3 ^
这段小代码肯能有两个你需要修改的地方
9 {4 [6 O+ i( L* l$ a1 | 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ m2 Z" p3 E/ B. o# |) R1 h 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “' |# N0 V) { u0 c4 V
|