此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, b% l+ a; ?& R7 H% W0 |! i5 f, t
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
6 C0 @3 ?7 X$ w$ |' M2 E3 S 方式一:
4 `6 }) G8 n/ N( i& p# g2 V 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 E4 K! L/ L" {( }* M
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和 B' a( Z$ [1 v, X+ n2 ~
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。% V/ M) {& U3 J
方式二:2 f' l3 v$ i5 u; i
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ p/ D t0 E# P# I1 A M( `8 `
SetTitleMatchMode RegEx
# J. V- G+ ]: |. ] return
& \- |) \) |2 L- P3 ~( F# s ; Stuff to do when Windows Explorer is open% E+ Z: L7 P" j( p: [4 \
;- a8 V4 o1 r* y
#IfWinActive ahk_class ExploreWClass|CabinetWClass
- c$ q% ~2 J+ V, ?" o ; open ‘cmd’ in the current directory
4 h$ L$ O0 E/ K2 d9 o ;
9 B5 U h' [ T' J" E1 P #c::4 ?! N: I, o4 z; A2 X
OpenCmdInCurrent()) @8 L" x8 k7 P6 x& E
return
& n( ^+ v L% G6 T+ H- C #IfWinActive: Y) D, [3 d# ]1 B' o
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' f# }" X& R1 s8 M ; Note: expecting to be run when the active window is Explorer.% a/ s. x* |. z* E- R( \: p
;+ Z8 `. a& p. I$ f$ O) H! d
OpenCmdInCurrent()2 B0 o* _5 v* E( c
{
. w7 ^4 v2 h, n: E& t# I1 J3 c ; This is required to get the full path of the file from the address bar
) E+ M* U! P/ T+ V# H# X WinGetText, full_path, A
- o9 f9 {3 s1 p; O2 q ; Split on newline (`n)
9 `- D* p/ U# `7 d' d) K StringSplit, word_array, full_path, `n; b/ o) L2 r7 ?; k- x
; Take the first element from the array5 t1 b* W3 T4 a# j. B4 p
full_path = %word_array1%& ^6 N; D7 O/ V# Z+ ]# n
; strip to bare address
: D/ N2 {8 m4 h% t full_path := RegExReplace(full_path, “地址: “, “”)
" d$ f: w! b* y2 k [ ; Just in case – remove all carriage returns (`r)
9 P+ e: I& D. ?$ k StringReplace, full_path, full_path, `r, , all, X$ o8 ^ a, e# Q& ~
IfInString full_path, \( }- \& I/ g& B; v8 C) L9 T
{# s! w- Q9 R C
Run, cmd /K cd /D “%full_path%”0 ^+ {6 @' @( a) i2 g6 L" I
}
) R/ X* h( I4 L- c else
8 L2 g5 F4 a c7 L- C6 g {/ ]4 h3 Q6 A$ f, M# m3 U
Run, cmd /K cd /D “C:\ ”' O3 B' o2 t+ P
}6 \# v& L; x5 _
}8 n3 @. w& ~3 k9 V: X) a
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" W5 G" m! x4 O( U4 b" S6 S2 S 这段小代码肯能有两个你需要修改的地方9 U% f- `! U6 q& x( s; q$ Y
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键" {4 H7 g; P; r
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! C$ s; c/ q/ A# t- M; P |