此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% J* C; E# z4 S 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
# l/ t4 \' G6 @6 V5 e3 X1 p 方式一:5 m3 `' c& s1 f' v
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ G8 W4 H, ^$ D9 k3 O: h6 U' K( y: J/ O4 f
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ h8 a H/ g5 s# o$ Q X
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ b3 ?$ a8 H6 |4 G! V- U# n3 P
方式二:
. {% b+ d6 \2 g. X 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:# F% v% c6 G( x1 {' }# i. c! n ~
SetTitleMatchMode RegEx9 `" D ?0 y2 R6 j* A+ M% ~
return
) n! P5 \/ }0 {4 Z6 i. j ; Stuff to do when Windows Explorer is open5 A2 P2 z" z9 O- W4 V* B: z6 a
;1 m y, _# o4 i( A1 C
#IfWinActive ahk_class ExploreWClass|CabinetWClass
- V: c, g, e( v4 q% g9 u1 i ; open ‘cmd’ in the current directory Z% t& F4 T4 p Z/ w3 M
;
% F; c# d5 P- B1 k3 M# |, w; j #c::0 p3 e) J8 }1 z, f( j$ \( ]/ A; k
OpenCmdInCurrent()5 ?% T) Q" p% k+ o
return" t' ` H9 j& ` w, n- ]- z' m
#IfWinActive! ~* B1 s( W$ T
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# S* y6 p- c- o% x2 }. c; C* o$ @
; Note: expecting to be run when the active window is Explorer.
* `; f9 Y, R0 o ;, Q# z7 @3 i. d& r
OpenCmdInCurrent()$ q4 Y8 ~6 n5 Y9 c* t* e3 u
{6 c( q% [# v% u. I9 c
; This is required to get the full path of the file from the address bar
8 _, G2 z2 R6 ^& z+ h ]: Y WinGetText, full_path, A
; B9 @% V$ g( i0 f8 \* R; @ ; Split on newline (`n), P r: i5 B" Q" H+ Z; D
StringSplit, word_array, full_path, `n6 f% N- H7 z' c& j/ D
; Take the first element from the array
# g6 g+ ]5 W; _: V2 i! i+ Z) J; h# N full_path = %word_array1%/ O) Y% t" M) j9 a9 ]
; strip to bare address
# R6 s( t+ M1 y$ t5 e0 r) z% k# |8 H full_path := RegExReplace(full_path, “地址: “, “”)
( o& i2 m+ | H D ; Just in case – remove all carriage returns (`r)) p; Y4 _5 p8 y6 \) m
StringReplace, full_path, full_path, `r, , all8 y1 u. e3 a7 K7 y+ D4 `2 s
IfInString full_path, \, x& \: f5 j5 Z# E9 r
{
9 o2 j2 O; u( P' @: ^" K0 C. W Run, cmd /K cd /D “%full_path%”
, [" l2 t: Z |- E2 D# a }
6 y- k# e2 Z j h5 q7 h else* S" q/ \' g+ b. b9 t$ M+ R
{
; Q" @+ n3 W6 u/ w7 {9 k. M, s Run, cmd /K cd /D “C:\ ”, o( y( I- B6 ?- G: t
}! N* b. c* |8 ~/ X& w
}
0 @: @3 z; g8 ~4 H% w1 \7 p. L 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# n& R. t; W3 n4 J* ~ 这段小代码肯能有两个你需要修改的地方
/ R/ e% U) K5 O4 O' X 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) W7 m9 x5 {( @* L4 L, m 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 ?5 I, k0 p F2 c4 `; Z) I, ?! K) |
|