此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。7 ~. M* v/ L1 g7 `5 Q! d8 t* R! ]* { p
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 S3 l0 [+ A8 [1 h; M) p 方式一:
1 d8 A9 l- q* ~( Y- R" C1 ? 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 `) N- T% s; l0 p0 {' Y) [ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ q: T' z9 f F V
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
, |% @& b4 B, Z, l+ x6 ` 方式二:' Q& T( y9 ^& T" s" ^8 b% f
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:+ U% O x: N8 C; ^8 O8 ]& `
SetTitleMatchMode RegEx0 ?- \- C( \* ~9 w. D* O* |
return% {2 @+ @4 w9 F+ _- P4 ]8 u
; Stuff to do when Windows Explorer is open o9 h2 K# g4 M( B9 H
;
1 b# I9 j$ O1 r4 Q #IfWinActive ahk_class ExploreWClass|CabinetWClass
# s& Z' g' H$ B3 j& l, x ; open ‘cmd’ in the current directory
$ l, H, i7 A" V1 |9 r2 U6 ~ ;
/ H. \8 P# i0 e4 v! c& j" x #c::
( v6 b u: z% @* G$ y& ? OpenCmdInCurrent()
* y7 p* w0 W- [# [, C! Z/ Y# j return
, f t5 n: I6 X #IfWinActive
: m2 S3 Z: `* W9 M$ I4 C- J ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 r0 @! |& S! I# @7 P$ ]$ q
; Note: expecting to be run when the active window is Explorer.
. B9 R2 C V+ n! \: k$ e1 J" Y6 ` ;
+ h! ], c; M/ e2 S! P/ q1 B6 R# n OpenCmdInCurrent(); e! n$ F9 ?/ i p, A5 l/ W
{
8 Q: O8 _$ G& h" S ; This is required to get the full path of the file from the address bar
, F9 S; ^6 z. X) K0 l/ m/ V5 S I WinGetText, full_path, A7 C/ ~) g/ q4 J+ K& n* [
; Split on newline (`n)! ]% I' |3 {: x2 h6 m5 h
StringSplit, word_array, full_path, `n* |, V- b5 ^1 |- Y
; Take the first element from the array+ ~. t7 J8 R; O6 E) C/ F
full_path = %word_array1%
9 f6 Z$ F C" ]% ~ ; strip to bare address
" A- y% G- ~4 D" E$ v& o" G full_path := RegExReplace(full_path, “地址: “, “”)
4 C3 U0 @, L7 } ; Just in case – remove all carriage returns (`r) V" d: T4 [9 X6 }& Y* h: J
StringReplace, full_path, full_path, `r, , all( [( j( C: n; ^' P" e5 v; d
IfInString full_path, \
; \+ H7 F+ N& i6 _+ L# a9 ? {4 ]$ w) d& }( s) `6 L3 C Q# |
Run, cmd /K cd /D “%full_path%”' C! @3 k. s; L" A
}7 l7 k8 \ V) d7 P8 P
else
t/ z' S( h: W( ?* i) U { v e) Y7 t, o0 j, n
Run, cmd /K cd /D “C:\ ”
L! o7 g2 b. o& S7 s" n }& ]0 ~( C$ C, C0 p$ M
}" _4 \0 j0 ]9 t1 D& z
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& ?% ~6 {$ l9 T: R8 r. a/ j+ ~ 这段小代码肯能有两个你需要修改的地方; z: A; m% H% {! S) t/ r% f A
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' e; N4 f. _; r9 f" D7 d
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; c: m1 Z {/ }, r z9 l
|