此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 Z+ ^8 v3 f- z+ D; W
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- v" y* s* Q7 r( c 方式一:9 ~1 R& Y# X8 I. p3 V, Z
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 ?8 F' H3 l7 O" T" h/ c3 X. R& y
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' b+ G/ \. |' B) m3 F' L HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。3 ^+ m r7 u* ?& S3 {3 I
方式二:
1 a/ H [: p! g S+ Q# D, \ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:* F$ r2 o. ^& v2 F9 q2 V
SetTitleMatchMode RegEx8 ?' t! w, F& [
return$ p+ m L' q9 P& T3 L5 n; j* @
; Stuff to do when Windows Explorer is open
1 l! J6 q2 x( O& i+ ~. s ;
6 c6 s2 {& E6 e$ N0 A" Y) t #IfWinActive ahk_class ExploreWClass|CabinetWClass
& A* G" S4 i0 G- [ ; open ‘cmd’ in the current directory" x1 r# l& x, l% Q% h' t
;
@) |9 I7 v! s# N0 x #c::7 H/ s* N# ~% B8 i
OpenCmdInCurrent()/ C" b" t9 |- r4 [2 N0 H* s
return' L" P# ]( w- }
#IfWinActive/ l7 k Q9 @8 {; g
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
, t6 f3 l- ]- O ; Note: expecting to be run when the active window is Explorer.
3 `( A: t6 z( F- M5 s# Q; ^ ;
1 \2 d3 {3 P, x9 A+ H2 R) h/ R OpenCmdInCurrent(), @9 d# c' z6 X( M
{
/ S6 ]- w6 E: ^) z( }& n) Y& ^ ; This is required to get the full path of the file from the address bar
3 Y8 c$ U! @0 d3 s$ C2 Z WinGetText, full_path, A* X3 Q- N* A6 }" B
; Split on newline (`n)
' G1 d6 F; n7 r& q7 t StringSplit, word_array, full_path, `n9 F' I7 ?5 `7 }5 E. c
; Take the first element from the array5 ^: J3 x F5 b3 \! W4 r! Q
full_path = %word_array1%
& P1 V6 y. m r1 b) p ; strip to bare address% d1 G5 c% B* }( J# b4 _3 u* a
full_path := RegExReplace(full_path, “地址: “, “”)% O. j' A; d" D& i$ {9 E. p
; Just in case – remove all carriage returns (`r)
9 P! d* S/ c* A StringReplace, full_path, full_path, `r, , all
; E# p/ o7 D3 t IfInString full_path, \
{, X! G8 C( v( d1 I; E$ h% E {. _" @6 d% i" O" {+ H
Run, cmd /K cd /D “%full_path%”
6 x7 H! p+ |) R }
( |* X: T0 x3 C+ j2 }5 C3 M else
+ |+ E! n6 b6 n: \- m. C1 {' T {
0 Q+ s! y S. P$ e7 _% G4 A* p Run, cmd /K cd /D “C:\ ”
) ]9 z- l! \) z# j" [ }
. t, E1 Q( u5 y }1 G7 p6 s) V/ K% c2 K$ ~% W1 i: }; f
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: y( e" S; a$ M' @) D: F 这段小代码肯能有两个你需要修改的地方2 I {& b4 t/ [
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, ?) y# l; L* a: g; L# ? 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 I) |/ j% B `( w |