此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 G g4 w1 v4 A6 I2 J 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
7 Y' }7 p/ ^+ K% g- C% S 方式一:2 t2 H+ k1 X$ m
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% ^9 w* D2 Z' {( c9 U5 ~ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. `+ M# F- ]" M3 p! t HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( \# R2 p! j4 u: Q) x
方式二:9 e; j; c1 Q# R# o. o9 x
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
1 s2 B# ?4 P/ w SetTitleMatchMode RegEx/ @% n! W/ a4 D- B I7 K/ d
return
! D& v Q# {( m \5 o8 h ; Stuff to do when Windows Explorer is open" J1 h' L* M+ X9 r3 C/ P
;
0 f. `: r: ~' T' A #IfWinActive ahk_class ExploreWClass|CabinetWClass
/ W* C' n" o3 O2 C& I ; open ‘cmd’ in the current directory4 A; _# G# D' \. z8 I9 O
;
% h, L8 u- E) R. S' i #c::
, U k% s) ~- _0 f2 T OpenCmdInCurrent(), f, q3 a, a1 X! P1 t8 |* ~2 y! u# {
return0 ?& Q4 h8 _1 i0 j
#IfWinActive
4 U$ R/ t" d* k ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.& C! S5 }7 F* s( |5 G2 p0 c. L
; Note: expecting to be run when the active window is Explorer.
) H" y- V7 C( n- J! H! h ;5 d( C, x' g" |. l
OpenCmdInCurrent()
7 _% v, n+ k+ O+ |) ~ { A# _7 u4 b7 N. [9 D3 o5 _+ @
; This is required to get the full path of the file from the address bar
% s- h/ Q0 f: @. z# S WinGetText, full_path, A3 d9 [" j& Q3 B1 b& d6 `- ~5 _
; Split on newline (`n)8 A9 V! Q+ }! G2 k$ d+ r
StringSplit, word_array, full_path, `n; x q( m% I [, o% q3 G6 j
; Take the first element from the array
1 W$ X& _- z8 i3 V full_path = %word_array1%
' m: o5 s' ?) y* Y8 H; ` ; strip to bare address% [, d' S/ C) _, n& M& M) U( c$ N
full_path := RegExReplace(full_path, “地址: “, “”)3 ~; x5 f$ D5 b* H/ Y) |# \& c6 F# p
; Just in case – remove all carriage returns (`r)
' d) v: l) Q- v% B StringReplace, full_path, full_path, `r, , all
( y7 B9 ?3 g2 i IfInString full_path, \
0 v }1 e! k9 X5 i" ?) ^3 O2 f {( V5 Z* }( c+ v3 Q" _* T
Run, cmd /K cd /D “%full_path%”
/ k, y( B! E* c5 Y }
2 u; Y3 _9 ?. b2 \5 V else' l' G! K7 S; ?- A' R
{
# m9 [% v( b6 G% U% x7 c5 n Run, cmd /K cd /D “C:\ ”
2 f% D# N; a. x* E+ B/ Q0 { }
6 u( J: Z$ r3 o) W }. l) a. q [5 p8 x! v/ B: ~7 ^
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 D4 B+ ^. c, o. ~ 这段小代码肯能有两个你需要修改的地方) Z6 I( Y3 y3 w3 {' q
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 b% b' z; f) m
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! y2 V; p& a( T b
|