此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 b* F$ z& b2 h: I4 Z! W2 @! M
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 z r" p3 w t1 d: [9 d+ V1 f 方式一:7 l7 \5 j' G$ j$ L# C
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: m/ C `" H+ t* _. W# u
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 e" q) u8 c$ {( f0 q. b HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
- \- T! H/ T% @" r( k9 E" b { 方式二:
4 l( D8 ^4 N; O0 N3 z" L$ i 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
9 u9 B% R0 h4 G. O SetTitleMatchMode RegEx
; h. \1 r% i7 Z3 w: S return
5 `3 b4 I! `) S& C ; Stuff to do when Windows Explorer is open" w: Y; |( P' I; G. P3 @; [
;% Y( N0 g8 ~' v
#IfWinActive ahk_class ExploreWClass|CabinetWClass
, ^& T' P9 f" w: e; j ; open ‘cmd’ in the current directory0 H- G. f' x; K; t ~: e7 z
;8 x3 r& {# a, R
#c::
: b6 b" r8 q4 Z! a OpenCmdInCurrent()" Z! L4 ?3 _) D; \6 H% I# {
return* d. s/ F- b2 v2 u1 d# k
#IfWinActive
+ }6 a, q# C, Q$ T ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) [% S4 M. V4 T5 l! i3 W ; Note: expecting to be run when the active window is Explorer.
% n4 J' F S9 W7 m# Z9 k) h1 q ;9 g$ B1 O3 S6 a, \
OpenCmdInCurrent()' e+ O5 n( ?5 {# G+ b
{& P; s4 ?# g9 J3 P+ N
; This is required to get the full path of the file from the address bar1 q* ~( U1 Z# O$ ]
WinGetText, full_path, A
- v) y/ g# j+ R9 D- W& M ; Split on newline (`n)
+ T) `3 L6 J9 C* k. u5 x StringSplit, word_array, full_path, `n3 c6 Z* X1 ~' o
; Take the first element from the array. p8 l6 F. k$ e1 Z* I4 k2 j
full_path = %word_array1%( w+ F5 T% K t( m3 f9 n: D8 ~
; strip to bare address
4 P( c; E% q- ~ z: J, x full_path := RegExReplace(full_path, “地址: “, “”) M0 Q6 U. n2 Z
; Just in case – remove all carriage returns (`r)" A6 o6 f9 Z% k, B' G
StringReplace, full_path, full_path, `r, , all& j; O4 a2 [2 ?8 n! |
IfInString full_path, \
3 f, U. N! o: K1 T% B0 Z8 I {
2 q6 }! Z/ I2 |2 @+ D Run, cmd /K cd /D “%full_path%”
2 y- w- U* F1 L# @$ B1 p8 r3 _ }
$ {6 u+ `% k$ G1 d else
! ?# L" g2 H3 }. k% J$ q6 l5 H" V {
% f6 |' Q5 L: I Run, cmd /K cd /D “C:\ ”
) |/ r# |. c1 B {3 k3 R4 w } }
5 N% c; p4 F4 t9 C8 n" R }# r. M9 a! \6 }# E( B: k, |
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: x4 T. I S, R' e3 W. L9 Y
这段小代码肯能有两个你需要修改的地方
) X4 y" F5 |; `$ I8 M: l1 [( ^! R 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键, ~0 k( _" C& S; {8 V9 g% D y
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; k$ |3 l, A$ T7 c0 |5 F
|