此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
, `5 V7 r' [+ F2 G4 B$ C' h8 L 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- j0 a3 g T1 h6 Z8 F 方式一:6 F/ h1 V. K' M+ N$ p# v
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 V" }! h4 h* J# K
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. G( W* X# ^% H: d& B! J HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! R: p4 _" Q% y( f# I5 C5 ? 方式二:1 [, V3 E0 i- d- T7 r
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) v7 N) B+ d2 q SetTitleMatchMode RegEx
& C) F' k6 E: f9 y5 P return
% T2 D* O6 G" ]( o Y" X' j d: { ; Stuff to do when Windows Explorer is open
3 t/ Y+ T/ ?5 T! @ ;
/ T) A" l( w1 B* T4 a- C: @ #IfWinActive ahk_class ExploreWClass|CabinetWClass2 a: [+ F) ?2 w! |3 I
; open ‘cmd’ in the current directory" H0 `' s: x0 |2 U+ h$ @
;5 m4 w0 `; m5 o) q* i$ s
#c::: Q2 m) w F0 ^! N1 T
OpenCmdInCurrent()
( [: z! u( w/ S$ `8 @; d" R return2 D( P: f# }% b: n1 K) V n0 y O
#IfWinActive# [8 ~+ j2 p* }: z
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# S5 N; M8 E: l+ N
; Note: expecting to be run when the active window is Explorer.4 o( C; Q7 O6 u. m5 f! H
;
* M* @ I: g! w. Y, P OpenCmdInCurrent()
, L5 |* e, g; x0 k! D6 i; V {
0 G6 G9 n; S9 e p ; This is required to get the full path of the file from the address bar
7 n! _; U; r% I4 N WinGetText, full_path, A
0 ~- _ h8 D, l) o! y, c5 A, ]& | ; Split on newline (`n). b( z. y x: }8 O+ _5 E3 M* n. W
StringSplit, word_array, full_path, `n$ a$ \% H* ^' s6 D, J4 u
; Take the first element from the array9 X! J; @; V; b; d' Y) m4 ]3 w
full_path = %word_array1% D3 ~, m3 \7 M9 h% ^; p9 Q
; strip to bare address9 H! b q- | W8 q" P2 P* ]/ i
full_path := RegExReplace(full_path, “地址: “, “”)
. y4 [2 O. H! I! l ; Just in case – remove all carriage returns (`r)
- \" i r a- D% a8 R r: x StringReplace, full_path, full_path, `r, , all; }0 q1 W0 `0 v" O
IfInString full_path, \3 e* R8 ^' l* n* C" S+ F8 h
{
9 s2 x, X2 f3 w8 J" \ s1 G9 T Run, cmd /K cd /D “%full_path%”; l4 P+ e4 D. o5 m
}4 h) Z/ Q' \ ^" X1 R5 t5 l
else, g3 J% h5 \- o1 J/ h
{
* J& ^( _8 Y, E' `, e Run, cmd /K cd /D “C:\ ”
+ m( ~$ {% \; n3 M# ^ }
* g' @, S' \1 p X6 B* ?6 w }; ?, {" x1 D; r) v r
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 {' p- Z6 w! Y 这段小代码肯能有两个你需要修改的地方
- y# c4 R! _' o7 D2 V4 I ] 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' O3 I- l% z1 [4 m 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 d& X. [) [- D/ z0 I' t
|