此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
4 y* g% @: q( Y1 a& l3 V9 x. W 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! f, b$ S7 [. y6 Q, G
方式一:
7 X& O: P' e$ F- p2 }2 E 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# [0 j# S- Q* t% r U$ j9 `! Y 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) j8 g( g4 n+ D/ Q
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 z. d z( y, u 方式二:
+ O# E5 S2 J" s4 t6 u7 ~: v5 U 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
4 c% q: |/ r- M) d1 C5 _! d/ s SetTitleMatchMode RegEx* e% J5 v) m% s9 ]6 w+ g
return
* L+ @+ p0 ], ?, }2 R% y2 u ; Stuff to do when Windows Explorer is open- c5 J" |- Z8 t( j9 n8 r* Y
;' i& V% u9 v) z$ ^, S% O% s
#IfWinActive ahk_class ExploreWClass|CabinetWClass
7 @$ M) L- W3 }2 T1 _4 c ; open ‘cmd’ in the current directory7 u# V7 Q9 I6 L' k
;
- x- O! w/ A9 w# H1 G& h. }: _9 X+ s #c::" [1 H1 w `, g' k% |
OpenCmdInCurrent()) ?- [% y6 |% L; _2 j
return! H: q1 E8 |) s0 ^1 ?% d
#IfWinActive
$ g8 ~3 M2 m! d/ \ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( W1 [) {# X7 L3 g" { ; Note: expecting to be run when the active window is Explorer.6 b" T3 @9 J. A8 I2 s# v
;) L6 a6 E( }2 K( Q
OpenCmdInCurrent()
3 ]* U5 }( `" H X. ^* [# x' ` {
; J9 s- v! g8 T* w8 _" T, m' \ Z ; This is required to get the full path of the file from the address bar
) f# x+ `& A- M3 f% Q& H WinGetText, full_path, A
, a9 I# E& Q! ]8 v( I. h# w! n ; Split on newline (`n)/ ?. t$ k$ D( B: c
StringSplit, word_array, full_path, `n
) x5 Q! A+ y. v# s ; Take the first element from the array
# C. e+ R& `* Z: D o' x full_path = %word_array1%& w2 B* ]2 d' Q/ S
; strip to bare address/ ^& {5 ~$ f7 r; _3 z
full_path := RegExReplace(full_path, “地址: “, “”) x/ N1 {; B A, K/ A* U* {; t) T' U
; Just in case – remove all carriage returns (`r)
5 T2 O; L( r- M# U& P3 k! S( h- s8 M StringReplace, full_path, full_path, `r, , all" W/ h g8 k+ j: {: B3 G
IfInString full_path, \7 \2 }# O3 O G) e5 {# h
{
+ r6 N# V7 I" h' A Run, cmd /K cd /D “%full_path%”' x( ?5 a4 h4 m2 w P' X4 {6 E
}$ ]- v( O2 J$ K9 d8 x7 j
else
9 y @: y5 q4 Q7 g" ?' B2 s. X" q {! F4 r6 `- A: P) E
Run, cmd /K cd /D “C:\ ”
8 |( R6 n7 S8 }0 q$ U. }2 y- c- t" H }
. g8 p+ I2 \' Y9 J! z5 V }
0 R% u5 W: q) W% x" S$ ~ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
9 ?! [' n4 j6 _7 v) L 这段小代码肯能有两个你需要修改的地方
+ y: T: u* x% v) ] 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" x* I7 R% d. K& O 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ G) B3 P+ S, ]9 i% a4 R7 O
|