此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 w7 `3 k: }" d5 J3 n+ @% L$ k
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 m0 s0 T% P) e
方式一:* a+ W5 p) O" i* y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
' ^, L; J+ I( j 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: o% S1 a/ f8 T: Z/ B# D# t) F
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, c1 o0 V, s( E) z/ D
方式二:
" \1 V8 H2 g8 X* J9 [ J 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ z( C2 S$ r5 e4 u( x1 L' O/ T SetTitleMatchMode RegEx
! c r1 a" H% [) {3 v) t2 o4 s3 ] return6 e( K3 [6 W0 a# K3 F
; Stuff to do when Windows Explorer is open
# [" d' J1 z# z: Z1 i, R# l& e ;8 {# H, c0 }6 v- I# n. D7 |
#IfWinActive ahk_class ExploreWClass|CabinetWClass
8 L9 W. u: y: s7 }8 R' w ; open ‘cmd’ in the current directory
% R1 @! L T8 B" l x2 s ;2 H( H; ~4 P6 B* v% n
#c:: e+ T8 J% ?: a9 \( @
OpenCmdInCurrent()
9 b+ K( _8 }! F. k9 L& i6 j) G return/ W7 O9 ~7 V6 ~* O. L4 t
#IfWinActive& ~$ ^) s, z$ @' H* i* Y
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: P9 A3 p; [3 J" _! `& n$ u+ D ; Note: expecting to be run when the active window is Explorer. k: x1 j2 ]& P# y
; {: ^- z9 d( a1 X1 L( s
OpenCmdInCurrent()% i2 G0 Z3 O* C5 T; b% G) v
{
( |( w ~( C5 X, L. B4 l3 W ; This is required to get the full path of the file from the address bar
( C3 |. y# E: z; { WinGetText, full_path, A6 I# t4 g: y. _% D
; Split on newline (`n)' K+ K4 @; w3 C( j. P4 F4 v- r
StringSplit, word_array, full_path, `n
y/ {5 `/ ~; c2 l5 a ; Take the first element from the array6 U4 D2 A8 t* j. I
full_path = %word_array1%* c4 ]; c4 O b
; strip to bare address; n |9 R/ D8 L+ E# G
full_path := RegExReplace(full_path, “地址: “, “”)7 B2 G' P" G7 Z$ g! l; L
; Just in case – remove all carriage returns (`r)
# O) r4 f2 ^- W$ d StringReplace, full_path, full_path, `r, , all: P/ R5 R2 y: x/ B
IfInString full_path, \ N/ Y9 f3 a6 O
{
* J) w# O# e8 ?% n7 t p1 H Run, cmd /K cd /D “%full_path%”; D: V7 x5 E' V$ J! E) |- \/ ~
}
" E; z: Y$ r+ O4 g X1 g7 g1 J8 h/ ~ else5 B+ [! c& H4 j4 h8 j
{% }" Y- v( D9 H4 `5 e/ u/ t
Run, cmd /K cd /D “C:\ ”
- e/ C6 F. K# e' v }. H. V. z9 O i$ k3 A0 |
}5 N' ]/ r# @4 a" k! ~
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ o/ s8 n. W% U. v i5 L
这段小代码肯能有两个你需要修改的地方
& Q+ p. Y: E% M: N# I 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 x: X' V" N8 J7 a& ~0 z
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! B7 G6 E( v* p7 R+ X
|