此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 I& J4 N8 _; P4 |6 J1 m 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 I; i% {- i) d0 s: X
方式一:4 s7 [! E1 F& K, c3 a# L% W( J' K. S) `
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( Q8 K2 R' W; w! h7 |1 K- ^ q 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, [# F! r5 \/ b" V" z! c" q HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
8 t; t M5 r; F+ t) j/ S 方式二:
2 u# `8 ?( Z* |+ _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
5 ]) z9 I5 V+ ]: P, g SetTitleMatchMode RegEx
3 ^: Y t( T( E9 n! x% ^- |! D( }- E return
8 H2 m e# s9 n5 o7 C6 { ; Stuff to do when Windows Explorer is open2 d4 d; ?! B; q
;
2 G/ k( O2 P' h2 t #IfWinActive ahk_class ExploreWClass|CabinetWClass
$ z5 o) r: N/ Q; | ; open ‘cmd’ in the current directory7 h D4 Y( W5 y9 O! o& |. z
;2 i" q$ g2 a( A# @. S$ W K
#c::
; Q' J G: u1 f% j* L6 m& v7 ]8 [ OpenCmdInCurrent()
+ K7 H7 D2 F$ C8 j. n4 y return
) L. o7 g+ C; M6 V# f3 j! u0 _ #IfWinActive
; a* [, y' ?, T0 i$ n2 i ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 @0 c$ I" g8 \+ U8 C( ^& w {( s
; Note: expecting to be run when the active window is Explorer.
! s: d- w/ @8 {* v' c T ;3 S6 B6 I$ [- ?0 l' w% @
OpenCmdInCurrent()
* e7 l/ m, {) L& `) q {
/ o% q. f1 Z2 v9 P( O7 b4 s ; This is required to get the full path of the file from the address bar
; D1 M2 h: q( o w: K9 n' S WinGetText, full_path, A* C: m4 q3 k. `
; Split on newline (`n)
2 C& `0 N' U0 z5 _6 e% l/ R1 j StringSplit, word_array, full_path, `n
# q1 y- D" L4 [- ~' ? ; Take the first element from the array6 D, v5 Y! f0 O$ Q; Y$ y
full_path = %word_array1% C, a w. r- o e( r
; strip to bare address; j2 O' `2 s: j M
full_path := RegExReplace(full_path, “地址: “, “”)
4 @' _$ h. x6 F. q$ h4 t ; Just in case – remove all carriage returns (`r): _; b$ A, P! l6 \" F+ Z
StringReplace, full_path, full_path, `r, , all9 Q4 A [. U' n1 H" g+ g0 a
IfInString full_path, \
Z, o' Y% |0 {4 ^% {; L {
& t" |' w e; V! K: Y8 q9 [4 @ Run, cmd /K cd /D “%full_path%”- j. C+ C, Z4 L+ N2 c
}
8 `$ M. b* c3 \8 w0 ? else; m( r* @* k9 t/ P1 G: d- {
{
u: T. t/ ^4 v. s+ ]+ W* p$ N Run, cmd /K cd /D “C:\ ”1 K U# x! B1 J4 ?5 }, X
}& D1 t4 @% ]% w
}! f0 T% u0 q! @# S1 {0 J4 i
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
6 _" [) S( `+ a( O; J7 M j 这段小代码肯能有两个你需要修改的地方) g' V. b6 T) o( u4 c. w' d
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# Y( q" Z) |7 s+ f! R0 X 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. w, B8 @8 I1 t7 l+ y% q: g
|