此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) |3 ]% M! _' S3 Q9 D- r
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 a% @4 Y$ ?8 g. \
方式一:; X. j3 \2 D3 l6 c* m4 w' E+ c
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- F& m& Z4 ]4 L# S 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, ?8 i- \6 z% q# x6 E5 g. Y HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ q- ?8 e, K! l! @7 `4 t 方式二:
! k# ?. Y" T* I' c3 O7 e 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:+ A4 i2 X: M% [3 e
SetTitleMatchMode RegEx* d+ @& _/ Z- w% d# ^7 s' q p: L
return
, i0 C6 s) M: X5 Q7 A# O; H* p ; Stuff to do when Windows Explorer is open
$ X: c8 N& H# {1 b# a* ] ;# i. q9 C6 b" W, Z
#IfWinActive ahk_class ExploreWClass|CabinetWClass
8 i$ V x8 F( _( N ; open ‘cmd’ in the current directory
4 d: Q) ]0 h+ J& a { ;
8 x5 o+ e0 b7 @- J #c::3 R$ N) F: g! o( H% F5 Z4 [: Y
OpenCmdInCurrent(), T, H( Y" Y9 g
return( V8 \7 V% z' f; q; o3 F, {5 u' ^! d
#IfWinActive
+ _& `" U$ t. a2 `0 v ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* A# K' a+ Y4 G3 \/ i" U' U ; Note: expecting to be run when the active window is Explorer." H& C# j- x6 X; ?* b: E
;
9 U0 s6 l( x/ D/ ~ OpenCmdInCurrent()0 Q+ v2 J, t3 w3 }' W# m
{; x, k: Y% x, u0 y2 G2 r
; This is required to get the full path of the file from the address bar
9 }: i- B {7 S& p WinGetText, full_path, A
+ v+ p, _; E/ r0 R ; Split on newline (`n)
n1 K% i( m' d0 ?, a/ u& S0 s+ R# \ StringSplit, word_array, full_path, `n
$ z9 T* e9 T( g- i. L0 Z ; Take the first element from the array- T% O3 U/ i% O$ x1 Y
full_path = %word_array1%/ z+ v, P3 C3 }* b3 f
; strip to bare address/ m' Q! D3 x5 u/ g# y% y m
full_path := RegExReplace(full_path, “地址: “, “”)# u3 e7 f) i# j
; Just in case – remove all carriage returns (`r)
% m, K; Z$ V1 e, l1 o; {4 @ StringReplace, full_path, full_path, `r, , all
1 c' Y& Y$ u. S1 C. W" y; \! \: h0 z IfInString full_path, \
# F1 ]# p* I) l& f. f U' z2 d {/ |. C1 K- ]1 Z1 Y% Z8 i
Run, cmd /K cd /D “%full_path%”
8 f' m% I; C! {% @) `& ^/ M, r, G; O }* U* L1 z% U/ \5 N% j3 a
else
L7 ]7 F* Q. N7 j4 P {5 N! }5 K. e9 S) ]+ w6 z, k
Run, cmd /K cd /D “C:\ ”7 g$ c/ C0 H4 r; q8 F
}
# y. D8 F8 Z/ G* q2 R }! {& `/ _7 ^2 Y9 h% U
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: v8 I, Q4 d0 ?9 r$ g3 M O5 `$ ^* i
这段小代码肯能有两个你需要修改的地方
( T6 [/ ~ Q" u 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; W2 S8 c U H f 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
% b; M- h9 k5 w7 ~+ c# K |