此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 e" i" f3 }9 u. } Y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, r1 \) a( f6 k0 K
方式一:7 I- y# o/ H# ~/ x$ U$ j7 Y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& t/ r% p* D4 l c 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 A$ e3 S( y- x1 ?8 u0 d HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 @6 }5 t$ A% @8 o, ~9 m
方式二:6 W2 ^: k8 U7 B- _" W1 N
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, Q0 u( |$ P7 E0 w: r# k
SetTitleMatchMode RegEx$ B. s, [& E2 a/ g
return
9 X# w. Z9 p& u( Y& L ; Stuff to do when Windows Explorer is open
! Q& K4 M2 a7 _ ;- N3 d b/ X- w- s8 h2 p; d
#IfWinActive ahk_class ExploreWClass|CabinetWClass
0 Z3 I) u( k5 B: [; g$ ?7 [& f ; open ‘cmd’ in the current directory
2 I; D) e' a1 D7 F8 Z; ?! ^0 s" E9 r ;
" \! x! |. }" x E& [! w! d #c::
4 T6 ~% @6 V# M OpenCmdInCurrent()
2 w+ M1 I, M+ z: b, p# N& w return
/ ~( p7 L S) ~1 ^4 Q #IfWinActive
/ e: u' G+ o9 ~ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% m( W& x* y" P ; Note: expecting to be run when the active window is Explorer. ~8 m0 z# t9 l
;; Q( g7 ]7 i3 W/ r) E) V
OpenCmdInCurrent()9 n9 f- @: D7 S8 i) D
{. Y- C: k y2 v( q) X
; This is required to get the full path of the file from the address bar3 }$ ~6 y$ E* I0 G7 K/ Q
WinGetText, full_path, A
+ R1 G% q, v( J8 U ; Split on newline (`n)
$ V. u, J9 P* J0 c4 N# R StringSplit, word_array, full_path, `n
" U; \) e% N1 |) `& d0 @7 c& d( ~ ; Take the first element from the array0 I: V& ]3 [! c: I' h( r# ?
full_path = %word_array1%( C/ O% t6 W+ H+ M3 B
; strip to bare address. V/ c4 [% W5 e$ O
full_path := RegExReplace(full_path, “地址: “, “”) V( {! u# G, v# S4 W
; Just in case – remove all carriage returns (`r). {1 J# V& v" f; `( z4 Q, S
StringReplace, full_path, full_path, `r, , all* X6 A! [8 C {. S# `' V6 y0 @9 ]1 \
IfInString full_path, \2 ^, [. @' }- H$ ]3 w* J) L
{
- I2 {6 C) Y/ b3 C7 q' B. X/ l Run, cmd /K cd /D “%full_path%”
) u; Q' b- Q# X( r$ T7 n( L }5 S( H, H A( ?0 E% b
else
& v# n# ?) B: Z+ [& a0 u% Z$ {$ E& @ {
# v/ c8 ?1 |8 a4 w$ X, n F Run, cmd /K cd /D “C:\ ”
% n3 u3 ?& W) W! d' h* e2 I0 b0 r }' K0 L4 M( H* Z1 ~" p7 N5 ]
}
& Z3 s" c, _- _* x0 [ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 M8 X! {+ w6 t, u
这段小代码肯能有两个你需要修改的地方' U+ z, ]! m- e9 S, U) ~% t1 S
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" w. l. {- T) B2 g8 l3 L+ _8 z 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “" V, Y, Q/ M2 G. h
|