此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 f5 \& h$ b- r# c6 F/ [/ U 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 F( n* k) l/ S/ g- b
方式一:
! \) `7 g. S+ s 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 \4 {0 t( u9 z, T2 o1 N 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" l/ d; L) c8 n HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 B. z/ h9 V5 P7 O 方式二:
+ x. C" t! w7 { 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 ~+ I% x3 O5 ]) Q$ Q% s
SetTitleMatchMode RegEx
# C- Z# L* t2 s* ~6 f return
; w! }7 ~9 x( \+ @' ^& b ; Stuff to do when Windows Explorer is open
* b/ d9 b% x. k- d( w ;
1 S) a% v# n2 X9 @ #IfWinActive ahk_class ExploreWClass|CabinetWClass
2 g! @ G, V4 x( t B$ M) `) O% K ; open ‘cmd’ in the current directory; p9 T4 v* K v5 D# S& I1 P, ]
;
! R" ~% L$ B- C# z: F7 O #c::
( L8 _- b: |& t1 [7 E9 ^; C OpenCmdInCurrent()! E7 a) g$ G) C4 i* e# H! o, H
return
0 }2 U2 S- F# j( E #IfWinActive+ X; u6 J4 R( f0 n C: d/ c
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' C) i( P7 X V0 u/ ~( W M5 @" X ; Note: expecting to be run when the active window is Explorer.
8 u1 Q; E* M5 M1 Z1 g$ u' m' K/ \ ; w8 E9 K [ _/ ~6 u, C* P. d7 Z
OpenCmdInCurrent()
7 c; w" w# \4 ]; T. G$ L. j {" i" v/ U7 Q8 I5 A+ ~0 P$ d
; This is required to get the full path of the file from the address bar+ j L* R* L: e$ H
WinGetText, full_path, A
1 c' ~; P+ `- [7 u# d# ] ; Split on newline (`n)
4 ^8 q$ ^9 a7 R0 K' I StringSplit, word_array, full_path, `n
L% q8 X6 F; ~0 k' H- U! G ; Take the first element from the array
8 \& z" w4 w& v8 u& u& J4 b full_path = %word_array1%
7 u" i; v% c* S& H, X, v% q ; strip to bare address
' N3 Q6 Q" }8 N+ g full_path := RegExReplace(full_path, “地址: “, “”)
5 Z: o3 ?% W! f! e4 M! ~' z ; Just in case – remove all carriage returns (`r)
/ r t! e8 ~! g) p# p3 h+ L StringReplace, full_path, full_path, `r, , all
2 S/ s; V n. n# Q IfInString full_path, \" c3 p I5 W, I8 [4 ~, e. q
{
l! b. x3 [3 v& Z Run, cmd /K cd /D “%full_path%”! W9 g- i% S/ U# V9 o
}
; p& G; M% A$ u3 y( e0 M else
5 k+ G% n5 B" G# y+ b2 }# ] {4 m9 I. }4 t7 i0 S7 |
Run, cmd /K cd /D “C:\ ”4 O8 F1 t$ ~' d8 i& U& O3 ?7 Z8 m3 @
}
) p$ u5 V3 D1 w; @1 k5 Q }
) [/ {" r$ N; @8 x+ I- j 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。; E9 }5 G* t$ p7 Z$ j4 S
这段小代码肯能有两个你需要修改的地方# f; o7 |) I! u
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 s- G5 h! u; P% V 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “7 Y! X, m, s; o+ y, ]
|