此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- s# c# T+ n1 `# E9 D" Q% v 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: U9 `! F6 a6 r" _( J
方式一:
4 R1 G4 w# H1 T6 D 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# ~: ]% Z6 }6 L S1 a! M6 G O4 W 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- `6 B- X! ~9 v HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。3 [( y, V- g( D1 B" I4 N8 h
方式二:2 l; I/ c/ ?: M& K+ d1 |" t' U/ e
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
: L2 g: {4 T4 S SetTitleMatchMode RegEx: k: z8 T2 ^* O8 d* M7 I& U1 a
return/ q7 T* [& r( r+ \5 O A! L! ~/ D7 [
; Stuff to do when Windows Explorer is open
3 `2 c6 j' g! A; n4 s4 S7 e- s ;8 Q. U" i7 `0 a; \2 P+ `* h( E6 v5 \
#IfWinActive ahk_class ExploreWClass|CabinetWClass. q, H' O1 `( u3 r4 V
; open ‘cmd’ in the current directory! Q4 U2 ]. c5 C/ e+ p6 c" m! C
;
# t0 f7 m8 ]+ g0 k. Z. M #c::1 }$ w0 k c& d# x0 `
OpenCmdInCurrent()
7 |' l6 }# y% S8 z( O return
; a$ m/ i+ k# r& _% T o #IfWinActive
9 `" Q5 C( h: d& \4 `& p# W- A ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 G' I- n1 U& E& Z+ F l- x ; Note: expecting to be run when the active window is Explorer.
# |, ~0 [. ?9 y( h9 |& A, }( { ;
- I5 }; k ~& H7 t$ k& G! ^ OpenCmdInCurrent()2 @& @+ W0 j# \1 j2 o) U9 @
{& F, b( k2 n. \" G1 `
; This is required to get the full path of the file from the address bar
: S2 x4 Z% Y! t9 B WinGetText, full_path, A
4 y* N1 F5 M0 N6 a/ C$ f ; Split on newline (`n)
, y7 L @" ?1 J" e8 q StringSplit, word_array, full_path, `n
9 [' L8 L6 S8 q1 r w- g ; Take the first element from the array' |. G% M2 x' K; o: @9 A' _% ~
full_path = %word_array1%. C& C2 g" W/ n. g' m; l# z
; strip to bare address( m" k9 h* L" r+ L
full_path := RegExReplace(full_path, “地址: “, “”)5 k' f% B1 T4 o( l
; Just in case – remove all carriage returns (`r)+ D, d* v: {$ |5 Y' Y8 ], S
StringReplace, full_path, full_path, `r, , all. V e2 k8 t/ _0 f O
IfInString full_path, \
* ?- q" x! h3 F' p; ` {
! S' L9 ]" `" k Run, cmd /K cd /D “%full_path%”( l1 u [% ^* k/ O
}
% t" }- @; T9 l" @ else, W& B- v0 d* M9 `* i* T4 S- I
{9 i) F5 ~) T/ d/ u- R3 b
Run, cmd /K cd /D “C:\ ”
( u! Y2 x! b5 X/ q }
) {5 E1 x# C7 _ N& b- g }4 b+ m" k/ X7 r' `# x- |6 j
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% s+ O2 F3 W, h; k- W5 W4 W
这段小代码肯能有两个你需要修改的地方' w0 M6 z" f; V& u5 q% J
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# B) e+ I/ E6 _
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “' N" A. G( W: \- l! ~/ F6 F
|