此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# E+ u3 ]7 t! u# X$ @
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 k2 u( N5 [% h. t' P& F
方式一:
8 K2 O0 y7 ] G# N 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 ]3 g% l6 I" Q1 l
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 V5 D9 ^6 |/ `- j5 x1 \- ^
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 o4 t5 x1 Q# c( v4 h* i
方式二:
" ~- r, @: p' i' X7 U 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- j5 G4 i: k" C) \ SetTitleMatchMode RegEx
2 C( I* y6 C# d return
0 K/ ~0 L% n* z5 w/ F5 b$ f' A8 J! m ; Stuff to do when Windows Explorer is open
. I' Y4 ~, d4 m3 o. z/ u ;
6 Y. |6 p( S5 k4 g C+ s) c# i* u #IfWinActive ahk_class ExploreWClass|CabinetWClass
% q! t2 q7 l" Q q; B. U- N$ W ; open ‘cmd’ in the current directory' J( P; S: F+ h3 N
;
2 n+ N: ] k0 n4 t. r8 l' q& j9 u #c::
$ t3 Q/ u3 I) f) i3 [ OpenCmdInCurrent()7 _- {9 [2 q# n% C% u
return+ }+ a6 f/ D5 X" N- u+ Z
#IfWinActive; h$ L i. r) @5 k
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) o) C& ~% r$ P ~3 I
; Note: expecting to be run when the active window is Explorer.
1 d. ~1 o. g3 {% K7 G ;
/ z Q* O) J/ m7 r2 v" g OpenCmdInCurrent()
' E, Y/ i% I+ E% M& ? {
7 \) H: r I: }3 s" D0 _& s ; This is required to get the full path of the file from the address bar# k4 I9 e* P* z! E1 M: m
WinGetText, full_path, A
, `* C. a! K4 @ ; Split on newline (`n)& V& S, b" o: Y/ X5 ^! n% n
StringSplit, word_array, full_path, `n1 E7 |5 Y. c$ b: }6 V: t% H
; Take the first element from the array* P9 l2 V# e2 w% ?
full_path = %word_array1%5 M' a# T" o3 {4 k) i; e
; strip to bare address
1 _; ?* K2 f+ |! H full_path := RegExReplace(full_path, “地址: “, “”)
/ x7 B4 N9 i9 `$ y5 z ; Just in case – remove all carriage returns (`r)
; y4 z2 \. h9 B' g5 A, E, r StringReplace, full_path, full_path, `r, , all
' s, Q* \5 x( v9 u& T' ]/ o IfInString full_path, \, H7 b' _# o. E& G3 _% K
{
# V( x p) M* m3 p3 A, @ Run, cmd /K cd /D “%full_path%”
1 v# S& ]! c* Z& g0 y }0 O8 W+ m) O: f# S* L
else. X0 j" P7 T! l" y' n
{
0 n; H9 _: M5 @ {' d+ s$ t Run, cmd /K cd /D “C:\ ”
# A& E7 l; Q2 Q5 J5 C, p) o } a" \( A: H* ~
}
! Y) D5 |! E& x9 i" y" | 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
9 X: Y7 u7 a8 c+ p! D4 Q 这段小代码肯能有两个你需要修改的地方, k& x X( Q* b/ @4 z% d
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 A4 |7 L7 G) v2 _9 L6 m$ l 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. [, Z" v! h) r0 ^7 F o |