此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
6 U v" X: k2 W8 A% n3 }0 z3 X 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* H2 Q S% P! y% e$ l! A
方式一:! F$ o/ e3 {! S% ~3 P0 `4 A+ j
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 J5 {4 G, x! u, t
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# f* \$ |# P8 G' q! q, i
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* C4 ]/ }8 U/ X R. c- A# r 方式二:
2 q9 A$ {0 A0 S* n 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 |$ U5 {+ o$ [& v: {4 C5 E SetTitleMatchMode RegEx7 N0 Q' C z6 R( m1 y7 A8 f/ a& G
return
% S6 o3 z( b1 b) ?2 S. n0 X ; Stuff to do when Windows Explorer is open
3 I6 b {" V# F/ l ;
1 A1 ] N; T) x #IfWinActive ahk_class ExploreWClass|CabinetWClass- `) r# ^: O1 M- i% i$ f) n
; open ‘cmd’ in the current directory5 U d0 Y4 n. G Z0 H
;
' ]' m' @6 n7 O( Y #c::
& Q8 F* K, e3 V. [ u9 B- x OpenCmdInCurrent()
4 L( {$ [3 r( c4 d$ N6 C return
/ i5 d* R0 P% ` #IfWinActive' C* X; f. ~6 G* f% R
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 G9 N z+ t+ p
; Note: expecting to be run when the active window is Explorer.
; Y: m( G3 R& |: w ;
0 ?2 X X2 ]) K" f, u6 N: e7 l OpenCmdInCurrent()$ {$ d) w3 o) w R5 t
{6 S% C0 o5 D. E
; This is required to get the full path of the file from the address bar
% H* y& f4 K- B" ^ WinGetText, full_path, A' S i1 S S$ ^. w# w' e
; Split on newline (`n)
) D0 Q/ P" ^) f/ z% q StringSplit, word_array, full_path, `n
5 W* G: {/ g9 G, E ; Take the first element from the array8 B! b) c" n8 x1 ^
full_path = %word_array1%5 R) ?' N$ L, J$ o. D1 i
; strip to bare address
( u* a) r9 D G9 Y4 W1 u- X full_path := RegExReplace(full_path, “地址: “, “”)
" i, R+ @$ e$ C: ~! X; X G ; Just in case – remove all carriage returns (`r)9 l3 u# m5 T% i3 ^+ i. ?' u
StringReplace, full_path, full_path, `r, , all
/ @/ r, c8 Z& X3 H4 m6 R IfInString full_path, \
6 U4 }0 W `: f9 ]! `' ?7 b) p {
]; O I2 c3 {+ ]2 J: J2 z Run, cmd /K cd /D “%full_path%”& Z# Z$ t0 w2 R" {% B; i# S: ~0 h2 [
}
7 |2 r7 t8 r! Y7 x" h else
" @( i; I1 }, ]* a- `7 v {
! R# ^! S t' K( F- I Run, cmd /K cd /D “C:\ ”
- \# G: E7 I- |. N! M% O }
1 \4 X) _7 B3 A2 |: n, a8 d# R }/ F, h5 ]7 d" {) O
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% U& ?9 Q& K$ y- U/ Z& j6 r
这段小代码肯能有两个你需要修改的地方% E' Y) X1 N( [( i! Q3 N0 G/ a: n
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ R# B2 p4 p7 [3 x3 V' M 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “% d; d" s) h- h
|