此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 Q, w5 C8 n0 J6 {3 A 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
% k& s! _- q( L! C# l- e3 W$ e { 方式一:
: |' i) A6 o# l 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
, Q- z6 X# B$ V! M. j 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! h6 a$ j+ y' r' G6 p- F" p HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* ]7 E8 e' m# I: t$ Y( R, c
方式二:
1 r1 p) R: @: l7 n5 b; @0 E% ~ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. q/ s& U4 B' {8 E
SetTitleMatchMode RegEx
7 Q. e0 c& q t return! B, p' X# c4 n9 Q: y" A
; Stuff to do when Windows Explorer is open- R! Y" h$ e7 e6 N- O" z
;7 p) K' Y. C% h# h
#IfWinActive ahk_class ExploreWClass|CabinetWClass* D8 `% a+ }& _: J
; open ‘cmd’ in the current directory# k) C, d2 F9 E' }, _
;5 `. A9 I K" @5 f( D7 K1 R1 c
#c::1 Q+ p! a$ a# B$ \$ L
OpenCmdInCurrent()
# y5 H% C- B6 | return a: j6 ~. E0 s2 R- T0 e3 f
#IfWinActive7 Y( F6 m/ o2 O3 C! S
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
& q8 w' F, p3 ^- q3 u ; Note: expecting to be run when the active window is Explorer.
3 W Y5 U" E& q& i& v7 b ;, C. a) l: _6 Z
OpenCmdInCurrent()/ T( l- Y1 ^( N( a" S' k: {9 P
{
. t- O' f2 x/ k* }5 o1 n+ \. P4 X5 N ; This is required to get the full path of the file from the address bar; K9 N8 \4 b4 r! l* y3 W% F
WinGetText, full_path, A
8 f$ @& ^" u) F( k w6 J ; Split on newline (`n)1 q1 a+ G5 m5 b" w3 k
StringSplit, word_array, full_path, `n: }. R2 |! P0 ]. p! |3 N1 U
; Take the first element from the array
( p2 a& P$ m1 G o' K: z a full_path = %word_array1%
7 z R) N4 w! `4 p/ ]3 F- o& f# I) { ; strip to bare address9 s) b3 N3 t4 Y$ M
full_path := RegExReplace(full_path, “地址: “, “”)# m8 k" M$ U- D( I
; Just in case – remove all carriage returns (`r)
+ L; R( O, S9 Z/ J- m* v StringReplace, full_path, full_path, `r, , all
1 i3 t6 Q3 |; _. P2 I IfInString full_path, \
3 o$ B! N: v0 _8 D2 F- G9 h+ u! Y {
p9 Z+ z+ j7 i& c8 G/ Y Run, cmd /K cd /D “%full_path%”1 y- r0 v# F/ k( W
}, g: _9 ?2 b. }2 n: J- e6 Z
else7 y2 I; E4 j! X1 Q2 l
{
+ q+ l7 U$ _( E9 \: e, o- i: \* l; ~ Run, cmd /K cd /D “C:\ ”
6 a* x5 ]6 @- Z: a9 a( V: e }# W+ a" b& C( ^8 X
}
8 @( U0 P5 e3 j' F# { 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ M+ }. y+ e2 J- z& p: c% _5 u 这段小代码肯能有两个你需要修改的地方
0 k; \2 W% X; p6 J J9 N 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' `4 _- b1 x6 w$ l2 O 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 M% s6 C8 U" b1 d0 L& Y* R |