此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。3 i7 o# B7 ?! A/ s9 D! g
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
! L- _' k& v& I! ^0 D/ [( ^ 方式一:
* e+ ]5 l$ B+ a8 ?; e7 H! J7 c 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,! R! b7 w6 f2 c4 R* D2 J8 N
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# D- u( U. t; O6 z- F
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
# R! K7 x! ^. V8 w 方式二:
2 l: z4 g4 y g, a) ]" h 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
9 R" Y: ? J) ? SetTitleMatchMode RegEx, X% X2 u6 \0 e4 o8 ^. o
return
9 k0 v6 K4 G9 V& X ; Stuff to do when Windows Explorer is open. d% ?4 B' W% u" t4 m) {! ~7 d5 f2 c
;& t- Y* ~* f4 l T+ F- x
#IfWinActive ahk_class ExploreWClass|CabinetWClass
% L3 h0 k# V' M0 i6 X% Y% D- [& } ; open ‘cmd’ in the current directory
/ i$ F. y" W: \3 q8 h% q ;3 K2 x! ?& O. ^2 D- P' E
#c::3 @- G7 @# l3 k" p
OpenCmdInCurrent() D4 i9 d9 {5 W4 K0 l
return
9 a: z# f+ v% b! a4 z7 m #IfWinActive
" ^4 z1 ~& H( Q6 `9 a ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
" g1 N- G$ |+ m7 |0 P ; Note: expecting to be run when the active window is Explorer.5 Y; Z1 Q8 K# c$ i% H8 Z7 @+ O3 k
;7 q& X; |$ p1 e1 P3 ~1 _$ i
OpenCmdInCurrent()
- f2 @0 \4 s* [2 W {+ \. G5 O0 x L6 Z& Y& j
; This is required to get the full path of the file from the address bar( B; E b" a# u. {* M- L: x
WinGetText, full_path, A
0 D z+ p7 Q0 `3 {) I( s ; Split on newline (`n)& I# t) ?; y+ l- I
StringSplit, word_array, full_path, `n
- y1 f- j, H I; d" i5 U ; Take the first element from the array
; B: W0 g: k/ s full_path = %word_array1%
$ N( Z' l8 {! J% h6 C- @( r% A: J ; strip to bare address
8 j; _1 {" H+ J2 J full_path := RegExReplace(full_path, “地址: “, “”)
8 m! l, X8 Z" U8 [8 W- }1 g4 N, Y ; Just in case – remove all carriage returns (`r)" W2 Z/ \. t" s9 V
StringReplace, full_path, full_path, `r, , all
6 d4 ?7 {% T/ V% Y IfInString full_path, \
d: o3 [0 P7 r/ d& G/ [ {
T0 R: l+ ^! k! H) c& t& f$ q Run, cmd /K cd /D “%full_path%”
2 q9 b2 x. F' V2 }+ s }( v5 T) {2 l9 Z. ]4 d% z, M% D
else7 X* p E; P& e& i0 s3 [6 \: h
{
6 \7 V' e5 K: S% w Run, cmd /K cd /D “C:\ ”
+ z! `, J% Y1 p. y4 f$ l1 e: V }- b$ X. ]1 C0 h2 |% l
}
1 a. P7 _$ F/ W3 O. c& A1 Q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. A( O5 X2 K q5 F6 i% q- c* i 这段小代码肯能有两个你需要修改的地方
6 R# ~+ ?4 X/ N" q$ [. Y" E 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
! O1 {- j/ m; v- X1 t3 a6 ] 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “& I Y( v) \* L4 `# p0 I$ u& }
|