此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 E) v. o# z# y: K4 g 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。+ |; D7 F1 Z6 P& I$ E
方式一:
; D. k/ g$ D( F2 b; A 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: r1 h: k3 E6 _4 l: H1 Y
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和2 h8 T! m; Z9 d. _2 Z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& X- t& t' @! k$ k 方式二:. p/ M: x( P n* R& A0 ? A. X1 f5 c$ C
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: K9 A/ }6 [9 f' L* d9 _( x
SetTitleMatchMode RegEx" E/ P5 F; v3 |* P3 D, c
return0 r! u0 p. R) Y) x! j3 [: H
; Stuff to do when Windows Explorer is open
/ K% G; Q6 R, [) T/ X/ x ;
0 ]( l8 U% _3 @- x$ @ B #IfWinActive ahk_class ExploreWClass|CabinetWClass
$ J& q: c7 U' O& ]; J2 Q+ d ; open ‘cmd’ in the current directory# K/ @ [) u% C0 M2 ~4 W* a6 W" ?9 [
;
+ B) ?8 I/ l( Y #c::
* t+ F3 V7 m7 g, w1 _) O1 z OpenCmdInCurrent()
0 s* ?6 o+ j2 M9 r Q# v return
( O0 o$ F* a6 z- f' u; a5 d #IfWinActive/ Z# `1 C- n+ ~2 L- {5 R% t
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. T- N$ B( L6 \4 V5 u1 R% U ; Note: expecting to be run when the active window is Explorer.
6 \: K; q/ [) w5 S: G, p ;
- O! g( B2 d8 N0 @! C) J5 e OpenCmdInCurrent()6 ~) a0 v8 Y. S
{
( w" V3 ?5 V% ]* z% B* J ; This is required to get the full path of the file from the address bar
5 r3 U! E( _9 m! t$ q2 Y6 f WinGetText, full_path, A
x4 P, o* z- P! r' S ; Split on newline (`n)
9 ?4 e1 ~: M+ p5 @ StringSplit, word_array, full_path, `n
' @8 a7 |! ]- Z) S0 `+ ? ; Take the first element from the array
) j' v* L$ c3 M( \: } full_path = %word_array1%+ P* ~* f7 @! {4 Y! ^
; strip to bare address- K9 k0 D; p% N4 a$ B. q
full_path := RegExReplace(full_path, “地址: “, “”)
+ F/ Z) G/ I6 h- d/ t ; Just in case – remove all carriage returns (`r)& z* f6 n2 w. i2 Y9 E8 r6 M* `
StringReplace, full_path, full_path, `r, , all* Q. T, `* P6 o9 n- d* i
IfInString full_path, \0 S! h# J% x$ l8 f8 p% u$ ?, H0 H
{
+ ^/ z" Y% o" c2 z Run, cmd /K cd /D “%full_path%”
# s" {5 l9 S/ _ }
/ ?4 F. E; M0 I0 }3 D& N5 B" k% N else+ L1 A! K9 t+ ^6 x/ O7 @) g. D
{
$ x1 `0 w' V9 K" i$ l4 k; n, V+ ? Run, cmd /K cd /D “C:\ ”
9 `) i9 i# ^9 [3 }: \1 O1 T }0 J5 X8 S- K3 p) q/ S' R6 `
}
: |( ^% m0 k; h- L' Y; _; s 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! h9 y; o& ~/ ~. V: W9 h9 I4 E% r
这段小代码肯能有两个你需要修改的地方; T& j" |) ^9 f
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 Y; o9 t: [* ~) X5 z5 \. G$ I 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# [8 y/ @. ^8 O) d$ ]; P) X7 j
|