此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
( t8 ?4 C- Z; b0 W 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 j8 g9 E P: g" I% U 方式一:
& H# V: m( k/ j, H 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 l; G" K2 ]5 S5 C' m" h
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和 h. @3 a0 ^: x2 r. o+ S& I
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 q2 q. ^; _$ l
方式二:
; N6 r% P+ k* H% W7 p: T4 [ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! k# T8 r1 R5 C" \1 X, y
SetTitleMatchMode RegEx% \6 Z) k5 ]. B x4 z
return
. e* G# s% Z$ D6 A7 l ; Stuff to do when Windows Explorer is open
7 D, ?- n6 _4 D9 n* A ;
8 N0 Z4 W' L- c* f- j0 d9 I #IfWinActive ahk_class ExploreWClass|CabinetWClass
, x; C0 ~5 |3 g. k- D ; open ‘cmd’ in the current directory
4 T9 i# g0 e% C* o ;4 M" a) B; Q) ~, E9 k1 o/ [
#c::
3 m N# m! W$ o# P& C$ x+ J OpenCmdInCurrent()1 t# h# y# f7 N; H r
return
4 T+ v6 [0 W) x. z$ Z. o #IfWinActive
' E% ]& [0 |2 j6 R ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.3 O3 z$ A; b# `' n! @1 ~6 X. I+ o
; Note: expecting to be run when the active window is Explorer.
. I2 [6 ~( b* F+ C+ | ;
! D' V- x/ r$ {9 J$ q' N OpenCmdInCurrent()
5 N9 F* T& {& f5 O {
. f! H6 h; n" v ; This is required to get the full path of the file from the address bar+ c; r! a' ]* J6 \
WinGetText, full_path, A
( ?2 \. x+ z, E/ Y" J, r9 g% ] ; Split on newline (`n)
* Y2 C- f! \# X StringSplit, word_array, full_path, `n
$ g, ]3 ]+ L/ W ; Take the first element from the array
8 b4 g& R, s+ V) x full_path = %word_array1%
5 a; ~- {: q, \ ; strip to bare address+ W/ z% Y/ p/ y! c& ~% s% C
full_path := RegExReplace(full_path, “地址: “, “”)! b% K6 e$ k! k
; Just in case – remove all carriage returns (`r)
8 {$ c$ M% Z, t5 ?4 [ StringReplace, full_path, full_path, `r, , all0 p0 K7 o# B5 ^0 q+ d; d( w
IfInString full_path, \+ ?* d2 J# s' f- F4 m
{
! c' l% c- m8 a4 V( |- \ Run, cmd /K cd /D “%full_path%”
0 n+ k8 B* t( U }/ I- h$ A2 {* ?% Z
else
9 g- c$ l& }0 Z { K" x" Q4 U2 T) J
Run, cmd /K cd /D “C:\ ”# l+ D* D7 g1 ^' p1 q
}
$ a6 `" ~3 G! w! k* x" l* w }' v8 t$ S; g: ^
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。4 G- R( B* Z5 F. f0 l% \) Y: X. f
这段小代码肯能有两个你需要修改的地方4 }+ S- l/ ]4 ?1 j
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键+ \2 d+ D; G5 D0 D1 ?
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; Q: \3 `( W$ Z6 `( Y S |