此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ g: H! A1 R& e 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ d% B. u. ]5 |5 b
方式一:
' G: j* j: J K# s 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,3 U1 T2 R2 P7 w/ j$ j4 B6 A) u% c2 j& }
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 V O, K. j! l8 r! U HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
( {* A, K7 c4 { ^& C U 方式二:+ x9 B d3 k3 y8 n% B: h
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
5 _6 {4 e F' o8 G. J. h# F6 M SetTitleMatchMode RegEx
6 k# a. O% j& `7 I5 o return% ~5 p& g& m& f) C& w
; Stuff to do when Windows Explorer is open
9 A' r# g M' ~) `. f ;
x* |: j9 A; k2 S h; ` #IfWinActive ahk_class ExploreWClass|CabinetWClass
2 R5 K# q6 C! H4 I ; open ‘cmd’ in the current directory- G7 c; ^+ B* `4 t0 i
;( V- G. h9 ]1 ?
#c::% ^- @$ t6 l: z* y
OpenCmdInCurrent()
2 Q- H; K z9 w+ t" h6 b" k) q0 I: j, a return
& {- t3 s j' N$ a$ s #IfWinActive
c- Q2 q/ M6 t5 H ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.3 W ?4 { k/ e: ?
; Note: expecting to be run when the active window is Explorer.
. ?7 G- Q4 }. g: z, I) U1 q ;+ k6 q6 Z0 Y/ }
OpenCmdInCurrent()0 ^- t0 K0 N A! x6 g& n
{
: ]( ~; T; i( A9 [% v3 n ; This is required to get the full path of the file from the address bar
8 P% W+ R- E' l, o4 _' @" q WinGetText, full_path, A
+ U5 x% r" c" E& @$ x0 N/ ~" ]* E ; Split on newline (`n)
! J$ A$ ~1 b2 c( v StringSplit, word_array, full_path, `n% y# c$ b7 Z& E8 o. T* W5 S( l( L0 W
; Take the first element from the array1 m8 F f8 ^4 p3 Y) x! q. O
full_path = %word_array1%7 c8 T: O% M- K+ S
; strip to bare address+ f2 D& K9 H) ^% x' c& O! I
full_path := RegExReplace(full_path, “地址: “, “”)
4 |. C: Q& n9 c- w, q ; Just in case – remove all carriage returns (`r)
0 z5 O T3 {2 d7 Y: f4 ]* f) M StringReplace, full_path, full_path, `r, , all( G0 o& b8 @1 s- u3 [
IfInString full_path, \
5 c' I' Y9 ~( b" z& O$ O {4 D8 h( d; h- `' `7 X& c* k
Run, cmd /K cd /D “%full_path%”+ E, e- q% Q" n6 @* K! g0 u
}
. Q7 ~* J8 X# z6 A& U% X) g' R else
. F) u! c& k5 b {- B, C5 f; S1 g+ C" E/ I, Y) ^
Run, cmd /K cd /D “C:\ ”, ^+ s( i3 }$ W8 O/ O% e
}5 w+ c% ?$ O2 k( K; ?
}2 s# R5 \9 ]1 q# [
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 _4 U5 T- t& U5 r 这段小代码肯能有两个你需要修改的地方! _( N1 J) g8 ^/ U
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
_4 u; T" w% |3 q. S3 J 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; z) Y/ [" D+ y! T" G |