此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ X9 d0 l' Z7 a5 Y; p3 x 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, w+ n" N- i! F5 f 方式一:
3 S% e! @. m5 w2 F" [) r* v 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 ^: V. n5 V! I9 W% k7 b 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和% M l, w% Y& Q
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。: u* b x. V" e, G1 `; @
方式二:3 r2 T" m# ^8 q* Z# N5 Z4 a: Q6 o
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 K4 f/ L& v4 `3 W/ \" y
SetTitleMatchMode RegEx9 j7 w, N: w( G3 |% b `6 a, p
return& Q: W0 b" {/ }" L
; Stuff to do when Windows Explorer is open
, E5 Q J+ K5 y# l5 \, k& { ;
* ]8 g$ D R# c( p #IfWinActive ahk_class ExploreWClass|CabinetWClass
. ?* }& s$ e+ _1 q' W" ^& e+ E) N ; open ‘cmd’ in the current directory" G2 R& V' w9 G O
;
' _4 I T$ y7 p: k3 p #c::3 F2 M* ] S5 j$ R4 [+ Y
OpenCmdInCurrent()
% P8 V8 k, S* F, q- k* ~ return, B9 f, y! [3 r2 K
#IfWinActive
" S7 Z% |# k F% L) U; A* ? ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 E) S( S i1 F, l5 E ; Note: expecting to be run when the active window is Explorer.
/ f) i7 U5 @& W+ h1 }" H ;
$ C9 ]3 D" `4 s/ h, e$ t" K, ] OpenCmdInCurrent()7 e: F' {* e6 v
{0 M- K! u# w4 a
; This is required to get the full path of the file from the address bar0 E, M" I" W3 w/ h6 I4 [
WinGetText, full_path, A
! ~4 ^2 N4 o7 B3 `) t3 Z* l$ z ; Split on newline (`n)
' X( u) N, [) l' j! o0 w, X StringSplit, word_array, full_path, `n
/ j% i: k# k6 F5 T2 y6 a* W% R ; Take the first element from the array
! K, R4 L8 j7 _6 K {7 z& p* q( [1 X- } full_path = %word_array1%
4 N+ v) l# Y& ~ ; strip to bare address; U s9 e3 x J) C
full_path := RegExReplace(full_path, “地址: “, “”)" ~, r/ s" K. W& m; w. F' x3 s
; Just in case – remove all carriage returns (`r)3 w! s* ^7 |: C- h6 \
StringReplace, full_path, full_path, `r, , all/ E. {) ~0 @# Z E" g# ~/ M
IfInString full_path, \1 x# I0 e w, `9 h2 d4 m
{
: D; N* y' @- L3 h# g5 r! e Run, cmd /K cd /D “%full_path%”
! J) C0 {; ^$ F" d) p2 g% L }, r8 t6 c8 y$ i8 h: Q
else! h& c }% F4 M
{. D k! w( P1 |- ^ Z2 P
Run, cmd /K cd /D “C:\ ”
0 } d# z' x+ A% U0 [5 Y' f: ^ }
. w# u- C. }6 Z! _0 u% @ }
3 m3 W4 g' f0 ~+ _ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: Q. H6 A3 h8 D8 y! n 这段小代码肯能有两个你需要修改的地方! t+ V8 y) ?, }
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键2 ?9 a- {" H2 [5 S2 A$ X
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “" Z E: m) d1 ~4 E% u/ j
|