此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
4 I1 S; y9 i A$ @) B) Z+ {$ ^ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。; m! |: T, K8 i# W9 ]: f4 x9 Z' n
方式一:
6 N; U0 p, K2 I7 c 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,; ?. G2 c+ d1 Z/ d
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 U" s# e' b( G4 C HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
- H( B1 @' L5 w/ M+ Z 方式二:5 W. T0 t. ^; V* U9 E# }0 B
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( T8 [$ {8 [3 {9 k7 J* o
SetTitleMatchMode RegEx$ j, W& E( v) N% T8 C0 ?" K! U
return: L! j9 U7 e* `
; Stuff to do when Windows Explorer is open
: x5 Y* ?( V0 n1 X# e ;/ a t5 r4 f+ f- t& u7 R' Q
#IfWinActive ahk_class ExploreWClass|CabinetWClass
( c; E2 d' i5 g i ; open ‘cmd’ in the current directory
5 {9 N- u. A0 m# p! g& Y) T ;% O: ]" f1 X! O. p8 \
#c::
2 {( i; L6 r7 Z- T OpenCmdInCurrent()
4 Z, K3 L- f6 h. B T return8 D) x+ f, E, I" R% ^8 y
#IfWinActive
6 P0 O) J1 B- { ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.4 c& [: Y7 ~2 U# u
; Note: expecting to be run when the active window is Explorer.3 O4 G: S% Q% r0 {
;
! c* y0 S; y7 e OpenCmdInCurrent()
4 h9 Y* ?3 Q3 ]) v- ` {- d) Y3 }4 k# U1 y" j
; This is required to get the full path of the file from the address bar9 U$ b. |1 j/ T; `% y
WinGetText, full_path, A
7 C: ~* Y7 x) l! S( I ; Split on newline (`n)
7 Z: j. y) E- Q0 h9 f StringSplit, word_array, full_path, `n
+ g g- R1 Q) j8 ~9 w0 i# M ; Take the first element from the array
% t: {; Y- z6 H9 m- S, ` full_path = %word_array1%
; r) o3 N7 c& ^+ N. i ; strip to bare address
( m% C, ?! t; t' w/ U! F( } full_path := RegExReplace(full_path, “地址: “, “”)3 Z3 k$ E9 x& }7 |- w0 K
; Just in case – remove all carriage returns (`r)/ T6 [5 ]1 v: P0 Q- H% H6 c5 P% v
StringReplace, full_path, full_path, `r, , all& w/ l1 O' ]5 u6 a2 `
IfInString full_path, \
3 _( A9 s1 e8 v6 o6 S {8 b v; m) B, Y- O5 o# r d
Run, cmd /K cd /D “%full_path%”
7 i" ~ `8 [1 C# N( } }1 T4 [$ ~% z1 s9 U7 U8 m0 Z
else4 N. s7 N" k6 K/ _
{3 H6 v% h" ^; M( i4 g
Run, cmd /K cd /D “C:\ ”/ u5 C' _" f: l4 Z; \
}4 s1 Q( j5 e6 I( J9 l2 @
}, ^$ m: f+ s4 R4 ~' Q, M
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
' ^- \9 j, u, Z! s; m$ _1 F 这段小代码肯能有两个你需要修改的地方& `+ ?, z* o y$ _% I$ t- p# F& y3 m) r
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 X6 t! z8 M3 S% l# L8 } 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. z% O' v: K3 C# a& ?
|