此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; U; l0 R& r4 [, @( R
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 N( K; O& k% C b- f 方式一:8 K2 H( {2 w: J; e6 R k0 [
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: `! o2 M R% X) x
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, U8 F$ L2 c3 m1 U9 E
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 }+ x3 A D. ^- R) v
方式二:$ d9 a \/ t6 p6 ?6 ?" v( K, G- M, l5 y) v
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:; o9 h. N" L0 C/ V, r
SetTitleMatchMode RegEx
. S+ _# g; w9 ?# } return# _4 {6 I3 Z: i, R; I I! k# k
; Stuff to do when Windows Explorer is open$ \# z) t/ _6 R8 h3 k- M
;
' }# @7 b7 d$ c+ X8 U #IfWinActive ahk_class ExploreWClass|CabinetWClass
/ ^3 Y9 e' l4 w a a ; open ‘cmd’ in the current directory/ @3 }$ B& }0 J! I
;
* }" A1 d# T! r5 O% _ #c::) A4 r# r" t. s6 d+ i8 s9 c5 ]. Q# j
OpenCmdInCurrent()& I: g& Y9 [6 o$ A* ^4 o
return, ]- |* n# v+ V* M0 @2 j0 w
#IfWinActive6 }7 U6 X- L" l* H/ h& N
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 }# d" F2 `$ L3 y: X7 t7 h ; Note: expecting to be run when the active window is Explorer.
3 b1 h9 y' Q1 }. L/ s ;
0 e. ^; D* |& ^- u OpenCmdInCurrent()+ Z/ H9 R4 A' V
{8 t0 `: L# f- e3 S: q
; This is required to get the full path of the file from the address bar' s' M! O: [7 A- }" n
WinGetText, full_path, A6 l$ X- Q, M6 Z
; Split on newline (`n)# X6 r! ~2 v: n7 M1 y
StringSplit, word_array, full_path, `n
6 F B8 v& F. ]; _& t ; Take the first element from the array
( l8 d: d9 \! L; I1 ?! u& V5 W3 q full_path = %word_array1%- G9 s: ~) D# d% w h( N
; strip to bare address
3 M7 _* f9 b4 M, S/ e, \ full_path := RegExReplace(full_path, “地址: “, “”) X6 e, s8 `. a) t1 A
; Just in case – remove all carriage returns (`r)3 ~* B/ ]- Y3 `, ]" I' T
StringReplace, full_path, full_path, `r, , all, v* e: ~& {3 x8 W7 a% q
IfInString full_path, \! E+ A9 ~9 W' C0 u2 l& K" K
{
3 B# `, m1 Z( g7 i9 {2 c, u Run, cmd /K cd /D “%full_path%”/ {% U' [8 n- D% s8 M9 v
}$ ]/ u: @1 h$ h- G3 g5 S
else, Z0 f7 c5 |' i; f! q" l1 m- I9 @
{, z) K. z8 F) s8 C8 O
Run, cmd /K cd /D “C:\ ”
. C/ G* a, w$ q6 L. ?5 X }
' j3 p- s# \# \+ D }* P, ?! d+ M/ N$ S
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 f9 L6 B0 N9 p2 M
这段小代码肯能有两个你需要修改的地方
. ~( Z" ?2 ]# l0 @, v, b 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ \ ~( h: L0 A3 k' k/ g3 ^& m; t5 Y 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 B% e$ C: i/ s+ Q |