此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% F. S' Y: j; Q! t" x8 ^7 P5 p 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 B3 q0 R7 U5 [. T 方式一:
' c0 f4 a$ T3 P9 v ] 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, o @( v. l; d; G
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: ]) C( a V" l; R1 C) _6 v HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ q) b4 V& R7 I# E6 Y/ ~1 d
方式二:
) @# Z8 q% }" k v+ P 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( Q% K+ B: ]9 m
SetTitleMatchMode RegEx: D3 k& V9 d; P& L
return
C1 n" ?' z$ l$ V ; Stuff to do when Windows Explorer is open' @. |3 b# V6 V7 n+ C! z6 i; l
;" N+ k8 O& n! [4 \# E" }' F
#IfWinActive ahk_class ExploreWClass|CabinetWClass
& s3 S" ^1 M" G5 K8 ?7 x ; open ‘cmd’ in the current directory/ c# U2 z/ E+ s5 X
;% y8 N1 ?, N `6 {
#c::
# E" W3 m! C# B x# i. [9 W O OpenCmdInCurrent()
5 h3 n9 [2 W6 } return
' S3 m3 _% ^' g% ^7 u #IfWinActive
# h. c! S' d+ L9 R ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 b3 w5 Q; y# Q! _, |
; Note: expecting to be run when the active window is Explorer.
5 D p* w. s3 W& x ;
& n+ l5 z, j8 J0 { OpenCmdInCurrent()# {/ m( p3 E8 M) Y' ]( w
{- |1 }, F! f" V' |- [
; This is required to get the full path of the file from the address bar
: H& _& ~9 H! n$ z WinGetText, full_path, A: b0 F& E2 U: W% G
; Split on newline (`n)
$ B3 {$ ?( W3 G" ]. R j* j StringSplit, word_array, full_path, `n6 R# o. ?5 D. @! Q7 b7 u
; Take the first element from the array5 K5 A4 |; g9 Z# M2 K4 W
full_path = %word_array1%8 W2 w/ S) d& F2 S* k
; strip to bare address
5 c Z# z& U3 Q' D: k full_path := RegExReplace(full_path, “地址: “, “”)
# l2 p L8 K$ p1 F4 D+ F ; Just in case – remove all carriage returns (`r)
( q3 C f; M% ?/ s StringReplace, full_path, full_path, `r, , all; M, `4 Z+ Q( Y8 A5 D$ b/ X
IfInString full_path, \9 B k+ C+ i2 W) [6 }
{
5 A- @! L" @7 t, ^' x Run, cmd /K cd /D “%full_path%”
* V; n- V* M2 F$ ]& O+ R3 @# x }
: \" A( J1 R G. r4 r2 V3 C else3 `& A' O% u, C, G
{. M. s- ^: Q$ I) R; z6 D, z
Run, cmd /K cd /D “C:\ ”7 [8 x4 p7 L3 K+ R2 `
}1 Y5 ~$ ~& n2 P I4 Q; Y
}
" _) T4 `/ V$ z0 {- \ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" z8 a6 S) M% r% O
这段小代码肯能有两个你需要修改的地方
0 }# {" i$ K* B2 [ t z, |$ Q 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键8 Y" r S. ]/ M6 ~' _! _
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 ?; B9 {/ p9 ?) Z1 G1 x) l |