此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
* _: N! F5 |5 t# Z( d 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 D* T. W3 ?3 a( N1 N5 k" A
方式一:- s* N4 L! N' ~2 ?9 y% B$ w
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 j* m. f: J) x# S' c2 v _
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 X6 L9 d" L' r7 c' p Q g* e HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* ?" x9 l/ l* W& T
方式二:" ^6 c O' ~, u0 h& i6 S2 }' C
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:$ P$ g* m1 B0 w: q2 T. Z5 u+ n
SetTitleMatchMode RegEx
U' P: C% q: Y; S, @ return
0 _7 h! H; N' O6 P2 B ; Stuff to do when Windows Explorer is open
! q& F( B: c) a! J ;
7 k- r' j) }! g# ^ #IfWinActive ahk_class ExploreWClass|CabinetWClass5 k* c+ c, b, U2 Z
; open ‘cmd’ in the current directory. r. b% \! I$ t; \ G/ Q: s! s
;$ ^- B0 S, {1 m4 T4 @# u
#c::
?9 J4 H: m* g5 ^ OpenCmdInCurrent()/ V/ k% n; b1 h6 P) d$ s
return0 }1 B% z- R W3 i
#IfWinActive
/ h4 p( H9 s9 [6 V# `9 l: S/ \ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
& O8 U/ O3 ~! R5 t9 W$ @ ; Note: expecting to be run when the active window is Explorer.
% X0 u2 m1 k% ?3 B9 D# ~ ;
$ \$ L ?9 ^5 T$ `: ^ OpenCmdInCurrent()0 C! }' p7 ^6 y# z9 [5 j' W5 b' o
{
2 S# w5 A( |$ P. R7 v ; This is required to get the full path of the file from the address bar
$ o/ p& G+ C, y7 K# o5 @ WinGetText, full_path, A& p5 u" n1 B0 J( b# @
; Split on newline (`n)
4 a9 q/ h6 x6 v1 r) j/ V. c StringSplit, word_array, full_path, `n* |8 Q1 i; V [0 i, L" \
; Take the first element from the array
$ ~/ K/ d! L4 t0 [# N: U$ [ full_path = %word_array1%
- C* P, p/ K* [8 U" m+ x! h; I0 g- S ; strip to bare address! {/ ?) ^. Q' x2 u1 A! l
full_path := RegExReplace(full_path, “地址: “, “”)' ]" p% n, `( ~" v) W; p$ R" {
; Just in case – remove all carriage returns (`r)
5 M2 H0 x8 u/ ^8 ^2 @& h StringReplace, full_path, full_path, `r, , all X* W6 Z7 G9 [4 `8 Z& D3 ?
IfInString full_path, \$ A! `. ?# u" G
{* R; E5 l- B2 S
Run, cmd /K cd /D “%full_path%”
' L! }7 X3 R( J }% I% k) E& W9 m3 L- @2 Y
else
6 R, c E. G0 k% t5 L! m { `# D# X9 i6 {4 t( C' J+ H1 A H
Run, cmd /K cd /D “C:\ ”
( D9 h& I) a2 L0 n' K }( c* N- w6 ]0 p; g) a. q
}
: b% ~/ \- H8 X; e3 R0 z 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
% u" k7 J2 B" c+ b5 z% h 这段小代码肯能有两个你需要修改的地方9 X) }; u ` [& Q/ U: _/ V* e5 {
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( ~2 x6 t1 M8 x" o5 [ Y8 O. y3 W
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “% _4 G" }/ m2 u; U* i( [/ Z
|