此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
: i, P3 @* l. j- @- J0 H9 G 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。' k5 D5 S* u: g/ {/ l9 s+ V
方式一:
/ a: f% F2 y; h1 }* Q9 I 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, ^* v5 ]4 D8 `5 @* M( j4 a4 @
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! M- T+ J6 P; P) d6 b! Z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) {3 r6 n5 P6 m- v2 j3 N! T# p* o
方式二:
+ r6 m" A) s$ c6 t' m% T' u 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:- Z0 j$ h4 p* O1 W; d7 j
SetTitleMatchMode RegEx
4 |% j. T) U3 h1 [: Y return1 Z' r+ t B) k2 d4 ~
; Stuff to do when Windows Explorer is open
1 D U( J4 L' ~" Z# e ;
. H0 F7 k9 I/ A% V* c% L# p, ~ #IfWinActive ahk_class ExploreWClass|CabinetWClass
. u4 X6 x) H, `6 ?% w9 { ; open ‘cmd’ in the current directory
@! }& B4 _4 ] ;$ x2 a U7 U# R3 S& Y# v- Y+ \
#c::/ P- Q# t) z @. K& T8 m# z1 I. t" D' \
OpenCmdInCurrent() d) w; w# ?- G8 Q8 W) y
return) Y% Z0 M6 U( `0 l
#IfWinActive
: [, J+ ~/ b* ~ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ {) X/ g4 Y) ~
; Note: expecting to be run when the active window is Explorer.
- k I5 C% e# p1 B+ C" M ;
. M, |, [% b3 L& l OpenCmdInCurrent()/ g. L+ I( e( K1 a0 g
{
$ q- Q0 x5 ?+ P2 O ; This is required to get the full path of the file from the address bar8 q! ^1 C% C. h# n1 g/ Z
WinGetText, full_path, A
q' ~# N. V) k ; Split on newline (`n)
. W V% B2 Z V- Z8 [2 ^* ^8 I# Q StringSplit, word_array, full_path, `n
: \, ?$ x: S' q$ P) J ; Take the first element from the array& p+ A9 I N" h1 A, ]& ?/ j. j
full_path = %word_array1%
/ J9 s% } L P2 o( J ; strip to bare address2 l9 }; |( Q% }5 S' N% O
full_path := RegExReplace(full_path, “地址: “, “”)2 d; c# m. z- i) Y
; Just in case – remove all carriage returns (`r)' `/ d' o& |# L& N
StringReplace, full_path, full_path, `r, , all5 O* i7 Z" x5 n8 t9 f- k1 ~
IfInString full_path, \) r5 L7 C+ n* a0 |% n0 `7 S# w8 L X. y
{
8 S8 t: X2 Y' T0 a" u! Q4 D" | Run, cmd /K cd /D “%full_path%”
1 Q1 U* N# h) D) e: i }% Q3 m2 Z3 ~9 ~; } x
else/ j: l, D$ g- q, j' W z
{- k; s: ~% f8 L( [9 Y$ t& a
Run, cmd /K cd /D “C:\ ”
# h! c: d2 `9 t3 U }& [3 w" X7 `- V) C7 R
}0 b' A& W5 X, J
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% |, s2 ~9 I" Z( e& D7 P! N
这段小代码肯能有两个你需要修改的地方& B9 z9 x2 r Z( B
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键* k. R8 X8 q, F9 Y5 O3 N/ Z+ U
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 [9 u3 m) d* ]* q* c) n" a7 q# J
|