此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 A0 R8 m; F8 o0 d- A. R 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
! ^" S% X& m5 a8 O 方式一:( l2 e! M: W$ l% r: |# P% W9 g
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
' f" {# @% I# n/ b9 U: d 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ ~3 d/ R) p/ Q
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。7 f: N2 C3 d0 g; T- k' }/ v- I
方式二:0 @; N0 ~+ Y: _) T/ z/ u
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* M" j8 k6 H( o ? S' P6 Z SetTitleMatchMode RegEx$ D5 _7 ]- i1 S! ^$ d1 q6 ?
return
$ l4 S5 h4 b0 Y; v2 {) ` ; Stuff to do when Windows Explorer is open
3 ]! q& ?) ~- D5 @ ;
1 |8 o) m6 z6 e4 H6 s) e7 k- P #IfWinActive ahk_class ExploreWClass|CabinetWClass
* v1 w; f5 X& w7 ]4 n. h ; open ‘cmd’ in the current directory
" H, F; b4 w4 _& v* {7 P ;( d, ]/ f3 J8 K7 @0 a. G
#c::8 o% b2 H, T' K7 M
OpenCmdInCurrent()
/ _0 ~7 Z0 j: ~% d return1 M+ _4 c, L; r9 {. [
#IfWinActive
' Y9 f( }5 v5 C* k& V ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) D1 y& ]& p3 Z+ @ ; Note: expecting to be run when the active window is Explorer.
- w8 D. Q. `4 B' q' [7 P" y! h' P ;8 ?9 Z9 _# ~1 f- t1 x" @& _
OpenCmdInCurrent()
! }3 x, U1 ^; e* V8 p/ a9 I1 a {, o7 ?3 _% d# F$ n
; This is required to get the full path of the file from the address bar
p& J7 l! w+ ~5 D WinGetText, full_path, A3 W: Z: _$ `% L# z0 f- J. e
; Split on newline (`n)
3 ?4 n! s; ?5 E1 h( a' D, C StringSplit, word_array, full_path, `n, U \9 a8 r/ O; I# ?$ K+ ]
; Take the first element from the array9 Y* |7 R( N* @" r: U6 R: R
full_path = %word_array1%1 u5 J' b1 C5 L) F
; strip to bare address0 h( E' Y$ M% z: Y+ c2 Z$ D/ t" Q
full_path := RegExReplace(full_path, “地址: “, “”)
0 F/ u. m: M$ i S, ?, k1 q" s A3 W ; Just in case – remove all carriage returns (`r)5 s7 B" Q" N( N N/ `
StringReplace, full_path, full_path, `r, , all: C# A! B- |/ y" }4 e! G6 F$ S6 u
IfInString full_path, \) s7 j1 b2 H, ^( A% P2 d' E
{. z0 g9 w" f, B3 S9 ^: f% l
Run, cmd /K cd /D “%full_path%”
4 Z4 c* e/ z, g( [! A1 p }. B; J2 B8 }0 n& ~8 R2 i
else
' R2 i9 r0 u# q, ^! x {1 S3 C# ~% D# X3 [, Y
Run, cmd /K cd /D “C:\ ”; W8 _' k% T. v7 C
}
3 T; [0 T% @1 F }0 v, s4 H; c( Z* T
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: ~( A R; k) X1 f! J0 I3 i6 H 这段小代码肯能有两个你需要修改的地方
" Q- C; R0 K. k) Q 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ J6 J6 N! ^4 w+ Y; z* A 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) M. v T4 G: z: T |