此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% W( v1 P7 _& y; h: Z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
) b! f9 {& o8 N. h( t5 i8 l" q9 D 方式一:6 h$ Q4 M9 o: c1 \0 p8 d1 R
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 V; ~; N& H: o4 o% R+ E$ t 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和2 S' G, i( \6 V9 X
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" b; K3 T6 N) U7 \; h1 y y 方式二:
( K# F" T! j* b. |% X. q 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 H; t- [ {# T SetTitleMatchMode RegEx& b t0 r; U9 D% I
return
: ]& `; m$ A/ G. J ; Stuff to do when Windows Explorer is open
: w; s8 j% G' U ;0 I6 L- i3 B9 B/ C) l
#IfWinActive ahk_class ExploreWClass|CabinetWClass
$ Y& i# g! E/ H5 J6 P ; open ‘cmd’ in the current directory& w$ v! ?$ ~; X! Z7 s( d% a
;
" P1 t& i( B) V$ \ #c::
8 ~' `9 A8 p2 G; J5 y; N3 d. s' ^ OpenCmdInCurrent()! L0 ~$ P3 b& w( {
return5 _3 _9 n, c+ s% d
#IfWinActive
# M9 c4 f5 E4 ~% ^( T/ o3 Q+ K ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
$ R- ~8 Q+ T/ N7 T ; Note: expecting to be run when the active window is Explorer.
2 e) P4 w2 n8 z" f( S* F( i5 T* e ;# z( j( k* D7 G+ s# g5 ?+ C5 l! p( i
OpenCmdInCurrent(). j# {$ C# j D$ C
{
7 ^9 G/ j) p) F1 }9 e ; This is required to get the full path of the file from the address bar+ ^3 L' `" `8 S* Z1 F
WinGetText, full_path, A1 U) X$ s, ^* D% m- o m1 C* u
; Split on newline (`n)
, T5 a1 |' `. s; W- H6 s! b2 O StringSplit, word_array, full_path, `n
9 E1 P- w g, N* v ; Take the first element from the array
u Y$ [: |% b3 I( h full_path = %word_array1%
, {& u- y! u0 n) I0 @) g+ Q ; strip to bare address
7 {5 D0 S+ y; ?: I; t+ d; J N5 O full_path := RegExReplace(full_path, “地址: “, “”)
* l6 N" M" K" _4 D7 [1 ? ; Just in case – remove all carriage returns (`r)3 ` b t* V4 x% O1 h3 z* t
StringReplace, full_path, full_path, `r, , all
9 M* k$ M. \9 V* A, Z! g IfInString full_path, \9 K; D. O7 j7 |% d$ R2 z' [
{+ J3 q! g& ^! o- @% Y: m3 R
Run, cmd /K cd /D “%full_path%”
4 V0 @) l+ k$ h& M }, G4 X9 F8 R) k& _0 m, k0 ~& T
else
$ n( l. j3 S7 H; U6 o {
* q+ D4 @7 W) F: m- x9 v0 e Run, cmd /K cd /D “C:\ ”
$ B# }" d" t$ i! u3 M: m+ h }- r' P7 @5 H6 h( `/ q
}
7 w/ N! R; w: k: X 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 e# [. A7 I+ V$ W9 @* t, ~
这段小代码肯能有两个你需要修改的地方
; H/ S5 {3 ~. f7 F6 w 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键1 s z7 O( [, D
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! ?% r% _, q4 W. G/ v |