此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 `2 s- t" W9 d 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
! w1 h! V1 i% I l6 \ 方式一:
& C& ?- F- T" V/ o) e; f2 _ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 d# d3 t- Y, y4 }( F* D3 `$ ?+ ?
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和( a- i+ E0 l: I! n, r' f2 a) j
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" n; P% Q3 J: n3 U7 b3 U: G 方式二:
, I+ j/ X' Y2 @& v Y G2 K 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: [, s* D% m; s) |
SetTitleMatchMode RegEx1 y9 a0 j& W& u% Q8 }9 g
return
7 ^# S. k# q$ [; [) d" d Q& E0 m ; Stuff to do when Windows Explorer is open2 T1 @2 {+ P, i$ z: z& K
;
; `2 f* u6 r: ~ #IfWinActive ahk_class ExploreWClass|CabinetWClass; I {4 a5 d. H) ]0 m0 G" l0 m
; open ‘cmd’ in the current directory5 }. N/ q6 R- ?. I7 O& t
;6 y& o' q6 ]5 K" E& D4 A
#c::. ~& q1 R8 E3 q, J0 o
OpenCmdInCurrent()5 f, V" c3 ~8 {
return
: I. c- F2 O5 k7 B1 k4 V #IfWinActive
3 K& ]6 A+ s3 a9 ] ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 N; ^! u8 N# u4 \% G ; Note: expecting to be run when the active window is Explorer.& I, [) Z. o$ \* s
;
6 q i7 c* w; Q/ E: U! F OpenCmdInCurrent()
S/ g& T. y; w5 V6 }: O, f* ?. y$ S {
: x5 J8 w- @& P! k3 X/ B ; This is required to get the full path of the file from the address bar
( r8 X% l6 _. U7 f j5 |. A WinGetText, full_path, A2 ]4 G, A |4 |: F) I
; Split on newline (`n)7 ]" X7 \9 l4 q0 {
StringSplit, word_array, full_path, `n- r$ U1 ^3 }# g. G
; Take the first element from the array6 ~: a8 ^ A6 F! x1 W" `* b: l# [$ p
full_path = %word_array1%
3 z m: y- D1 b8 M8 N C ; strip to bare address
a1 R. v# Z" D) D- C4 |6 y% Z; Y full_path := RegExReplace(full_path, “地址: “, “”). |/ X* O( a8 G
; Just in case – remove all carriage returns (`r)
3 }8 \& J+ Q9 K& |) u) q StringReplace, full_path, full_path, `r, , all! | \) ~* x! o+ A% I
IfInString full_path, \
7 D4 ]7 B+ ?$ n3 B {
' n0 X7 [4 Q- ?+ q5 O& V* E Run, cmd /K cd /D “%full_path%”
. \3 G5 `# O" F4 E+ Z9 p9 O: P* L/ U }
1 o6 t0 t& b, y0 C4 S: \5 U else1 v# e3 B. f2 E5 {4 N( ^, g
{! |: Q5 m; N$ E: q0 o5 A Z
Run, cmd /K cd /D “C:\ ”! r0 K% j% @$ Z! X% [
}: q; Q/ i+ o; @( V9 c/ Q
}
% T3 b3 P7 r+ l3 U 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
e+ Z9 n; |" p 这段小代码肯能有两个你需要修改的地方9 c# I1 N! a b+ o
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
]8 L8 {5 C4 S+ Z0 u0 z, @ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ W- J0 Q' Z; h/ P g$ g: U: I3 s |