此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ E, y/ B! n) r5 i; ?, T 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 m* a/ V7 _) S) w
方式一:4 b. a) s& x9 c, L. @
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: ?8 w, p: P9 Q. g3 l
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 M. C# d2 H9 Q0 S HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。7 n! r1 w8 M2 L: Y r$ O. V2 X
方式二:9 _4 i9 u0 X. \; T5 B
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 _' j: ]$ Y4 Y) v' z SetTitleMatchMode RegEx/ ?0 q1 k9 U! y @
return
; b8 s: a. Q- m: C. x/ q3 I ; Stuff to do when Windows Explorer is open. j/ H( v7 D# u8 l, b
;! P1 r& b# {) |5 N) `8 c" O ?
#IfWinActive ahk_class ExploreWClass|CabinetWClass( D4 [# }5 R" c8 ]' Z% `8 j/ H% T
; open ‘cmd’ in the current directory3 U. ?6 _3 U( I3 F
;
4 I3 U3 _9 w5 k; m #c::
N! a& U. x1 p OpenCmdInCurrent()
+ F) h% i( H0 i) e/ l! k' { return
6 C0 o+ b& ~1 Q" j6 e, S #IfWinActive
. y' ?0 N! ~! ^# F( M$ o ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
" h! T4 B9 L. i3 o0 | ; Note: expecting to be run when the active window is Explorer.
6 d; c, c) B _5 T( d' Y9 \+ L ;% [9 q' W2 `, l6 @1 Q
OpenCmdInCurrent()
9 @4 L+ R5 b. a, Y {
) \2 e4 p6 ~" a& Y3 o$ S ; This is required to get the full path of the file from the address bar
2 T/ X2 C9 C- l r WinGetText, full_path, A6 _% N w/ M+ p* t9 c; l o
; Split on newline (`n)- V! l* m4 t* a. f# A M
StringSplit, word_array, full_path, `n
; ^/ d( s+ n, _" d2 Y ; Take the first element from the array
2 A; y# ^ L- P, l! E, S+ P( c( O1 V full_path = %word_array1%
# U# R. |9 b" y1 }9 z- i/ ^ ; strip to bare address/ c; |9 b0 H9 [0 p4 S; z
full_path := RegExReplace(full_path, “地址: “, “”) C& e, P& v+ M/ `
; Just in case – remove all carriage returns (`r)4 \& w( c0 P, A- o9 a) J) ^0 h
StringReplace, full_path, full_path, `r, , all4 @$ f! ?) l2 O1 n! Y7 P* Z
IfInString full_path, \
( g1 ]- X! Y4 e" H' a0 H {1 i6 ~! i1 w# X! s) L' @
Run, cmd /K cd /D “%full_path%”
! M9 J6 Y: f y( ` }$ v, a$ s. x6 }8 M
else3 W# I$ p- J: c4 o, [2 v
{
4 ^. J/ l5 N5 B% Z, A8 ?4 W! l" q2 ? Run, cmd /K cd /D “C:\ ”* l8 t n3 R8 D3 H* \7 @
}
, G. Q8 L# s3 Y0 I }
+ K# L! _9 N3 J0 @0 j( G; N& z 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 R- S" I$ F% p, r 这段小代码肯能有两个你需要修改的地方
: r' z' q7 n0 A# H9 [* u x 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% K( ^" i; J+ p4 Q& B$ e6 V; O$ f0 s
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “% E! u7 g" Q$ C) ^. _; g1 S0 Y
|