此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 i4 @; k7 N9 i% t \
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
% j7 Z* @9 s" ` 方式一:9 k& d/ j. e9 U2 h
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 K( A% A! ^( S6 c& z; b3 f" _ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- \9 Z: A$ S- C3 B HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 h$ o" b. T; l; u) C. g; x( Y 方式二:
7 y9 ?8 u* O. I* i/ x8 V& E1 O 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
5 ?6 J6 @ U/ l: y8 s- S! f SetTitleMatchMode RegEx
" {' F, C/ n4 }% D* G return
2 c2 S! K3 e2 P Q3 T. _ ; Stuff to do when Windows Explorer is open$ m& |! d/ p/ Y+ `+ r4 A+ X
;, r6 B. L5 q% P, b8 A6 J$ O
#IfWinActive ahk_class ExploreWClass|CabinetWClass
) H3 a6 B/ t% U; B7 K8 V! Y ; open ‘cmd’ in the current directory! d. b# o! _: F6 [! U
;, w2 g7 D& t2 @" t" X- v2 a4 ?. r
#c::
. e7 a. E+ \; C9 d OpenCmdInCurrent()" K% P& |% ?, r3 ]$ w/ |0 s$ y
return
) r, t2 n2 R& l$ d! r #IfWinActive! v7 K, y" b! l. ^" c8 Q" j
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
! ~' r1 B/ u+ f' f6 `9 v. E ; Note: expecting to be run when the active window is Explorer.
J! Y6 Q6 f: O# B4 c2 x3 O4 j ;; i/ e0 I; `9 K- k$ a7 j0 C
OpenCmdInCurrent()1 N3 w1 Z& [- H
{
2 f/ t8 u* P- s1 v2 E5 C ; This is required to get the full path of the file from the address bar- c0 O2 F6 {$ i" T
WinGetText, full_path, A% f. j( h: ]8 C1 L# r/ j4 D8 x
; Split on newline (`n)6 w9 C: K. L5 ]' @
StringSplit, word_array, full_path, `n( S& h; z6 H% x! M+ x
; Take the first element from the array# y: R0 H- A0 i5 b1 ~9 i) z$ j
full_path = %word_array1%
+ c: l) |2 r% e( s, g# a* b5 t ; strip to bare address: j" u- f9 H; a k3 Z/ P
full_path := RegExReplace(full_path, “地址: “, “”)( c$ g: q2 |/ Q
; Just in case – remove all carriage returns (`r); y9 Z# T! R3 @; U+ a. }. l
StringReplace, full_path, full_path, `r, , all! P# J( H8 _1 \. U7 @+ P' T
IfInString full_path, \; r1 E& w: D* v! {1 G
{7 `) C/ m; l# R3 G. `
Run, cmd /K cd /D “%full_path%”
5 C2 h$ y; g8 W1 N7 e9 a& |- V9 @ }+ f/ R' U6 t0 i* Q3 w4 D
else
' ? o o5 s- [% H/ \ {
h* T$ M% u; Z3 A" d Run, cmd /K cd /D “C:\ ”7 _0 W7 b& f) f
}
1 l% g8 X& y5 Z& u6 n/ Q, O! a4 J }
8 j+ P4 ^3 x" O9 T) B 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( e& p3 @7 C$ f! F2 ?
这段小代码肯能有两个你需要修改的地方* g% w. z: F' T4 e
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 P& f" j, r+ ^; P6 ? R
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! r2 h# G/ i0 S
|