此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
" n; p6 ~$ _8 n/ O# p 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。# H& \# T, E" C) L
方式一:
" X0 b( @' M9 A4 `% k 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
8 F/ Q# h7 `+ W( H 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# C- [5 P0 ^) Y0 Q$ s
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
q0 Y5 v1 o( _ 方式二:
: W& Z g/ t+ c' t% ^" T 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. B% T/ y5 r: d" b9 \8 |
SetTitleMatchMode RegEx, J9 y1 v- a8 P5 X
return
" S- Y* H' [, H7 V ; Stuff to do when Windows Explorer is open
* I. @; z/ n7 a0 F ;
* T7 E% ~& T d- L( D A) G( d4 i4 o; x #IfWinActive ahk_class ExploreWClass|CabinetWClass$ N8 D$ j8 r1 ^8 i) E
; open ‘cmd’ in the current directory0 x$ {' ?$ K1 I! Y
;
3 I- t" J3 i% ~% l0 C# h #c:: e3 d% c" f4 D6 y; I
OpenCmdInCurrent()% |; ~$ k2 ?; S; I. o
return$ N0 X: V4 C( w7 n" t" }6 D3 C
#IfWinActive
. f1 E" S- U O! @# \: w: @ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer." p8 s! s" \ s9 A
; Note: expecting to be run when the active window is Explorer.
5 h# E5 l$ W' G# y ;4 q. e; f- `5 |: z$ ~3 d
OpenCmdInCurrent()' D. G1 Z; \3 p$ p
{( d. n6 {. ]+ b. }
; This is required to get the full path of the file from the address bar9 e/ D$ C' ^2 D
WinGetText, full_path, A5 A9 ^0 t5 b/ @- R
; Split on newline (`n). u, b5 |. u& p7 c
StringSplit, word_array, full_path, `n
+ P% B" d1 }) |9 W4 L- R: B ; Take the first element from the array d2 n$ J5 o% b3 M+ Q& `
full_path = %word_array1%- x; ]# I7 p& W3 D
; strip to bare address8 J1 X. L% W# H
full_path := RegExReplace(full_path, “地址: “, “”)+ m3 z# C4 V2 [8 i
; Just in case – remove all carriage returns (`r)+ _5 r' w' I0 |: T S
StringReplace, full_path, full_path, `r, , all
, I* O# w" X& U+ H8 F IfInString full_path, \
6 }- I+ c) @4 C1 y* P {
5 y" |2 Q. i/ C4 @ Run, cmd /K cd /D “%full_path%”6 k j: E+ o% O( s3 {( h
}
4 C7 O1 i0 }% O: r2 \+ \ else
6 o1 D& `8 `6 Q% t+ b/ _0 e1 S {3 e( F: J" w# ?5 v# V5 d3 t( q- x
Run, cmd /K cd /D “C:\ ”
) V. B% k% S" P% L }; q7 J) q+ _* ~
}
' Z8 n8 c6 s5 Y6 ^ r 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& J( ^1 o: t# y8 Y3 h# {
这段小代码肯能有两个你需要修改的地方* `1 w4 t" M: F/ @# p2 S6 F, V! \
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% |( I: f3 D& C- ?7 K, d0 {
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “8 |& N5 n# C) q l! ~0 ~
|