此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
, \# U" O9 m9 M1 j, z2 N- B 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。3 N8 \: J% _3 Y( x6 n0 I; ~
方式一:1 y2 g0 t8 M2 C5 @: h1 b5 Q
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,3 \- g7 ]8 g- ]
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) i# D; ?8 T, y- K8 T
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 G- S1 q1 _! x& Y1 G6 x: Y 方式二:
- F8 d( t Y: c- q# B& f8 o+ {2 M1 Y 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 G; N! s4 U, z
SetTitleMatchMode RegEx
/ @( N4 f4 F3 N/ N+ r/ C- _% T3 C return3 Q7 \, C- d* S9 B( `/ a
; Stuff to do when Windows Explorer is open
0 J3 I! W. x. c' U& { ;1 l4 F/ g/ O% Y6 g3 ~' y) D1 B `+ y
#IfWinActive ahk_class ExploreWClass|CabinetWClass
$ j1 k- d- @8 \ ; open ‘cmd’ in the current directory
4 @$ {6 P, n' G5 F% V' x' B ;
/ y& _; g! l6 F% g9 z5 ^ #c::
4 ~( K% \3 g0 j2 E# Q$ c4 ? OpenCmdInCurrent()) g: m; U* B/ d0 b; v3 ~
return+ b; R' b+ D# [ R/ B( ]7 |" j
#IfWinActive# w' D! k8 p0 h+ l3 ]8 L' h
; Opens the command shell ‘cmd’ in the directory browsed in Explorer." a) h# [. N" J# c5 S( i W
; Note: expecting to be run when the active window is Explorer.
) I. K' l& R6 E% K6 z ;
+ G; E& ~* I P. }' o2 t& ]! w OpenCmdInCurrent(); L; h8 i: v) X% `- V0 x
{$ s' q% m# p6 m& M
; This is required to get the full path of the file from the address bar7 l2 a. g( _( T& I0 ~
WinGetText, full_path, A
6 D' R6 _9 \" F ; Split on newline (`n)
# a0 E) ~" ]" H7 l- [9 R# [ StringSplit, word_array, full_path, `n
l2 \, J: B6 J ; Take the first element from the array6 H7 b q" W" E: U f. s
full_path = %word_array1%
* {/ H# W0 n1 }1 K5 t% k" ^ ; strip to bare address
% U" a% Y: j: t7 Q% ^. I full_path := RegExReplace(full_path, “地址: “, “”)
4 V3 w# r2 O5 p6 I ; Just in case – remove all carriage returns (`r)! x' ]! H' f# v% S2 U0 b9 q
StringReplace, full_path, full_path, `r, , all
$ a- {! f) v% ^" R. u- a% B+ L IfInString full_path, \
% F1 ^/ f( t+ Z. j' N {" f' b% ]7 W8 d
Run, cmd /K cd /D “%full_path%”
4 {/ D3 f% S' ~1 Y7 u' x }
. a; w* d+ j# @0 e, p else
y2 h7 N9 h: K4 `1 _8 c+ i- k, X {) w; s* h) @/ p( [
Run, cmd /K cd /D “C:\ ”
" }- |* m- N" y# g4 R( m8 ]# U }
w0 c1 ^# Q5 B2 ?/ l# v }7 v9 A- p2 X( F5 Y
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。 j$ M q2 I% R; g6 o
这段小代码肯能有两个你需要修改的地方
) S9 t# l& q9 Z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 }/ @- g: S7 J' q$ h" L/ O
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 k7 d0 r9 p; z; L
|