此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% e0 o# z1 y7 A# j, A4 a5 ~1 | 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 g" }8 ]% i* A6 k# Z$ G' ]
方式一:
8 f3 a; B* O/ u1 N/ f) L% O$ x3 f/ P 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 D" S# _$ @$ n* n. b- E7 g b 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) v* n* A" f7 G, U9 l, o( R HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 o. ]+ Q- I. C
方式二:# m" b6 i$ U# u2 f: u8 h# m
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# G D0 ?+ K( N, u, p3 `. h SetTitleMatchMode RegEx* H0 M2 Y8 C4 w5 e$ [9 t* o
return
, E! O F/ g. W) h7 Z8 f! {* K X* \ ; Stuff to do when Windows Explorer is open
' j( `3 i7 ~) [$ Z, e ;
9 F- a" x/ H. K+ V7 n #IfWinActive ahk_class ExploreWClass|CabinetWClass
3 w7 y: o9 ^2 u) T% l. s ; open ‘cmd’ in the current directory2 e D$ Y/ c# g1 I6 a1 K
;" S- J" y. M3 A: ~; ?
#c::- m0 r$ ?0 |: |% H2 d
OpenCmdInCurrent()* ~- N, H$ P& t5 B% i, G- Z) \2 M; ?
return
! y1 x7 E3 W& K5 G% ^ #IfWinActive$ y3 @; Z2 l+ \4 ?
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; E+ q- c, r+ W ; Note: expecting to be run when the active window is Explorer.. U+ V3 Z q: X
;2 i% k$ e" Y# f3 }6 k8 i
OpenCmdInCurrent()4 X9 E. B- J& v# z+ {& t3 x
{
: A" l: P# J; x0 o0 `* W5 r ; This is required to get the full path of the file from the address bar
. `' F0 ?. w0 v/ d* y$ r WinGetText, full_path, A- k5 Y* e7 w: R: f8 g9 ?3 v
; Split on newline (`n)2 j1 P) j' a7 A0 j. A
StringSplit, word_array, full_path, `n
, K! p% ^! u" i& S7 t9 ^: v ; Take the first element from the array
5 y. Y* K( T7 n8 l& E+ s# u. V! ] full_path = %word_array1%& s; U7 l( @2 z( g& U, i: |9 ]
; strip to bare address
( `$ [- ` G5 y4 {' ]: u9 i5 n9 K full_path := RegExReplace(full_path, “地址: “, “”)
/ l/ z+ m% ?6 E7 b' G* x. W. w ; Just in case – remove all carriage returns (`r)7 N8 H2 a1 W- y4 v3 s
StringReplace, full_path, full_path, `r, , all b) u) T4 ~& C8 }
IfInString full_path, \
* U* [3 e2 u$ y" l% x {
0 l" W+ B/ d4 ^$ U Run, cmd /K cd /D “%full_path%”$ K ]9 u3 Z0 o
}
$ |( G) Y: Q; Y% D& v, z else8 _" k* J p+ X, z( W$ |/ B( q
{9 j- _) {! s4 c) }
Run, cmd /K cd /D “C:\ ”! g' b2 l0 b( i/ I! Z
}( E* K4 x7 A7 n
}' O3 b: m& F: D
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* T& G) R) Z j- Z
这段小代码肯能有两个你需要修改的地方
g, l" h+ M' L& x# g! v7 a 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键. i1 H" {' `: n2 Q6 [
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ e( c' u. U+ ] |