此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
( u6 F8 x5 S9 w L5 j: P% m/ w 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, n' \6 o3 |% w0 T( o 方式一:
( o3 Y& d2 }* j) v- K9 c 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
8 n" x5 H, O* y. k% n# L 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和& p7 c" p$ R" `& b3 n( g5 u
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* n/ g7 E, {8 I7 K, W! ^4 q$ { 方式二:9 d9 e! w( }$ @
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:0 w# r: x& O0 x1 ?6 J
SetTitleMatchMode RegEx
/ ~) B" @8 }- z6 W return& U4 s2 m! s, {; s
; Stuff to do when Windows Explorer is open) m: n! L/ \7 [) I9 ^0 ]
;
7 m% W7 F- K L8 Z #IfWinActive ahk_class ExploreWClass|CabinetWClass
; C9 B. Y9 r7 o% Q+ T$ L: f5 X6 Z ; open ‘cmd’ in the current directory5 p4 _6 v$ Y4 x! [* `( s4 T
;3 p% [- h9 e- t: v
#c::
0 v% m: h' x z, p OpenCmdInCurrent(); t3 H' V1 h' \6 E
return
" Z( k0 e& L5 l- b #IfWinActive
) I/ n" b6 G0 D* i: ^- m ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% c( r! P$ T) _1 a! Z6 _: ? ; Note: expecting to be run when the active window is Explorer.% ^) Y# Y3 ]5 g1 `7 L6 y" ?
;) C1 h3 z- Q: s5 e5 ]: \7 |
OpenCmdInCurrent()& t, W4 R4 ]6 a% g3 M* ~# Y y
{
; g, h4 o1 `, }) b* y T ; This is required to get the full path of the file from the address bar: u" ?* C3 v" F, W+ g
WinGetText, full_path, A
( p! ?% b: _/ R- o. V/ i B ; Split on newline (`n)2 |7 Z4 R0 p: ?" _
StringSplit, word_array, full_path, `n
: _/ y" r2 X6 m7 R5 y' w ; Take the first element from the array
0 F- g6 w# \- J full_path = %word_array1%
4 { m# ]' Q/ \! x; F& S ; strip to bare address, U) Q" j/ _* }! b% c7 q1 O
full_path := RegExReplace(full_path, “地址: “, “”)
" x' e6 z9 K) ^& A I: s" j ; Just in case – remove all carriage returns (`r)
6 A3 k$ k1 z p" R StringReplace, full_path, full_path, `r, , all
8 s4 }/ d9 n* Z; X IfInString full_path, \8 J) V8 n- O# u3 X
{
5 F8 l# ?% H, D4 p% F, {- l, C Run, cmd /K cd /D “%full_path%”) U9 V6 P0 F) K$ Q9 e
}; L3 d+ h9 g- w+ q9 k- H }9 G2 D
else
* y, S, C# q) D U3 o8 U {3 T6 u/ R. L, S6 d t# F; @6 B
Run, cmd /K cd /D “C:\ ”: n# [) w2 M7 `" E) X1 O+ @
}: R# @6 H! ~) Y: T! O+ J' V
}
6 U, _5 m. K2 V* {- d$ Z 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 Z7 u, a$ ?7 m% R- D
这段小代码肯能有两个你需要修改的地方! m# C9 @; k' b0 X! ]
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键/ ^4 }" N p& m# E5 w9 [
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “* ^. q! J4 l A* W n
|