此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' I! `' r9 R# B8 ?" K9 N2 P
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 C! f$ s" T9 P' s$ O$ W
方式一:
& [1 w V1 p1 x u3 N0 A2 ` 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- Q8 [. a5 D- y+ Y
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 l4 m2 g6 Y3 P" N/ d& r: X HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' \+ P- S1 b$ C5 N 方式二:
6 P$ Y% H% \9 L0 C5 \) S 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 b% v+ b* R# |
SetTitleMatchMode RegEx7 a! U3 w3 d4 c# t4 l, P+ G
return7 Q6 E5 v; o. X& S
; Stuff to do when Windows Explorer is open
3 q3 z7 w- }; k0 L ;1 v& C0 ~' V7 Y3 q, c) i
#IfWinActive ahk_class ExploreWClass|CabinetWClass
$ T9 M- F$ e$ |: [* G ; open ‘cmd’ in the current directory2 F# R) q4 V2 e; J) ]
;
$ g5 ^' B. h( W7 N( \ #c::9 L$ h- ~& ]& \4 J, ?
OpenCmdInCurrent(). z7 i( p% H" v2 C$ f5 s r5 N
return
% A. ^% p1 P$ R y$ ^6 K #IfWinActive
" i0 I1 I8 w/ G: @9 l( b ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: l/ E- Y Q, S, l8 w7 N2 ~ ; Note: expecting to be run when the active window is Explorer.
! O; h1 M% |. P" | ;" J+ H( ]! c$ n: j/ O. @/ f6 p
OpenCmdInCurrent()( \3 I( X2 @' D
{
5 A6 h: P* s" m6 V ; This is required to get the full path of the file from the address bar
+ F) h: I! U4 M WinGetText, full_path, A+ h7 [8 o; E$ \7 L
; Split on newline (`n)
4 G/ s8 n& Q1 H5 \2 X0 ~" l StringSplit, word_array, full_path, `n
( j! J( b9 B" k/ T ; Take the first element from the array! `5 U1 `) k, R( b- ~. f) m
full_path = %word_array1%
+ V" I' m+ F# q9 u$ O: m ; strip to bare address
! ^ s" C) D' k h# U1 t# E8 v full_path := RegExReplace(full_path, “地址: “, “”)
/ V( i2 Q2 `3 b; n" Y ; Just in case – remove all carriage returns (`r)
0 z+ \4 U! f4 z' p StringReplace, full_path, full_path, `r, , all
2 ^. R! \& ^2 y6 z8 p) H IfInString full_path, \
7 R. Q; N9 R) Y {) J6 t: y" g3 v1 I% A3 d& c- j; w* O
Run, cmd /K cd /D “%full_path%”$ b. F6 J' V( ^5 J
}
8 H3 C6 {! M, g else/ z! M" b; G8 a$ W% N/ @! E2 X0 j
{# S( P+ w' I2 U8 ?* E
Run, cmd /K cd /D “C:\ ”. t7 W: X5 l" I; U& b$ G8 y- H
}
. z: ~3 [. d, X+ b/ }3 N }
' J/ Q) M2 ]8 t% C) @$ ^9 g 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
9 ~2 u2 z9 d8 Z; U% f 这段小代码肯能有两个你需要修改的地方
7 E& ~- d3 F7 `) L& P! A 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 H3 ]2 _3 Z- G% C8 V 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
' r: \$ n& s+ ]) ~ _% z |