此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ K0 L$ O2 t4 [3 i5 R0 d/ N9 _
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* g5 G8 e1 R$ B; T1 U7 \
方式一:0 _- f+ `: h3 H& l: F e
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% P: U: M2 X0 S$ S$ Y 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和1 j3 @( E4 Z {) [) k
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' G4 K. b+ b- O8 d# Q$ R3 x' q2 a 方式二:
% T8 r; a( ^" D 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 h' w3 Z9 T( l! W! @3 C
SetTitleMatchMode RegEx
) C, r" z9 O, _$ i) v' b2 g return
t7 |7 e6 O% O ; Stuff to do when Windows Explorer is open
! T$ _/ j4 H$ P) C i ;
" ]* r1 S2 L2 H4 W7 D3 T2 J1 }2 g% } s #IfWinActive ahk_class ExploreWClass|CabinetWClass- ^2 K9 u" O0 Z1 u u8 i9 ]" C
; open ‘cmd’ in the current directory
9 R! r: D* D7 k3 D% D ;
+ ]9 o$ N- K* P+ J #c::; a) h9 t4 v/ c; D
OpenCmdInCurrent()% W. u* L2 X" z' B1 N/ r
return
+ h, L: N+ Y# z Y* e #IfWinActive8 m0 F% D1 e! D- u" ` S
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
/ B' F5 m3 I& _, y# @: G* V$ S ; Note: expecting to be run when the active window is Explorer.
9 ^% B8 e- D6 O" q' M0 ` ;2 k* o7 Z+ g4 E; b: n7 \
OpenCmdInCurrent()$ b" ?: s8 Z' F$ s6 x
{, H4 C6 W4 J1 a4 Z8 g9 v
; This is required to get the full path of the file from the address bar
5 E( M: c! h' a WinGetText, full_path, A
" K5 S# s$ ^. x ; Split on newline (`n)
6 x4 y5 {7 N6 J( S. ^4 W, h% _ T StringSplit, word_array, full_path, `n
/ s9 w: M$ ^+ @6 }2 B2 s ; Take the first element from the array
1 s: H+ T) X3 y" { full_path = %word_array1%! | c8 z' m+ X3 B$ L) K; J
; strip to bare address
* Z. F( i9 N3 P) ]4 D full_path := RegExReplace(full_path, “地址: “, “”)
/ ~1 D, y* [% Q( r ; Just in case – remove all carriage returns (`r), i, Z3 w0 ?8 H4 x) S1 L& c
StringReplace, full_path, full_path, `r, , all
+ j f. ~$ r! z- g2 D8 ?" f1 U IfInString full_path, \4 i1 F: J A2 x% }5 ~' G0 K# {* o
{2 P* T0 u' t9 Z! V$ v6 |! A) J
Run, cmd /K cd /D “%full_path%”
/ Y) @ A% i3 g; O5 a7 N6 m }! N0 T9 j& ?$ {- R( J' x' M z9 A
else
+ R) ]: Q0 _1 B) \( V. L+ r {
) y! h( g) J% ]7 F4 _$ F Run, cmd /K cd /D “C:\ ”
A$ ^1 _0 K0 M, L$ s* [ }
$ }: Z) t% B3 @& Q }( M' R* G8 F/ r4 }) u) w- r
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 i% _8 ^0 w0 @: x 这段小代码肯能有两个你需要修改的地方
) P+ I( f3 Y" n/ j( z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ }3 E3 `7 w8 n' V5 V, W' t 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “0 F w2 a6 ~( }! G5 l
|