此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, n& `+ D- {0 G0 a6 _
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ P4 E7 t9 T: d# ^
方式一:/ Y ~0 J; K* L W
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" P; P5 h7 a; W+ B: d 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( Q% }* S- G4 v: l% q5 s( t HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 D; _' Q: ]" f2 q
方式二:
?$ P$ r! w$ { ~, N3 ^2 @6 v 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
5 E0 r3 D" w- `& I" C% F" R SetTitleMatchMode RegEx$ A! i; }2 q3 O1 |1 D s" S
return. S7 W* L6 N! V, T( N/ Q2 y# a
; Stuff to do when Windows Explorer is open: m- _/ U! g2 k
;
; L( V, e, x* K F4 j #IfWinActive ahk_class ExploreWClass|CabinetWClass
1 [) [0 q) C9 p# i+ u, c/ m; | ; open ‘cmd’ in the current directory& T4 S3 M0 K1 R( d' [
;, N$ z7 c. ^7 S2 h" B
#c::2 i" R q( O; [+ ]* i- S# e
OpenCmdInCurrent()
5 ^! ~( W7 G% ^% ]# A/ O return) o- x1 U* l( I" M- D) H" d8 }* r6 u/ v
#IfWinActive) O/ R Z. o7 V; ]. k
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 s' W% r6 v1 d ; Note: expecting to be run when the active window is Explorer.# [- \/ M% g J% c& t6 E
; k& ~ \+ H6 [0 r/ W
OpenCmdInCurrent()
& p6 @6 ?0 Q1 y6 i5 w# F {
0 r) O$ p, c& G S6 B ; This is required to get the full path of the file from the address bar
2 H) W+ d/ @( s5 _ WinGetText, full_path, A. l8 M( a4 p; b/ k @4 E
; Split on newline (`n)- i6 L6 g3 x! ^ T
StringSplit, word_array, full_path, `n
' z1 G4 M7 H) V2 m' _) t5 A ; Take the first element from the array6 o4 D% Q; ^- L9 J
full_path = %word_array1%* ]5 B" i; Y6 P$ i$ s0 d
; strip to bare address: ^8 @- x! C0 k
full_path := RegExReplace(full_path, “地址: “, “”)
" W) V. j7 m. S9 @ ; Just in case – remove all carriage returns (`r)
2 w" E* R$ w$ r StringReplace, full_path, full_path, `r, , all% X, S" V% \! {8 C z6 G8 r# H
IfInString full_path, \
- r5 J4 w+ U" P7 o# I {$ L7 w/ M( b* T8 T, Q9 l' ?
Run, cmd /K cd /D “%full_path%”. I/ s5 [* T. v6 \
}
% k, h( ~3 T# _! q& m* a else" @2 G4 [0 n) l0 d. o& o
{
. ~" a- f: x: f Run, cmd /K cd /D “C:\ ”
$ ?! k6 e; {/ J }2 Z2 c0 w9 H. }2 c; ]
}7 ~, l$ \; O$ J7 F1 F V: S
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
I6 _& `6 p. b 这段小代码肯能有两个你需要修改的地方3 a$ o) a. [$ |6 _
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; I w1 ^0 D. t; k0 [3 ]5 W
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. A( a+ K. \, i* X+ {$ w* t2 T/ z |