此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 n2 Y7 x& B2 ~# I. i9 h2 Q- k# F
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
/ c- _' O) ]) i0 @ 方式一:, o) b. O( ~% M6 q
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
+ h1 l2 m- P) `* r3 L 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ s+ Q, u% T# `' \
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 i j1 Q- t& Q0 K# d: s+ \, f' O
方式二:0 L6 }6 ]; {0 f. g8 S% o
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 S5 f# z- A& ^/ ^; ?$ v8 c! G% s SetTitleMatchMode RegEx: [% i" v, T- H* O. F1 V
return
4 p/ M S h) A1 f8 v) J ; Stuff to do when Windows Explorer is open
1 P+ ^8 D, H0 I0 J, w ;3 @6 ?7 x2 Z. c$ u
#IfWinActive ahk_class ExploreWClass|CabinetWClass
5 K, |: e( c5 Y ; open ‘cmd’ in the current directory
7 S0 _5 m0 x& Q1 W/ C1 \6 n ;
$ A. W6 Y3 b$ T+ a #c::
% n: d: u7 {% D S* {. H0 `" v OpenCmdInCurrent()
! Y2 K" c6 y1 [5 B0 e1 t" j, k return
; K3 f& M( t+ ^# a/ o #IfWinActive
& s% M0 x8 j! H# L) \# S3 |2 N9 _ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ q- \6 _& O M4 E( c7 i* p
; Note: expecting to be run when the active window is Explorer.
( s" O% p' W; j- C; ~! q ;
& e+ L" S) h2 p' V OpenCmdInCurrent()
: B6 p8 K( S( @* ^1 q {
5 `! B Z' {, [5 b ; This is required to get the full path of the file from the address bar5 W" q# l% Q# C3 ~& n% {4 P- X# o
WinGetText, full_path, A+ j0 o. X1 v4 h9 ]4 y
; Split on newline (`n)
# E8 {/ h6 }+ {5 L1 [ StringSplit, word_array, full_path, `n4 ~: _; L+ g% G; q
; Take the first element from the array* h! M( W2 y$ L
full_path = %word_array1%
2 ~1 w6 A' D5 _0 M( n% o ; strip to bare address
2 n. |; o# b, ~5 ]2 _) U0 p full_path := RegExReplace(full_path, “地址: “, “”)2 [9 N! E( {6 s8 @ |% O
; Just in case – remove all carriage returns (`r)
) T" W; b3 @' q6 g. S* W StringReplace, full_path, full_path, `r, , all
) h" R1 H: V$ K' `' m1 B0 Q( T+ O IfInString full_path, \
$ u% o' @$ ^# N: {( c. b7 O" y1 E {# H h" f0 h; H; k2 e m
Run, cmd /K cd /D “%full_path%”* I3 k# l2 U0 I) `( B8 Z& c
}
4 T9 m/ x0 e F1 G3 W else: T z4 J6 V* X/ }6 @" T E5 m+ n
{
4 u+ ?# Q$ O8 {% v' u: ^7 I+ h Run, cmd /K cd /D “C:\ ”
3 ~# G& c) {4 A }
2 h% z" h; |$ m% I, f }
: w5 f H8 M4 l# q0 A5 r2 B. X& p 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 @6 a; g* W: r9 w+ o* N/ B
这段小代码肯能有两个你需要修改的地方& q- D( I6 w) n: R' B3 T5 z
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. k8 h/ M: M- M% I8 I, H 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “& \/ T3 Z2 _8 o8 j( Q
|