此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
! c) }1 Y& N( |0 u 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。" j2 K) m+ x( c
方式一:
1 g0 F. k- I5 p3 C Y 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
8 t5 ^% E' O9 C6 D 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
% M: q. } n$ P( C; t1 i HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ c( y( W3 d$ R; E& O" r 方式二:" ^% j5 }1 p# s: Y! F
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 m) |! R1 ~! l6 Q
SetTitleMatchMode RegEx
4 i: }3 P3 n7 ~/ \8 E& K return
8 | @! T9 `1 {8 J9 o' C ; Stuff to do when Windows Explorer is open
$ d7 d) w" ~$ o3 l* }- J+ h ;5 r$ F/ ]( u1 x% t
#IfWinActive ahk_class ExploreWClass|CabinetWClass
; w4 V3 w8 \( t5 f. w5 M6 F, G' y ; open ‘cmd’ in the current directory; b! b5 j& Z( f4 t" S9 o9 q, e
;
9 ~/ B$ g1 s `7 v! t2 v. i #c::2 K2 ~8 m6 T) S( Z8 R
OpenCmdInCurrent()0 X1 w2 J. K' ]7 { R' Q
return* o. {: B* g$ o% V
#IfWinActive1 G6 I9 {/ f, ~, t
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
0 F- O& n0 B8 Y- j) H* ]0 b ; Note: expecting to be run when the active window is Explorer.6 A( Q T9 [8 q3 g7 G0 z$ {& t
;
/ |, Z* u* @, O+ @/ _+ J9 h% G! E OpenCmdInCurrent()
9 @8 s! l; c5 T {
" c- ~; i1 x2 v5 i ; This is required to get the full path of the file from the address bar
) S$ ` S1 O$ @8 R( I& s/ V WinGetText, full_path, A
( J+ Q2 X3 g, M- t8 { ; Split on newline (`n)
' f2 w R- d' s w$ x, ]% S* Z StringSplit, word_array, full_path, `n3 u8 u% E8 U9 |+ N. ?9 m
; Take the first element from the array9 t& w3 D1 C+ {4 z
full_path = %word_array1%
8 ^/ |; z/ O# R4 }3 [ ; strip to bare address
C; A2 x- {+ O' H0 K& \# F full_path := RegExReplace(full_path, “地址: “, “”)
: U- j' k4 I( s8 f- U7 z ; Just in case – remove all carriage returns (`r) S+ |9 Q3 `+ P; k+ L2 J$ `. i
StringReplace, full_path, full_path, `r, , all
- e0 H8 }7 q6 B: O IfInString full_path, \; V( W' }* _4 P1 M9 }0 |! t0 k
{) I+ ]* c1 f; ], E1 C
Run, cmd /K cd /D “%full_path%”
$ G8 F1 R5 {$ X2 c9 ~4 u% p }
. E. j' I5 w* Z. k6 L+ E else8 z( ?% X/ ^% c8 `
{) |$ w# T2 k* D7 u/ l
Run, cmd /K cd /D “C:\ ”& H# P3 c, K9 N7 \# o
}+ {2 |) M. i @7 |5 f+ @' O
} f5 x5 S4 w' o* {/ K
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 Q# R- o6 D+ @$ d5 ?
这段小代码肯能有两个你需要修改的地方
/ i$ B% y$ \" i8 o% w 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. e- L5 j0 s& F, @ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “* @4 Z& H' G$ ~4 `* @ V
|