此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' A( V+ ^6 X7 y; Q# k, m6 P
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
7 {4 |" @% }3 d$ a2 ]7 Q5 G+ Y 方式一:
- Z5 G% h+ Z$ @0 v 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,' p! a" c9 b/ ]0 w
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和$ P$ [& z% s3 b; W6 P% u/ c
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 z3 M0 C4 z# T* i+ y
方式二:
! d( v& R, y+ Z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 E h% Y7 @( r- Z9 @7 E SetTitleMatchMode RegEx
1 `$ J. O n6 F& ^, K- S return
) s! j6 t- t$ |% s ; Stuff to do when Windows Explorer is open( j' V+ C1 j; p8 n { z
;
4 a; Z% R1 O5 f( E9 C6 w; [ #IfWinActive ahk_class ExploreWClass|CabinetWClass
4 Z# G5 y* X9 b* N ; open ‘cmd’ in the current directory5 O+ r4 ~* r) u M
;
( u" R7 D, R: P# ? #c::
, d- \% l# I* J. v! j o OpenCmdInCurrent()
' y3 t* k) i7 W9 g return
8 @2 {* c I+ Z0 N #IfWinActive
9 R% { J- r! E1 ~* l2 u0 D, J! A ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
, q" a7 `# |. e7 D6 v ; Note: expecting to be run when the active window is Explorer.
! S7 |8 c& N8 u/ Q; G' ^ ;! j9 G; z& `; o& ~. {& @3 x" [0 B j, A- g$ ^
OpenCmdInCurrent()
8 |# S1 t A5 u {, V5 w* j, C5 d* _. \! v a2 v
; This is required to get the full path of the file from the address bar4 u* M4 \$ @0 L9 q; F
WinGetText, full_path, A
. H: O- Z0 a2 C! U5 o ; Split on newline (`n)) l% N* A7 ~# t5 ?
StringSplit, word_array, full_path, `n
1 g' n7 T! n& ?% c6 \4 V ; Take the first element from the array
4 A" k+ h4 z Z& C5 O9 ?3 [ full_path = %word_array1%; `# p: _+ I D& A
; strip to bare address' F3 ~% i9 s4 y& x% K6 {
full_path := RegExReplace(full_path, “地址: “, “”)
; J# P) Y4 b6 s- O' L4 V! ] ; Just in case – remove all carriage returns (`r)
: {8 u8 z9 y/ d StringReplace, full_path, full_path, `r, , all
: T- o0 F" d; q8 @5 q$ j IfInString full_path, \
7 |9 w6 c- q6 l$ O; H3 Y7 B {, a. M* X$ R- G; W# D0 l( E
Run, cmd /K cd /D “%full_path%”. q* o( P1 g% j
}
( d n( t% _' N$ i" w; v) C! w: U else
7 s: l5 L2 W( u+ j {# w9 E% O5 D' B6 e' A9 I0 u7 M
Run, cmd /K cd /D “C:\ ”
7 [8 Y$ ~7 \$ N: T. f q4 M, v4 T- ~ }! y& ~/ T! J! X0 w8 w% I+ ~
}
% R, T% G! }- O- I7 ^0 V0 E 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。+ Y3 g6 a' ]# Z8 B' }" G
这段小代码肯能有两个你需要修改的地方
, n6 `% i( c7 g) s( s( y9 { 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 C& g0 c _8 K# H! t+ {7 K
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “* w8 R% }9 p( ?$ p, y& y& u
|