此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
: j% h% M* i* ^: ] 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
l' o# R" S: g* Q% k 方式一:8 T: {3 u5 w8 a
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 b$ l# ^3 m! N$ W9 p' L N8 m 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和& [9 A( f; X$ T% \% u
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) E/ S3 |6 g& ] Z3 `+ m2 v) [) N 方式二:# Q" |& F) R7 X) U" B$ p
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- y2 y' l8 e# [' p SetTitleMatchMode RegEx
3 g+ G4 b; k9 H5 v6 [& T# J# V- I return
9 S* e2 g7 I! `7 v ; Stuff to do when Windows Explorer is open; q3 I# u; |0 G4 \' b2 d$ e3 \
;( _0 h* A- W( T& }4 n) J# |
#IfWinActive ahk_class ExploreWClass|CabinetWClass
* q: k9 G- M8 A$ A% R ; open ‘cmd’ in the current directory s4 n. ?4 u2 l0 y7 b# H. M1 t6 X
;1 J/ E* g- M8 j3 N1 O: \5 z" Y$ D
#c::
) M4 J8 w6 `; e+ u% p6 } J- v OpenCmdInCurrent()" r) r$ ~, A1 A9 [; s
return
, R* X, u! m) S1 w6 e. m* R& w #IfWinActive
; o4 F. S S( U" d ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- J" n4 `; r8 T6 `6 j! K. ~6 \ ; Note: expecting to be run when the active window is Explorer.
7 v$ x' }$ |' h* O0 t ;
' m) c, F% |! D* f% G) O9 z OpenCmdInCurrent()
- n) S! Y' }, @3 O0 f. f {
3 K2 _4 s- ?" L6 g4 Q ; This is required to get the full path of the file from the address bar
/ v' T" g" ^% f5 p* W$ k. K2 Z1 s- d WinGetText, full_path, A
% _: {5 V. S8 D* ]: Z7 w# T5 J ; Split on newline (`n)- A A1 y' o0 q3 E& J
StringSplit, word_array, full_path, `n# v, K- ?5 A& f6 ?7 q
; Take the first element from the array
% P0 B4 a, i1 y! K* y5 q full_path = %word_array1%% M; Q% b6 Z$ D% H) |. C
; strip to bare address
! R& ~& J% P$ u( c; D full_path := RegExReplace(full_path, “地址: “, “”)
. j/ _( y, m9 L$ p7 f- D @) F: v! b ; Just in case – remove all carriage returns (`r); _* P+ V, G/ W9 h& o" J3 N
StringReplace, full_path, full_path, `r, , all" w6 m8 v1 d9 n& x& U
IfInString full_path, \
4 ~- @2 Q3 o! A; U {
! z. y$ l/ ?# B f4 b) O8 c Run, cmd /K cd /D “%full_path%”
8 [( ^. t2 ^2 g1 G( K0 y$ [4 S }9 L! Y) D k j- x1 U7 ^
else
: r# I, i* i8 y3 j {' _, T4 H0 M# q5 x" S
Run, cmd /K cd /D “C:\ ”
( V( [9 t" ? H. Q6 ]& T }" e" Q S8 U5 f
}
/ U* G0 U" F* [! r1 F 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) Y: o3 y m$ f. i( X
这段小代码肯能有两个你需要修改的地方 \. P. H6 |3 A/ @0 L* Q ]
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 |4 o; E& K6 x( }2 K8 s
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “% {! m6 r# Q5 w+ I3 h* f5 L% _" H
|