此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; d1 S! S- i* H
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 K, l- [! L5 r4 p, i3 V9 ^ 方式一:7 _! J& P' k9 I- X; }4 r
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, k: k* N1 [9 V( {4 _/ {! A
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
$ T) r1 x/ f; L5 L o+ `1 T" @ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" Q* \/ Q2 S5 D# T+ u
方式二:
+ D6 \% e. ~% ^0 W" M 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:) U5 P/ u4 K+ v% O
SetTitleMatchMode RegEx
0 ?2 f% J9 _4 J/ Q1 p" R, ^, o% X' ? return
) t, A. K" g; x9 {7 x1 { ; Stuff to do when Windows Explorer is open
$ s( l1 k, e. Y/ K ; d3 ?7 t& E+ [! W
#IfWinActive ahk_class ExploreWClass|CabinetWClass* K$ F; _9 A3 M
; open ‘cmd’ in the current directory
; e$ E2 ~5 J8 ^* M: i% g8 R3 @( p ;* S% n8 ]2 U V6 x) ~$ P* @5 q
#c::% y" ~! [# t1 `& U* I
OpenCmdInCurrent()
' ?* x% I/ f% o3 @) O$ c7 R I return* Z$ d0 a _4 Y1 }8 q
#IfWinActive
+ M1 y( ^: K# a/ @$ r ; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ [7 M4 q, z7 \" R+ p
; Note: expecting to be run when the active window is Explorer.
7 V9 u/ b$ t# Y6 M* Z: D# O% \! h ;
0 d+ W8 V4 h0 M6 k OpenCmdInCurrent()
, t3 z( }0 u3 L: J% U- g+ H: v {* a# @ H! r |) X0 j
; This is required to get the full path of the file from the address bar2 c( g s2 c4 d% \; n+ |
WinGetText, full_path, A
G/ y( ^! C0 n1 P0 l ; Split on newline (`n)9 a6 k( G6 \) P# O' `3 s
StringSplit, word_array, full_path, `n2 ?7 @& s2 Z9 l
; Take the first element from the array! z' q2 I9 w6 u. p, q6 P, v: w1 G
full_path = %word_array1%) G8 S! v* ]. ^8 `! ]4 d
; strip to bare address4 C' b w* L- r2 \* h! J! t6 `' V
full_path := RegExReplace(full_path, “地址: “, “”)! @0 o1 b2 t8 B$ L `! r
; Just in case – remove all carriage returns (`r)7 ]% W! Z. D, o& B) i
StringReplace, full_path, full_path, `r, , all
& m7 f, `# @- Y* i: K IfInString full_path, \
4 y+ @. J3 J- ` R {
9 W% o6 u4 w O7 c& y Run, cmd /K cd /D “%full_path%”
/ j* }; o/ _$ K3 k M }- X. s# R3 i( x7 s N
else
' I) Y; ]+ T/ X$ q4 X {0 ], t* }; }4 H) ^& l4 ^ r
Run, cmd /K cd /D “C:\ ”
3 s1 S8 K+ J, _2 C+ K( j" V& A }
C$ B* o6 M Q3 q6 i }! i0 H0 ^. n* V V3 q5 n7 \0 t
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ Z, ?/ H/ @4 }3 l 这段小代码肯能有两个你需要修改的地方
, ]' [/ v' l! r- k9 m 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 I& h7 b |4 {& ]
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “" v7 h( `; n M
|