此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 N3 q! d- }3 z' o( ?
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
: V% _- [3 U: \: a0 n4 n0 r/ T7 ^ 方式一:& v+ W# a, y6 G% h* M4 f& p; z/ i
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& O3 d# q7 ^* H1 } 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! m# [* I5 y0 k; Z9 j) J4 k9 o+ D% U
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 e) ~ k$ u- q7 ?. B/ i 方式二:# Z$ Q9 ~" y& z8 w8 `2 e
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:' O6 j4 X. V% L" x
SetTitleMatchMode RegEx
5 K9 Z- o) h) O' ^/ v: J return
7 L0 h6 p W6 U" L ; Stuff to do when Windows Explorer is open Y+ E) E9 G" |
;0 ?% T. W7 i, P, v
#IfWinActive ahk_class ExploreWClass|CabinetWClass; ]6 r$ C& [6 T% {1 F2 g) Y
; open ‘cmd’ in the current directory0 z. ?: X% l0 e* r# c$ W
;
+ a: \6 y/ f% s1 ?; \* t2 } #c::
) n% @* ~. h v, _* T; ] OpenCmdInCurrent()( W3 n6 I* I' J1 h
return
: C2 H" s, ?; H2 m$ g' w+ N #IfWinActive3 P j+ n, }8 T& W* b4 j: X
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
! ?5 E* F/ u b4 O# {" P7 G ; Note: expecting to be run when the active window is Explorer.
$ g0 S7 r) L/ N" z ;; Z) A* _* n# N, K% X
OpenCmdInCurrent()
8 S! k$ g6 I% F& x k1 M8 B; r% g! W, ^ {# X; ^: v7 z# s* @8 L% D
; This is required to get the full path of the file from the address bar
w, m$ Q+ t( ?: C! a& F WinGetText, full_path, A
$ `" ]4 F$ v f ; Split on newline (`n)
2 F' m) x' q8 o9 q9 I StringSplit, word_array, full_path, `n2 g" e2 Y# z) `9 Z# l
; Take the first element from the array
- {1 H1 i2 C7 E9 b full_path = %word_array1%: P( l- K4 U* n" e% V3 r6 K( m
; strip to bare address
$ ^8 I, ]: r# C6 k6 W! ] full_path := RegExReplace(full_path, “地址: “, “”)
! @7 q/ M. Y: s ; Just in case – remove all carriage returns (`r)# y3 K$ }+ T8 ^) M/ c
StringReplace, full_path, full_path, `r, , all& @9 P4 j( t) z7 N. }( X
IfInString full_path, \4 m+ h0 i+ O' g2 w
{
! C3 H2 d) R8 F4 R Run, cmd /K cd /D “%full_path%”7 h N; D+ N) l7 b) q# `3 }# `
}
. g( q( l+ ]& x! n else
# r9 M" v& G$ ^: C: Y0 S6 c {4 ^; o8 q9 X( P) a$ S2 f! W
Run, cmd /K cd /D “C:\ ”2 r! m. ]0 A1 ]1 H# U/ B, `
}
( a0 A" ~9 f+ w6 i- a1 N }, o7 D, s: j1 F
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 O' h5 H+ u% Z7 ^- Y
这段小代码肯能有两个你需要修改的地方
* T, @/ ]; p4 }, I/ M$ f 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 Y. [! {4 J. x6 } 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “0 ~- _6 b% [1 A
|