此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
I) a2 y; `1 v, t. i 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
# q& e3 L4 Q/ V% h K) P 方式一:
5 T# W$ V* r6 t- ^ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& A/ ] i* }9 |( W: `% ~ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 w [6 z4 Q0 U+ V; d
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- d% e' Q# u6 v$ x
方式二:. a8 L/ r& V& p2 W" N2 L) b
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- p4 Q# M7 {" ~; c- U SetTitleMatchMode RegEx8 q }+ Y3 @' B& k% c$ d/ n
return
, e, q/ F L# W+ o/ l. i# Z ; Stuff to do when Windows Explorer is open" W) o: F& z5 @+ ]6 ~' ?* _$ b' H, |
;" \' `. `. F# n* F" j
#IfWinActive ahk_class ExploreWClass|CabinetWClass( Y N9 S- _" c5 W9 p5 W
; open ‘cmd’ in the current directory
& N4 \5 ?4 ]& g7 N- `; V ;
4 V8 [/ m# U" E #c::
$ M* K6 y9 ~9 A1 C OpenCmdInCurrent()
8 h& c: X& \: q S* H, w/ g return
* w1 N! R/ a( B8 w #IfWinActive
1 X* Z' u2 p; C7 N$ N0 O' w: Q) Q ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 I4 g ~0 M" \( t$ J4 K$ n7 Z9 V ; Note: expecting to be run when the active window is Explorer.
5 V" ~# _: j$ M% T ;4 K) W& r( ]8 S' t
OpenCmdInCurrent()
& j+ C& I6 ^1 O* Z! t4 c+ T {
! B- Z: o3 c( L! k& G5 i ; This is required to get the full path of the file from the address bar( H: R j/ i5 y: i8 o& n
WinGetText, full_path, A4 |+ r- P8 W4 e
; Split on newline (`n)& O, p: p3 J8 n0 n
StringSplit, word_array, full_path, `n( [) Y$ y+ |/ i2 d! S
; Take the first element from the array
+ o4 Z, b6 M5 [$ X. ? full_path = %word_array1%
# m' Z- J' y* C# L ; strip to bare address6 B2 G I( @" e7 o9 i' P" k w
full_path := RegExReplace(full_path, “地址: “, “”)1 k6 a" m; Y6 u' c: O9 c( N
; Just in case – remove all carriage returns (`r)
' z( l4 M- ?+ G$ Z, U; Q, P: ? StringReplace, full_path, full_path, `r, , all: F7 L5 q4 z7 M$ ~
IfInString full_path, \: \# D+ h1 v p
{9 R. }, P) F0 ?! B1 d
Run, cmd /K cd /D “%full_path%”7 Y- n9 Y0 p5 e) Q) I9 c
}
+ x g( _8 D$ q0 r b* x) d/ i+ @ else
y2 E& I1 p% q) \. n {
) V* }3 N! }& y B Run, cmd /K cd /D “C:\ ”7 ~3 p4 x; g* o
}
* V- Z+ D Z6 f& C5 g }5 p k' q' V, r' t/ k/ h
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& v; r" @" U0 ?* ? 这段小代码肯能有两个你需要修改的地方
1 G+ U1 g5 R$ p( L7 Y9 `: a$ J 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# ^6 J3 h; A; S: _ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 u$ N9 n* P% v/ v1 B
|