此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。5 [, _% M6 Z0 @! i8 o* |
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, }( J8 j: \. {
方式一:; g G. L. L* @! ^) C1 a2 a
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% V: i% e u1 u) ]
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和( W- d0 k) n) f! C
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 t- L: F& [ g
方式二:
# G- i: ~7 Y! v5 p, O4 d# Y, B) {+ i& B 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ e" S$ ^) \7 t% @4 k% P+ ] SetTitleMatchMode RegEx
1 Q( {$ \; ^0 r$ m" Z3 F return: ]. O& N+ Z7 V; D1 M
; Stuff to do when Windows Explorer is open
" V* D0 W3 v: D e+ y& Y7 r ;: t* O' }9 P4 ^! b, }* o: i
#IfWinActive ahk_class ExploreWClass|CabinetWClass! N3 d; s" Y9 i1 }6 @- @/ }9 k: \
; open ‘cmd’ in the current directory2 F* [) p4 w6 O, X( X; @" w
;8 [3 P$ c7 {; N, u5 ~% I
#c::
$ O f+ W, E& u8 i' p OpenCmdInCurrent()
2 n$ B9 O6 O& o. p' Q: f return
8 [( r% v5 ^3 v: C8 K #IfWinActive
& j' V+ {2 f3 n2 f& B ; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ Y3 ?+ I) r, T2 ^/ K
; Note: expecting to be run when the active window is Explorer.' r8 P5 m* L7 A0 D5 |& [. [: u' r
;% s9 P# `; l' l
OpenCmdInCurrent()" S6 r9 n" j. q! P t! z
{' \$ q2 J* U; m
; This is required to get the full path of the file from the address bar- t9 A9 \0 }- u
WinGetText, full_path, A6 H/ b) c _: `. l+ H
; Split on newline (`n)
% U+ r4 j; d9 M; @- _ StringSplit, word_array, full_path, `n
; u' N/ Z8 C- S5 v0 b ; Take the first element from the array
. J# F( ]6 I' z# v# W full_path = %word_array1%- ?2 _8 r" q! a. Q2 T
; strip to bare address
; m! `" E( R" ?3 e full_path := RegExReplace(full_path, “地址: “, “”)5 x4 j1 N( Z6 c
; Just in case – remove all carriage returns (`r)( h. |- ~) x0 c r
StringReplace, full_path, full_path, `r, , all3 v' ^! {& Q, w) T
IfInString full_path, \
1 X+ o1 W6 R+ T7 A$ D/ ?2 C4 d {
5 M+ f9 l) m/ }5 C( E' q5 ~ Run, cmd /K cd /D “%full_path%”' O; _7 G$ @* }# c: M1 E$ L
}
9 K* A7 g% N- B) W, ? else
I( `" K) z7 ~ b5 W! m {: J/ {1 u, w' `" N9 M S) r
Run, cmd /K cd /D “C:\ ”
& M; `1 E- L @9 C }1 o& A/ w; q8 h
}2 J/ B8 Z) R7 a5 m; O
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& \* j. Q; G8 J% @8 x# A
这段小代码肯能有两个你需要修改的地方; V3 k) [9 ]4 {) C
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) n; F9 a: _& V* d& V" k; C8 d
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
0 o0 _6 I. V: N+ A9 M |