此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" X) I& v+ K& m7 \
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 O# ], D; S; b5 U* S& Q! X* X2 M
方式一:
" b' p3 e/ g) V8 y- \4 g 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ Z; p* \! f4 ^$ K7 A8 x 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 }- e" P- m$ K) ^+ `! X7 @ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 V: m! i& @1 D4 [2 j& k: e8 z- h- G
方式二:
% F v( l. Q5 G 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- r2 ? h( |1 F! C5 \ SetTitleMatchMode RegEx ]& K( Z* Y0 P
return
4 O) b, {& E) v @ ; Stuff to do when Windows Explorer is open3 {3 Z+ Z) L$ d8 }
;, U+ p8 a6 W# R* w
#IfWinActive ahk_class ExploreWClass|CabinetWClass
$ ]" W! v, N9 T! E4 P ; open ‘cmd’ in the current directory6 o! q* x! [* j6 R2 e
;
+ Q0 L4 \$ X E- L5 s #c::/ R6 a$ R* D8 i1 f3 G. v
OpenCmdInCurrent(). W& i: H3 p. }- \5 B H( T
return
1 J! [5 j. O7 A K- U #IfWinActive
$ h% j; A9 d( W# E/ D ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' q6 q9 a. ^5 }$ M% v; I3 A ; Note: expecting to be run when the active window is Explorer.
5 G$ Z: {: x) s6 C! h ;
9 X$ o. a! j1 o OpenCmdInCurrent()9 T% F8 ? F* P" r/ k* h, e
{/ W' E0 H7 t* v: b2 y1 m* c, k/ b
; This is required to get the full path of the file from the address bar
; Z* \% R# x$ y WinGetText, full_path, A
" |! b! ]* h$ K) V ; Split on newline (`n)
' ]* @ S. j3 d9 W! }! a5 [0 f StringSplit, word_array, full_path, `n
' U8 `0 j. }% w& y5 T. I ; Take the first element from the array
1 D- z6 ]5 v* ]; r7 B full_path = %word_array1%
- z# C& W4 M- K$ \) F ; strip to bare address
6 t c2 g$ E( a3 M! }" [ full_path := RegExReplace(full_path, “地址: “, “”)
9 M8 q0 e3 J( H' b: d3 K ; Just in case – remove all carriage returns (`r)0 K0 F2 K0 M/ y6 e( `
StringReplace, full_path, full_path, `r, , all; Y1 j; u3 I4 c8 L/ ~: b
IfInString full_path, \9 o# W3 @; B' T1 k. f) H4 v* q8 H
{2 k0 n5 d) {5 q, W. j8 o
Run, cmd /K cd /D “%full_path%”" X) Z b# ^1 y% ?" P
}. A- {$ ?* E# k7 Y
else* U0 \* D, E+ S2 Y' G! n! U3 \6 a V
{
f/ p: g" l9 G4 h4 w3 S2 x3 H Run, cmd /K cd /D “C:\ ”4 D5 i! C. Q" u! Z" m
}
, g+ B% m$ Q$ V. t" ]5 F8 f1 l }
: b* |9 l& j: C h5 O' M+ ^! d( `4 t 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ c+ u. w! Y" e4 H# \7 ]
这段小代码肯能有两个你需要修改的地方
( b$ Y- h8 D0 l3 p" |* S 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& ^3 X6 d( n$ K$ e7 k9 O8 z' M 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 A& I) k7 U6 u7 _0 }! p7 i! n
|