此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 j# Z/ e2 T1 m! L 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
( M9 o& F% z7 g# H' Q 方式一:
$ T, T/ A; ?8 S% [7 l: N f- M 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( d- i5 e4 o3 x! _% L* Y+ Y7 l
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
% V+ j7 W ]7 m R HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
% D3 d4 d$ }* m. U: v 方式二:
" \% Q2 e5 b, H) V8 U 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ F% @9 K A* z. | V SetTitleMatchMode RegEx
* s: y2 m; R2 Q H* l9 P5 ]3 ~+ I return! R% S/ `* U# {9 g. a9 [: G. }
; Stuff to do when Windows Explorer is open
1 b8 z& g5 U5 P7 P( z! M; M: q ;
* Y2 h/ \8 m- {" ^3 O0 ^ #IfWinActive ahk_class ExploreWClass|CabinetWClass' K4 R( Y3 S }6 f
; open ‘cmd’ in the current directory
- r) K- b0 ?/ M* @# c( {2 @ ;
# y2 J3 d, }, i) ?' b& d$ l #c::
+ e0 ?2 x/ x# P# L; g9 [' f& c OpenCmdInCurrent()9 N7 f9 Q; }3 \" a. R
return+ J H M7 c9 ?" k9 e# w5 s% T+ C# s
#IfWinActive
- w, H6 D# ~. E* z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 Z9 S5 V' ~5 j0 s& z
; Note: expecting to be run when the active window is Explorer.
# Q% Z1 ^& L& O, o ;9 v: P% L, Z9 {1 }8 e0 A( U3 {6 o
OpenCmdInCurrent()( G) I) I2 h3 Z) j5 [
{
% ]/ d; s |5 }$ v7 R ; This is required to get the full path of the file from the address bar
9 V z' @+ _, l6 J5 C WinGetText, full_path, A
8 q1 x7 m' a2 d7 _6 d ; Split on newline (`n)
9 ?6 q Y+ u: O0 a, k$ V0 B StringSplit, word_array, full_path, `n: ~" n$ C1 a& O7 w7 Q0 g
; Take the first element from the array9 L7 q9 n0 p# ?. C
full_path = %word_array1%
/ {! v& y6 s- J( w3 ~+ {. {) q" w ; strip to bare address
7 @9 l5 Z4 J( [9 s" ]" m' h, \2 @ full_path := RegExReplace(full_path, “地址: “, “”)
6 \5 j+ A0 \' T2 t ; Just in case – remove all carriage returns (`r)
. V" X7 j* P- C6 ?- d) { StringReplace, full_path, full_path, `r, , all
) k0 }1 k3 _. w# y% h% Q IfInString full_path, \
; L0 c/ p% a6 Q0 Q7 k5 S. i {
. c# s$ {' h8 s: }! t Run, cmd /K cd /D “%full_path%”
) ~) W$ o) y5 X8 | }8 ^" B: L5 \! y9 d7 E" G; Q# A
else' _- p% C! Z* H, X+ ^- ]
{# V8 M7 I. a; ?/ ]& G
Run, cmd /K cd /D “C:\ ”; \5 _2 b* j R" f8 Z
}
% e5 _/ ?: T: X" ] }
- s2 v/ b4 w6 j2 j' }7 w2 c3 U 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 `. @, ~6 H, Y1 ?3 f9 s 这段小代码肯能有两个你需要修改的地方" Q" c3 b' i, i
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- q9 g$ S: m, O7 ?( J
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “ W: z \% v: c0 L% z. G
|