此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& G, }6 p7 T7 m) x9 [, M4 O" F
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
) D/ F9 a8 E/ x* U! l# J2 p7 r7 i 方式一:% l9 h1 F& k, d) }! G% {2 e
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 o ~ M. N" ] `; D' X 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 A0 [- U. {, c5 e$ w' D HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! z1 G* k+ c4 m: b& N3 U
方式二:
) }7 g* ~$ ]! h6 f( F5 D 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:+ I( n5 [2 s2 N/ F& o; x
SetTitleMatchMode RegEx$ i: R) ^7 O& @$ S
return5 l( ^5 [" G8 P( Q" B' N; D
; Stuff to do when Windows Explorer is open, \ U! f2 P: K3 `$ D! V& k' K
;4 i X1 K7 e3 K/ X: Q T
#IfWinActive ahk_class ExploreWClass|CabinetWClass
5 x. [: r7 _/ H) N# R1 W! [ ; open ‘cmd’ in the current directory( n. h& K7 \& J; g* V
;; ?, ?3 C& g6 g n. C# M
#c::. o! U4 Z! s3 }& }
OpenCmdInCurrent()$ e: z- W. E! l7 k3 R4 M2 j- i: G
return
4 N. v! i6 N0 j1 N #IfWinActive
: p. G; B. W8 Y ; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ w: f t, d5 e: u+ o
; Note: expecting to be run when the active window is Explorer.
x2 i( ~0 c/ N- A( Z& C ;( b6 A! ~2 g4 n
OpenCmdInCurrent()
" `1 D. y" E% w {
5 O: \0 }3 }1 r& L5 j3 M ; This is required to get the full path of the file from the address bar7 a. Y5 F5 a; F. u
WinGetText, full_path, A. u. w+ A4 W9 ]# I2 P2 A
; Split on newline (`n)
* K k1 o7 S7 ~- d" k* { StringSplit, word_array, full_path, `n
% a# I3 Z! v5 X" X& W ; Take the first element from the array
. x! G2 k* i% b& W+ m+ L$ ]8 \& V full_path = %word_array1%
: h7 L' X7 Q" ^( C ; strip to bare address6 K( s" j! E. W, e+ Q9 ~
full_path := RegExReplace(full_path, “地址: “, “”), n; C6 i1 K# o6 j, [' k. S
; Just in case – remove all carriage returns (`r)
: Y- n$ _4 g$ I' t, c, ?- q StringReplace, full_path, full_path, `r, , all
4 Z' u1 X; b9 i7 b IfInString full_path, \2 y' E# i$ Q+ h% g. V" a
{
; p5 i9 O' `* Y4 `8 w$ ~: @" X Run, cmd /K cd /D “%full_path%”
: M" v2 N& E5 V }
: y0 {) K$ P$ j) P/ v else
* n: f" P m% F* D; S {
: U" m- J" }# K Run, cmd /K cd /D “C:\ ”# a: ^. I: y0 F/ y
}
: C1 h1 Q+ D. K* M; p! E" s; q v3 [4 R }
9 C8 t' H1 {) h5 }1 q+ x6 T 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。, o% l+ ^0 h: T
这段小代码肯能有两个你需要修改的地方
2 q; R# O( F6 N n5 e: w) {2 P 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 V! u2 V6 P4 U) }! q
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “5 [4 m2 }- [' F) T# L
|