此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; m8 V1 G0 Z, A( b6 A7 X
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& j' P/ d4 u. M+ c 方式一:
9 T" B8 p$ G1 M/ P/ ~ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* W5 c8 L. y I( }
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和4 n8 f1 W3 f" x4 O; c
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。# S* X& d# E4 O9 f M# [8 E
方式二:# A% Q1 J/ O8 P! h" |& s
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* r) {9 h- C$ k) z! b1 d SetTitleMatchMode RegEx) R+ {8 L, D% ?( {4 |) V4 h
return/ m+ m5 r5 I5 j: C
; Stuff to do when Windows Explorer is open
. Z5 O* C: O( v* K& O9 ^ ;
% {# O6 W" X6 n( W3 ^) D- J #IfWinActive ahk_class ExploreWClass|CabinetWClass
, ~ j S9 J6 v/ Q0 ` ; open ‘cmd’ in the current directory3 r1 P# b* B6 s! E) ~5 l. n
;
9 w* Z6 y9 |& x1 x3 P, a #c::
" [; E" m$ r( ^( P9 k( d OpenCmdInCurrent()
. w6 s ~2 q3 a+ [# j+ A return
& q" U' P6 `8 F4 p( ~ #IfWinActive1 r3 j7 {6 j* c& X" x8 ^% ~% ~
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
$ }+ c, ^8 `- z% |( J. S6 ] ; Note: expecting to be run when the active window is Explorer., t0 t$ x7 \0 u
;
, ]8 ~, X2 ^9 O+ \ OpenCmdInCurrent()* {8 E( g8 G$ j1 S, ~
{
' T( H6 ?; f6 A6 B9 L ; This is required to get the full path of the file from the address bar' w, B7 i' [. r2 g% \
WinGetText, full_path, A
. o2 p" S0 i9 K ; Split on newline (`n)6 d/ ?* l6 e/ s+ P
StringSplit, word_array, full_path, `n
# [# a! l' X: o! H, K4 I ; Take the first element from the array
1 Z( r# @% o$ [ ?/ k full_path = %word_array1%6 U3 {' |4 n3 s$ O
; strip to bare address
0 H f, Q0 v# p' ^- E! d full_path := RegExReplace(full_path, “地址: “, “”)/ U+ Y; V; ]) \( ~
; Just in case – remove all carriage returns (`r)
; v2 c" L7 T. U* U( g- `" H StringReplace, full_path, full_path, `r, , all: {7 e5 U7 V: y
IfInString full_path, \
: Z* L; Q7 s, u7 }; f {- Y/ O2 r: b' K
Run, cmd /K cd /D “%full_path%”
4 x: M# t& u2 h# ^$ T& `0 E4 D }8 O2 |" G0 ~0 v* v0 A1 \2 s5 n. H
else0 ?$ x9 V3 s. M5 A, `
{' J! z1 b2 a8 G( J( d
Run, cmd /K cd /D “C:\ ”' a; { ]4 F. v; d/ c2 h
}- {5 n# t& b' i: c
}. [' r% ~( d0 M9 T, ^2 m
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: @5 N/ ~" v/ P5 `4 F' w 这段小代码肯能有两个你需要修改的地方
* s* [1 m& g- D2 x8 q 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ m" \) H Z4 O' C
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 w9 r: X; p, ~$ F" ]* `4 A
|