此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
9 d+ O1 D% x. k 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。" `" V8 d' n0 U" y: j( F; f$ T
方式一:
, J4 V- ]! x, t H# G. [* z) Q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 l, O& O$ ^( d* N* Z$ K+ ] 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( @8 k6 o+ _# r( U! |& X8 d [1 u' f HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ u) s4 k/ ?: H2 ^3 ` 方式二:
: g! t5 i7 ^8 @4 Z/ T. } 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 B D4 X2 p" r7 p& ` SetTitleMatchMode RegEx
T( A% E7 S$ K& k7 {1 L* C, \/ O return' c' q4 }& j* _% }, }6 c
; Stuff to do when Windows Explorer is open4 Q9 T( V/ C. {
;4 {$ d) W- c5 m$ `7 v$ N3 g' t
#IfWinActive ahk_class ExploreWClass|CabinetWClass5 h! o( D* C% y7 p
; open ‘cmd’ in the current directory
4 {0 O) m: I4 a6 Z& { ;
9 J% R4 R: l1 U6 `9 D #c::8 \" H1 M# T/ L
OpenCmdInCurrent()
; S1 \ X$ ?# e! l! J( f; |5 l return: V! y" n( p4 S) b7 b2 b
#IfWinActive
" H6 l3 q& A& N; M, F ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ H) _ W$ r5 Z3 K# P ; Note: expecting to be run when the active window is Explorer.2 H# a7 L" r: y& O7 @. F
;" g1 @1 s) }. U' d; d s4 i
OpenCmdInCurrent()" o G% {; ?5 ` y2 n: m a
{" F6 b# W! i; ?- ~& f8 {
; This is required to get the full path of the file from the address bar
3 {) p$ ~9 K# b# ~5 w E0 w j WinGetText, full_path, A
) F( W9 G D* p' C- Q- V2 R9 @ ; Split on newline (`n); R# H: _" n! ^. P
StringSplit, word_array, full_path, `n
0 N8 `: [7 u+ q, B: s7 ?0 {2 u" n P2 g ; Take the first element from the array9 F9 N' ]% o. a" R A# h. S
full_path = %word_array1%
, i$ l5 p' |& l ; strip to bare address0 O+ Q) `5 h/ U4 }# L
full_path := RegExReplace(full_path, “地址: “, “”)
l1 _( u+ _$ h0 i$ f ; Just in case – remove all carriage returns (`r)
& M( d+ b7 C( s9 Z! D+ V, c! p( U; S StringReplace, full_path, full_path, `r, , all: Z* f: {+ L4 _" r( y) f2 x1 n
IfInString full_path, \
; D* N/ W7 P" C9 e4 i w+ b {
/ {! V7 U( ]& K. ?* j' F* R Run, cmd /K cd /D “%full_path%”: `, v$ j" w: [% u' G4 R1 X
}
k: F# J* k8 b4 y) M. M" f else
- d5 l7 ?* s2 f$ |+ G# X$ q {& d' q" f) v0 C: y" P
Run, cmd /K cd /D “C:\ ”
2 [- U# E2 @) }0 C& z \9 M }
3 q P( F0 m2 P3 ~+ O }' X: a1 P! R, i, x& n# L
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 ]1 e5 r. [: W- Z
这段小代码肯能有两个你需要修改的地方3 A8 {- ]0 v9 |! p- l1 X
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" t2 R" A) P# R. U' B" ` 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
# Z1 T- T5 N! m" G |