此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
/ ]# y' S* J5 \2 J. v! _ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- J' x4 v! Q( c' C* ]* i 方式一:
( k$ l/ O! y$ n2 ]( Z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
9 w: {; W0 M0 G3 d, a9 ^! m 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 c/ ^) g+ m% J; d( I) S6 r
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。: J- |6 b+ e( u0 k# J
方式二:
# j1 V1 P% z2 T e 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:8 z$ ]( i p$ C K$ n- Q+ a( l3 F
SetTitleMatchMode RegEx
& O( {' Y' T9 V3 k- C) G" x" H0 x return
" I) {9 H+ j1 i. ~$ b3 h ; Stuff to do when Windows Explorer is open
% }! c8 L! @ [% b: O ;
% m8 f; x; S3 R7 N/ h #IfWinActive ahk_class ExploreWClass|CabinetWClass" S7 a4 @$ G0 W; Z, ]- L
; open ‘cmd’ in the current directory
5 B4 E9 Z! F+ Y ;
- P/ w |0 k/ T; b: @' ~ #c::( n- r8 x' P7 M7 Y# @9 h6 [; y
OpenCmdInCurrent()
* v, L( c/ `9 M% f) O return s+ @; R, C P9 m! X: U9 i
#IfWinActive4 e# Y, I; O' u! f9 A8 F
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 e# w1 q1 O. w6 l7 h ; Note: expecting to be run when the active window is Explorer.% V% h% p% d( I ]- L5 b& _! B) P5 P
;
- y# k6 e+ J2 ~! u9 a; @3 x OpenCmdInCurrent()
' U5 `: p5 {& S( f/ N5 Z {
" M6 T5 g# z5 d ; This is required to get the full path of the file from the address bar
' v# d+ B+ G& V; L WinGetText, full_path, A) F+ V% F. V! |# y/ `9 W p
; Split on newline (`n)+ j2 a9 }. i3 @; C! A
StringSplit, word_array, full_path, `n' q( }, z) j8 z; d
; Take the first element from the array
/ Z5 h3 `9 n# s2 K$ \, C K full_path = %word_array1%
; j/ G% G! K% {5 b; A9 ` ; strip to bare address1 p2 |2 {- P- k- ]0 J
full_path := RegExReplace(full_path, “地址: “, “”)
2 r r4 Y5 X4 d0 S0 b1 T ; Just in case – remove all carriage returns (`r)2 c* `" N9 F) E/ d3 a% v
StringReplace, full_path, full_path, `r, , all
0 F1 g5 e, L8 r2 ~) ~% { IfInString full_path, \
! t% q/ L* W$ w {
7 ?* s' c6 B/ |# A Run, cmd /K cd /D “%full_path%”7 }4 e/ z* O+ E/ u, c$ y8 c
}
O" o: N/ u1 P _. W else4 ^6 k1 p% s, u/ s E
{$ O; }/ w" K4 J# i4 c0 m
Run, cmd /K cd /D “C:\ ”% l; K* E8 C. N8 Q0 A
}; F9 i* q4 n7 P
}
7 l* N, r! N" ]) u/ v3 H 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: T `# G0 g+ L, }3 @" n* g 这段小代码肯能有两个你需要修改的地方% d) a+ Q7 q1 X' [& F$ D% Y
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 R0 y) {& F8 R& z 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- M: g. F5 v* Y. G; W
|