此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' g* ` ^- P" _5 l L! t8 ?
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。0 A, {/ _% z5 h( j5 P* t
方式一:
7 R- m* H: A# w w' K+ e& E$ o 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# ~1 k/ w( N7 N* v& U# [ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
# h4 X( J3 c' i8 @% k HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ x1 ]- V# F, ?. U9 s7 W 方式二:2 v" h: m# s% l* J2 f4 b3 Z$ P' Z
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
0 c: b/ A9 c% ?$ j6 z SetTitleMatchMode RegEx
( O6 X/ k7 k/ k* V5 f2 L! b return0 k. {& d9 {2 M) h3 T) a: s: ^ U$ n
; Stuff to do when Windows Explorer is open
- f# t, Y! E; d) }: \( G: Q: l% K ;" V7 u; \; u4 g
#IfWinActive ahk_class ExploreWClass|CabinetWClass
4 Z( Y' d: _# o ; open ‘cmd’ in the current directory4 O) r' V) r* y# u
;0 L" d. I+ g5 B& w( l
#c::- E- [, i: z3 }2 ^+ j R4 S
OpenCmdInCurrent()$ F ?; t; S% ^/ x2 {* `
return
! `7 a" Q7 @+ S; c' s$ n* Z, T #IfWinActive2 `* X7 ~# t8 j& q- O, j1 V
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.. r8 e8 [3 l# Z- O
; Note: expecting to be run when the active window is Explorer.
8 r4 Y2 H1 g& l ;$ X# l5 w+ a, B9 j( S
OpenCmdInCurrent(). t, ]& n: n1 d8 B' d- m& P' _5 Y
{% l+ p1 G! V4 |$ v$ O* B
; This is required to get the full path of the file from the address bar# Z7 B' b9 {! Z
WinGetText, full_path, A6 u4 ~8 B0 Z7 }5 {0 V
; Split on newline (`n)5 ^# R3 A: j: P* Y) T
StringSplit, word_array, full_path, `n
; W( H. o) Z( A9 U ; Take the first element from the array I4 @, ^+ A/ a
full_path = %word_array1%
$ O$ R& ]8 A6 C" } ; strip to bare address) N8 s4 p. Z. [
full_path := RegExReplace(full_path, “地址: “, “”)! i; w! o. J2 Z& N% `' Q
; Just in case – remove all carriage returns (`r)3 T6 }& N1 l* b- C& l/ e5 p
StringReplace, full_path, full_path, `r, , all' `1 {: H) n, z) E, A I
IfInString full_path, \
. P8 H2 | o+ M9 L/ x' J4 \ {
- D# m4 P. f8 X3 j! p3 a, X! @ Run, cmd /K cd /D “%full_path%”3 b- O* w) ]2 K! P# b# Y; U0 ]
}. f6 L9 |* J$ ~) J0 B. H/ T. i1 ^
else, L }6 r- y5 \ Y6 C+ ]4 t
{$ h+ r9 ~! v1 L# R
Run, cmd /K cd /D “C:\ ”
4 p* k3 [% [2 N1 p2 R }
3 |. z" [& ?( X: }. d4 N& m }
6 k4 r; H b! d/ K9 w- |% [ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 i# P3 J5 l8 T
这段小代码肯能有两个你需要修改的地方" |4 b1 g% z& ~% f: X" x+ x
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键. A5 O# U, N9 ~& }$ v4 m- c
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “% Q& h+ G% K9 \8 F( u, j& m( M
|