此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ z- y! b% J2 x* f' t4 _1 W
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 p+ q P8 p' k( D! V. m
方式一:- Z. ^2 d. y7 M
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% z. K2 l7 p3 ^3 x+ H) u 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和 S3 v# f0 z5 L" c* `7 W
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。' K8 @0 e+ s% r- ]
方式二:
! e/ ]/ X, e" Y' s 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 r# [; k1 m9 [; d5 _8 ~
SetTitleMatchMode RegEx B) R+ `. J5 V4 Q/ h0 _& G3 C
return
o, B/ H; X' ]3 Q! c7 R; e1 t ; Stuff to do when Windows Explorer is open4 J; c# x2 H6 f- _3 a7 u
;
j' I/ o W; q# T( [2 K4 }4 T #IfWinActive ahk_class ExploreWClass|CabinetWClass3 s$ H8 r2 D" e
; open ‘cmd’ in the current directory9 S0 G! c0 I- F9 H
;
) J( L0 N0 E" B' B #c::% G4 k$ Y4 I9 Y3 }4 t
OpenCmdInCurrent()- B9 W v: S+ o4 J" i/ I) V8 I
return7 [# Q9 P, q4 k3 g/ v0 Z
#IfWinActive9 l1 g% l: O) E, N
; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ s! l M8 O) b
; Note: expecting to be run when the active window is Explorer.* d5 Z4 s2 \ k
;, X. u# O" E. t
OpenCmdInCurrent()8 p+ D/ M/ K! \* Y6 ~' N5 H4 q
{
6 |: |/ I4 j5 d ]* j( y: V% L ; This is required to get the full path of the file from the address bar# y$ f/ N O9 w; Z) X8 L6 p
WinGetText, full_path, A
7 b/ W' A f* e4 I; } ; Split on newline (`n)
4 x; ^9 `) w% [( M: \; Y4 @ StringSplit, word_array, full_path, `n0 a7 H% I9 ]7 w
; Take the first element from the array: c' [1 l! e5 F {- c; C0 O5 P" S
full_path = %word_array1%; U8 K+ e3 I' u) {7 x! L' p
; strip to bare address$ J! T' e' h9 \) c
full_path := RegExReplace(full_path, “地址: “, “”)
3 m" n: F% {* a. h" ]6 R ; Just in case – remove all carriage returns (`r)
% n6 U' ]! s4 {4 M" V% G StringReplace, full_path, full_path, `r, , all
2 y! }6 l$ v2 F, ]; K. `( N* R3 \ IfInString full_path, \: ^0 l2 }* a4 k) f Z
{ Z% `+ A# X( Q7 [
Run, cmd /K cd /D “%full_path%”
1 Y, _; |( h; z8 p: z H3 R }
5 t! U; f! R: R" G. y7 a else
0 Y* ]# M6 s0 F0 J {
" I9 w0 V6 [& o* @, k Run, cmd /K cd /D “C:\ ”
k- W$ _& M5 u8 n! ^2 e* g }
5 W; S( M! {8 E, d: u- g }9 s& u2 f/ Z& z& [
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( f0 B. m% A, J; @; M
这段小代码肯能有两个你需要修改的地方
/ {1 F/ w8 s- w' J 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# Z9 q1 [8 x4 c9 s7 k 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “6 l; r0 ~: L! Q
|