此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. t7 w7 C$ h$ j) Z6 j9 t3 b+ Q3 r( u
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 {" O6 Y1 f4 o5 @( \# t; M
方式一:
. }7 X4 S; k% k6 x 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 g. ~* O$ `; [
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
3 m; K- O9 W. N HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。; @. H/ b5 u: T; }0 ~
方式二:1 q0 _/ P) t6 B0 _ @
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: m/ h1 }$ a8 J* {
SetTitleMatchMode RegEx
% A( T, u7 Z) M0 H' M return% X: L; R, H5 J
; Stuff to do when Windows Explorer is open
: i2 {( g- A$ I' m' [' f" x6 G& o* h ;" s# I( Q5 D* R; a* h3 J$ u% D. o9 V
#IfWinActive ahk_class ExploreWClass|CabinetWClass+ S' ]8 O6 H; k3 G3 @
; open ‘cmd’ in the current directory
& ^* i1 i X& D; T, l o ;
4 L g7 j6 m# {( p #c::
/ U& W$ R. m1 f/ [ OpenCmdInCurrent()1 s. @5 N9 c) x
return
0 h; E( g6 T& @/ l% ^5 b4 f #IfWinActive
3 R( \2 [; ~" u7 P, I ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% e& g! z7 \* m2 c
; Note: expecting to be run when the active window is Explorer.. {6 |, W2 `! l, n. k$ I
;! R0 k" \! L. L" n; M. w. T6 ]
OpenCmdInCurrent()
4 N3 j' a' ?& e# l {+ L# ^: m. Y2 F' f1 a5 h
; This is required to get the full path of the file from the address bar
* L* W2 v0 B s7 i WinGetText, full_path, A
, X. s& G h2 `2 O! V ; Split on newline (`n)/ Z2 C" C; l) t o, \4 R8 ~
StringSplit, word_array, full_path, `n5 n* r7 F3 Y5 P( M, m3 b# b$ d5 w
; Take the first element from the array
& v# m9 `# m( }, Y1 P0 ?* U full_path = %word_array1%
& U* m! {8 N3 @7 `) d6 B ; strip to bare address
_% o8 u3 p# p' W$ d% { full_path := RegExReplace(full_path, “地址: “, “”)1 R2 X7 X# t |3 _1 o
; Just in case – remove all carriage returns (`r)7 ?% D9 }+ I. g( {+ W) u8 k
StringReplace, full_path, full_path, `r, , all
$ Q! @' Z4 f& h9 }6 T% T IfInString full_path, \
! Q. V% T) y. o. U m {
! T+ [' k% ?1 W e0 z+ D Run, cmd /K cd /D “%full_path%”
7 K' \& w7 {& ?3 S7 Z }
1 G2 k1 M- W* b. v7 V& r else
5 k: z2 Z! j" z r: i {' ~! M) R3 K4 x2 `
Run, cmd /K cd /D “C:\ ”8 t, P* l s+ y' m3 l8 T" T) |
}+ U. ~' D7 C l- i" U' u. L0 ~
}: r: @6 X$ F4 K# J* [& X
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' x- K: s' Y- ]# \$ i$ n
这段小代码肯能有两个你需要修改的地方3 U9 |2 n' h0 }/ b
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
6 U3 R- m' W4 F: \& x; N 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ P8 t g5 L5 e# i: v2 V
|