此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ z5 l2 g. z6 r( \8 S, O i- Y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- t/ w" w1 \% V0 N: D 方式一:
) O, f) {4 h5 ^ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- d& T& b9 V7 t 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: W/ P8 N9 x, x! s% ]' Y HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ J0 S g0 Y0 o7 l0 D( p
方式二:& C% g8 R' V8 }( z- N
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
. ^3 l& |9 ?2 _3 x0 { SetTitleMatchMode RegEx
% Z; R0 n0 w/ k& G3 a u return
- J# ^" R' d V8 |" e$ w! A ; Stuff to do when Windows Explorer is open1 a/ @. n8 I- S( u4 N* a
;, s/ s- `' G5 D* ~9 S
#IfWinActive ahk_class ExploreWClass|CabinetWClass1 P/ t* r* t! f# y
; open ‘cmd’ in the current directory% G5 y1 B8 [9 p: i& o3 Z- P
;
/ m8 w2 h3 C2 P. D3 t% A$ H #c::
/ D& K/ {5 o1 L7 O/ d! d/ s OpenCmdInCurrent()0 b$ Q+ I5 t1 v
return
8 D9 k* s+ @; o( l+ U #IfWinActive
2 E6 |/ C/ k0 r) B0 C4 Z; b/ P ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- {, V+ l( M m/ q) k% X& O ; Note: expecting to be run when the active window is Explorer.
3 {' {! r: E( a! j Z' w/ d! A" n ;3 i# ?; x! G4 p% j& l6 w' f
OpenCmdInCurrent()3 [" \6 u7 d, M; r4 W
{$ O7 K- K) h: e; q4 T% s% ^
; This is required to get the full path of the file from the address bar
: q% F( w8 [5 X% U; U WinGetText, full_path, A
& W) X) I* n: [ ; Split on newline (`n)
, K/ R" ^, b3 N& |7 c1 H+ c StringSplit, word_array, full_path, `n
, x3 d/ ~* Q( Q5 i" d+ Y4 b% G. O1 F ; Take the first element from the array# d! E. Q& z; S! h) V
full_path = %word_array1%
: N; p5 n% V. w6 o ; strip to bare address
& |) P L4 }+ _) r7 R) B \% L full_path := RegExReplace(full_path, “地址: “, “”)
/ H; u2 O" V- L3 r% K ; Just in case – remove all carriage returns (`r)+ g# g4 j( q4 W: B( }
StringReplace, full_path, full_path, `r, , all8 T; r6 V' h& z' S
IfInString full_path, \+ E3 j* a7 Z5 G3 B# A
{* }# O7 P- z9 J
Run, cmd /K cd /D “%full_path%”
3 _+ G5 f4 b- D* l7 j }
, {2 x+ w" [& Z/ n else
7 E5 o( i1 @( @0 K/ v' W {2 }* T5 j7 F6 g$ R4 i) B; t' b% W$ |
Run, cmd /K cd /D “C:\ ”6 |: x3 _: f$ |* O
}
' Y/ x) ~ }/ t! n; l: P }! z* g# X2 o7 v( \" X
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
, M# ]* I* }0 Z& |3 S 这段小代码肯能有两个你需要修改的地方* V7 H( x3 Y6 w- y7 y" @
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ I# k/ l0 L0 u( R3 t( L7 X+ ^ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
0 a( U6 `/ J; ~ |