此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 E! j$ s( V- n* G7 \+ i$ K
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& r) ~7 f1 b% V( Z; P' `. \ 方式一:
- z- j) ^* |% h$ j 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: d( r2 I6 M5 a6 g/ b& Y 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. ^8 ~7 o% l4 n' {6 O+ ~& h/ I HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
. R- z3 G+ `, r! \ 方式二:
. J+ Q. N$ X2 p1 S0 d 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 x/ f5 j8 L% \ ?. i) |. Y
SetTitleMatchMode RegEx
/ X3 ]2 a( \& ^ return
+ P! ~( | z6 Z; R ; Stuff to do when Windows Explorer is open* u) t% |, y1 O; N ?$ ]) E
;% f0 K/ X( V2 t% y2 f7 Q% V+ C1 m) g. |
#IfWinActive ahk_class ExploreWClass|CabinetWClass5 r0 t/ m- B: v) l8 _" d+ R* B
; open ‘cmd’ in the current directory
& [7 S5 O3 l: O/ v- \! a ;. o1 R L1 C9 |% }8 p; d
#c::
5 J# S, \$ J6 H* y$ ]3 u OpenCmdInCurrent()
; L; U6 W) d O5 t! m3 t return- e/ c# I% ]: V! p$ p
#IfWinActive' |; g* Z& P+ j ]0 F
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; _3 p& D. S( `0 O K ; Note: expecting to be run when the active window is Explorer.
/ m3 H v# m7 l- Y- q. O6 v ;6 w7 |- ]+ Z, E: v
OpenCmdInCurrent()
) \' x4 w8 @9 k! Q q9 i {9 O6 T4 K4 I( ]. N
; This is required to get the full path of the file from the address bar
% X5 e5 y k4 i M m WinGetText, full_path, A" }' T% Y) T, K" m+ Y1 p
; Split on newline (`n)
) D7 M/ ^. G: w: A0 y StringSplit, word_array, full_path, `n
4 U4 b1 f1 U, ]9 ], z ; Take the first element from the array
3 Q9 y' |) n$ F- y8 l full_path = %word_array1%
& c9 i0 N' { a1 e" \ ; strip to bare address
" O( m9 p( Z/ ~+ h full_path := RegExReplace(full_path, “地址: “, “”)3 {5 M1 ^- r! y/ }" a9 `8 p3 b
; Just in case – remove all carriage returns (`r)- R' [! s0 V# n( m5 u5 s3 H
StringReplace, full_path, full_path, `r, , all8 w% X) u* t, H3 H3 ]4 m/ | P* ^
IfInString full_path, \5 K2 |! J4 L) z& i Y
{
5 C+ q1 z. y8 i% k2 c Run, cmd /K cd /D “%full_path%”+ Y0 t6 I6 \+ s% @, c% \
}
+ e) k1 i+ {& y else
7 x* ~$ V. H$ E X- T {4 j" S$ d2 J1 a# a( r& O& t
Run, cmd /K cd /D “C:\ ”' ]- k5 U+ S$ ^8 B& X/ h
}4 K9 P% c, j- h
}
* v5 a! b# Z4 Q) o( K: o1 C 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。+ X2 m' A' d- W8 ]1 u- n# {
这段小代码肯能有两个你需要修改的地方
- b4 i6 C/ o! p2 z. w 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) b" N2 c, E/ Q% M
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ f: l# o S0 t5 @$ A |