此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% Z; ^2 h+ k- d( d' M' s- c 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 `2 V+ X+ ~( l x2 o7 r, y 方式一:
E0 P- O$ Y' e( n: |3 | 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,) d# r0 m0 A4 t8 |
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ }+ |$ \) h/ b& l/ X7 m HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。# f1 R% Z# J( J5 u s0 \8 Z
方式二:
* X0 F3 C# D8 P# ~" O/ H 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- [8 G$ j' s c SetTitleMatchMode RegEx
" G/ y( P/ w$ {% I b return6 \2 D% z/ g' Y( I$ d3 N
; Stuff to do when Windows Explorer is open
7 ^) s, ]% ^& n; O9 c ;* ]( `" J R$ q8 o/ K& Z: I6 \' ?
#IfWinActive ahk_class ExploreWClass|CabinetWClass
% V0 s+ ]' g; u ; open ‘cmd’ in the current directory# c$ j; d& g9 l q: J
;
[3 q5 }1 m% {$ p #c::
0 n) L3 {* @( \8 w; | OpenCmdInCurrent(). `. s9 M8 h! W2 X9 B3 R* `. c* U1 r
return; P0 @2 |' f# t; @) s
#IfWinActive1 p/ j j! |# @9 `3 ]
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 B4 D2 M5 B, _: i1 S) z+ x. V3 H
; Note: expecting to be run when the active window is Explorer.
% U7 [) I% {( A7 Y _ ;
' q( c4 ^( B n* G OpenCmdInCurrent()
3 M, ^# I* r% R" }7 c: O% h {8 ]1 B) L; E4 a/ z
; This is required to get the full path of the file from the address bar
4 n2 O& c' x) F5 x8 d0 T) @- x WinGetText, full_path, A
) k. T8 j. d+ |* t2 b ; Split on newline (`n)
% ~2 O" r. @( D* w9 B StringSplit, word_array, full_path, `n
8 o7 @/ x( i7 i8 u2 S8 L1 E4 q$ ` ; Take the first element from the array
+ |! c8 d* l% x9 Q( h4 ]% W full_path = %word_array1%" Q3 H K" x, K, D9 C( T
; strip to bare address. {% t0 x5 ~& G# d5 K1 e" j
full_path := RegExReplace(full_path, “地址: “, “”) p- S+ E- R/ E/ \% Y/ o1 O8 u
; Just in case – remove all carriage returns (`r)5 P) Q* w; w, i+ }& p3 y( v
StringReplace, full_path, full_path, `r, , all
2 _; `2 b1 w j- O IfInString full_path, \& H" I2 h/ F0 M' M8 b- l# q+ N
{
m4 v: Q- |+ |6 d9 h* f3 B8 E Run, cmd /K cd /D “%full_path%”
9 ~& s' e# a! \, e3 s }- b/ c5 h8 Y ]% `$ [$ @, U/ a( r
else
, q) X3 G0 N4 H- O' {- M: a- U6 e {9 o( \: M2 \" O) i* z5 F: h5 P
Run, cmd /K cd /D “C:\ ”
' f5 Q4 S7 B7 O% e0 _ }
# k& r/ r. R5 J% ` }
2 E d7 R% T) |2 i6 C) c$ p 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 \2 o) ?4 V8 d7 t) f 这段小代码肯能有两个你需要修改的地方3 ]- J7 f6 f8 A8 s, b3 }
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- [9 _3 |! ]' t7 ]% A2 ~ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “% W& \' m! w$ b! g/ P6 s# e$ r8 ?
|