此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ K7 q) x% _: Q6 I" a- { 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 P6 S. g! h3 k0 B4 V1 Q
方式一:* M8 X' n9 y1 K- @* K
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 ]* h6 V% {: y3 h3 G4 {
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! W* c1 K8 A/ b1 a! g
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。' s k9 ?; W9 ~0 e5 E% H" D
方式二:
5 }6 T& F2 J& ?+ ]% A# c+ { 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 x& `% C' p. D SetTitleMatchMode RegEx
7 }2 y1 e! x5 `4 y7 e* _# L return
/ @: h. Q. B" @. E' @6 x ; Stuff to do when Windows Explorer is open
; H. P8 [. g: \) Z% p; E ;
/ r$ L/ ]* g$ p #IfWinActive ahk_class ExploreWClass|CabinetWClass
5 d, ~8 i! Z0 u1 X% e ; open ‘cmd’ in the current directory
+ C/ E a. d) x ;
% ~* P, \2 u, m/ Q& v a& _ #c::( d/ [! o! H# a" m2 D
OpenCmdInCurrent()
A! e2 ?( e5 I, Y( v return; K; Q8 U9 s: p: q7 a, o4 E
#IfWinActive
# s( z% ^% Z: L: l' J ; Opens the command shell ‘cmd’ in the directory browsed in Explorer., ?# h, F! {9 L9 Z" N% o; } H: Q3 K
; Note: expecting to be run when the active window is Explorer./ `' L/ A. w) f9 s7 `7 L; P5 z
;
) l/ j2 p% J0 v V5 i( N OpenCmdInCurrent()
( {) f B: N, | {& v" f; f+ c: n% f9 {8 ?
; This is required to get the full path of the file from the address bar
: l" |, m% i$ P$ d x% h8 y WinGetText, full_path, A( v8 U3 T* ~. i" N' d/ u9 Q9 U
; Split on newline (`n)8 J. ^5 s& W: ^5 X, Y+ B- [
StringSplit, word_array, full_path, `n
( ^ d- j$ X1 E% g5 z( \8 ~ \ ; Take the first element from the array- g! z* o0 v" w% F+ M% Y) {
full_path = %word_array1%4 x- Z, b0 w8 K! N$ a; c, n2 H
; strip to bare address
# ]: l! s! P; z( n8 x# X/ W full_path := RegExReplace(full_path, “地址: “, “”)
6 @6 _2 V& i# w' i% r! v' { ; Just in case – remove all carriage returns (`r)
1 Q) U% J# _7 G5 ^: m# ]+ A StringReplace, full_path, full_path, `r, , all
4 I$ S5 E3 }' I- k IfInString full_path, \" _6 U6 X# j$ G/ A
{
8 P: e( @2 c8 R- r, d( | Run, cmd /K cd /D “%full_path%”
1 k4 d: y2 ]9 ~5 h) Z' Y }
4 }8 U6 l2 j% ?8 `' ~& ]3 @ else
; D3 Z* A; k" p, H$ p% J9 T {
, f$ Z, Q `7 M% K Run, cmd /K cd /D “C:\ ”- z6 X) {" Q- T( w% c
}, p5 g# m3 h1 h/ C) T- K
}9 @) f+ J+ F; A+ h5 d/ o
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
}6 F* I+ M( s# F; H 这段小代码肯能有两个你需要修改的地方, P- ]6 p( Y$ z
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 v, f( Z9 X& U' @, l; L+ ~
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
% ~% Y2 I- |0 ]5 b! \6 S0 k* `2 \1 k8 g |