此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; x) }7 P7 b2 J/ o4 T 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
' b, [4 C$ D2 i5 K, r 方式一:
4 S+ B) Y+ K! S- v1 x$ d2 N 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ w7 G& q9 A; s m 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( t" U0 |' V2 |) S7 |4 A HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。; M# K6 @4 W2 J; x m2 ^# l
方式二:
2 ]$ k: \/ A0 ]+ E$ g5 \- A8 i 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
0 n5 H4 H# h/ X3 Y* W! a- s SetTitleMatchMode RegEx
+ Q9 _% v4 p5 _. Y% M$ ^ return
8 l2 F0 _ X4 F6 g! I# c ; Stuff to do when Windows Explorer is open9 g9 R C4 w+ I8 z1 M+ J2 h
;' [* R3 |0 [% r6 |6 g. B
#IfWinActive ahk_class ExploreWClass|CabinetWClass* Y" _" |1 h) u1 l! N. p; B1 z
; open ‘cmd’ in the current directory1 y- m" b& \) t9 q! ?+ M$ s
;
; ~6 c" ]8 Z' U+ {6 ^. G* z! l #c::
" @0 j, a/ n4 `& _4 d OpenCmdInCurrent()
* }) K4 G3 S$ x. F return
% t7 |' v: E% b #IfWinActive8 W; L$ H# }$ c1 ?0 O8 y
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 m/ V" W2 Y6 V% k3 [$ Z- \
; Note: expecting to be run when the active window is Explorer.
* K9 J9 o3 V7 ^' i% y ;
& [! q; S6 ~1 t* x: S. [, Z' T- y( i OpenCmdInCurrent()
5 k5 f( {: H% G; |% L# u( j {
* X2 A! M+ H5 I( Q ; This is required to get the full path of the file from the address bar
# L# S1 L) U+ L; J, G$ `" b WinGetText, full_path, A
Y& x0 p l9 E- Y" E ; Split on newline (`n): ~# i ^4 H; Z3 \4 h
StringSplit, word_array, full_path, `n
' R+ f) i1 S( b9 |) K) T6 K y) ? ; Take the first element from the array% X7 Z# @8 j+ ]
full_path = %word_array1%1 U4 J% k& B; e
; strip to bare address0 P d/ W3 ~2 B7 ^( E9 _5 Q
full_path := RegExReplace(full_path, “地址: “, “”)
' y6 q, p6 x, }& C: B ; Just in case – remove all carriage returns (`r)
1 p/ H0 X& t9 B7 B StringReplace, full_path, full_path, `r, , all# ]0 @; m+ Z b: t7 r5 R+ q
IfInString full_path, \# { B6 n9 A9 W/ H$ r7 Y5 c
{
+ F2 M# O6 A6 X6 N+ a# `2 S6 H Run, cmd /K cd /D “%full_path%”
; N. C% l' Q* ^& J7 B3 h6 R5 ]$ ]- w; k }5 B* p. Y( E; K2 R
else
4 L! u' p7 p c( r$ {# d {3 X' `# k- B0 ^! x* e; R( q/ l
Run, cmd /K cd /D “C:\ ”
: }7 w; j4 s; v, x) d }
2 ~% @) V3 Z% m% ^ o# G8 d }
P+ x* g D( f( f! D 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& s) c* P" @+ i
这段小代码肯能有两个你需要修改的地方
a$ Z2 o3 t1 F6 n 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' \" j6 q. l( e' W. Z. }
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- W4 `- H0 }; A
|