此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ }; ]. J' F6 _" X q: r; ]: t; ~) x 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! {" y) L) M( x
方式一:
1 y3 O' S. u% b1 n: t; c2 [0 w4 V 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( `! |" W* p7 j7 z% n% p. x 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, }" g/ @. ~; K( R
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 \) V! z1 c: h3 u6 k$ K- |
方式二:; H' _/ L( `: z3 N7 g. w! A
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:+ |$ p5 |% `; n. o7 w; F+ J
SetTitleMatchMode RegEx1 k) k( s2 d# i0 N3 g
return
! W b: @# z) o0 k$ ~( Y E4 w! m ; Stuff to do when Windows Explorer is open f5 _) |8 B" K) s" L
;
: T8 G7 H" `7 j; K8 x; K) p #IfWinActive ahk_class ExploreWClass|CabinetWClass, N" d+ Z: f. s
; open ‘cmd’ in the current directory8 c. ~# U. A/ S& ?- r
;$ _ u# s4 ~8 X$ Q2 N
#c::4 b- Q/ E; J z) d$ b- d7 @
OpenCmdInCurrent()% j( g/ R% ^: Q+ k
return% B( t0 |5 B9 P" [2 r$ M2 p
#IfWinActive4 g5 W% ]$ A2 d5 p' m s
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) O# D+ |9 g F# R& ?( @- y6 q8 m ; Note: expecting to be run when the active window is Explorer.
' o' M. q! z+ Y; S7 t ;" |7 m6 r# l' v# q% ^
OpenCmdInCurrent()( M$ |1 c' }" S" |3 S- B
{
: x5 z* p/ d1 X; r1 p4 R ; This is required to get the full path of the file from the address bar
+ j7 C4 _4 t9 V; j3 h/ r, n WinGetText, full_path, A5 o* G: Y) h4 J: o
; Split on newline (`n)- u1 |1 X- ^- c4 |
StringSplit, word_array, full_path, `n) U. }' _, u; \7 y9 g! w, ]
; Take the first element from the array
9 K. {) h+ I5 W3 L# g full_path = %word_array1%
- k% h; Y+ ~* d3 K ; strip to bare address' w$ M( b: l) D
full_path := RegExReplace(full_path, “地址: “, “”)
% o0 L$ {6 s% {! N {, d" l ; Just in case – remove all carriage returns (`r)& l- I- n3 h/ u$ h, k6 E) K) A
StringReplace, full_path, full_path, `r, , all
3 [3 n; m- a' N9 `% L, H IfInString full_path, \
) ^4 v. _. o/ S& i/ u- n) x% b# o {, h; g6 x( A* R* d# t
Run, cmd /K cd /D “%full_path%”4 _" ?4 O$ ]% }# t9 F+ X7 R6 o- @
}
# w3 v& ^' A7 @ else* C( D% }& ?# I* d9 ]; a
{
^& [2 r9 N" N5 t2 i Run, cmd /K cd /D “C:\ ”
- }- z) ]$ z) n/ |2 L/ {. \- d }6 b) A+ h t( R, }/ T
}
. r. y* C: j$ z7 ^) U 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 `7 ]6 e" u' C0 {& M7 ^
这段小代码肯能有两个你需要修改的地方% o+ Q9 T* J$ I! F9 a+ ^
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 g f. W! \( v2 _. p 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! j& z+ F3 M( e! r# Z8 h1 R
|