变量51Testing软件测试网Y&wF3|}4?
必须以$开头,只能包含数字、字母或下划线
+Dp|@&cb
C9F\-wA0$var1
w;vj.kv L8`3Tq#i0变量的声明
N,u!e"J-U'N&_6F0dim $var151Testing软件测试网f6H#|cI(N
使用dim、local或global,可以不用声明直接使用51Testing软件测试网`2a]`0_%l2^ l
常量51Testing软件测试网3qO8U"eEY?
Const $const1 = 1, $const2=1251Testing软件测试网#{mr h0QQ
MG
可以使用enum关键字声明常量,这个好像等比数列或者等差数列一样
!z"kI {\y-H1t0Enum $const1 , $const2, $const3 ; 0,1,2 const1默认为151Testing软件测试网#qm6S5}&LWxb]}A
Enum $const1 = 1, $const2, $const3 ; 1, 2, 3
4X Qr+C\ l0Enum STEP 2 $incr0, $incr2, $incr4 ; 0, 2, 4
w$MoWN9h)W0Enum STEP *2 $mult1, $mult2, $mult4 ; 1, 2, 4
T
W)e}S,H0[scope] Enum [Step <stepval>] <constantlist>51Testing软件测试网:O(I"Bl}:^
默认第一个常量为0.顺序加151Testing软件测试网R4ZAuk%zN*R r
当step 为*时,第一个默认为1
(N.O9b:C
M:G/b)FZ+U0
(M'G9gd#@DiJ#T0操作符:支持+= -= *= /= &=操作51Testing软件测试网4CJ o$K/V0g(v
51Testing软件测试网"cJ{$\6p!P
t?[
语句,比起vbs多了个switch case51Testing软件测试网b!De{0F)LV
f`1T:|
而且有个类似于qtp的with语句51Testing软件测试网fR2PR~
51Testing软件测试网_Y]2S8b(T.{
用户定义函数51Testing软件测试网WX"s5FI4kH0D:L _
func funcname
#?5b6T1q%_6H#V0return51Testing软件测试网R#J
z
^!o^!P2l0BL
endfunc
kG)O{8sb0 51Testing软件测试网(m.cT,Wt O3CC,u8u
注释:使用分号;
,J]F;O1]Kcc0多行注释
+g2Z1c+q p%}0#comments-start51Testing软件测试网;n5dh;^+txF{l
...
~0`5z Z@Y4j0...
M6I
F
D$u0#comments-end
&C%O;Gd};h?C0b0或
&_Z*?*i^'hF0#cs
)V+~+c3dA0……
,q1?f^#]!_Z\4^u0#ce51Testing软件测试网*xR/x|o
Rb lA
vbs调用auit组件,安装完成autoit,就可以调用了
#p8@ Mb
xJRuau0
];jGlad;q#F,E0Set AutoIt = WScript.CreateObject("AutoItX3.Control")51Testing软件测试网DQ[Nm(uN"oC
oautoit.run ("notepad")
Ic3\.cJ @ E(`X0oautoit.winwaitactive "无标题 - 记事本"
"[PR5P^ Q`0oautoit.controlsend "无标题 - 记事本","","edit1","test"
a%jP"Ot/wT1M%q/Y6T0
;W5U+P5VB;X"} g0 51Testing软件测试网.h?"Hg)L
遗憾的是,autoit对中文识别貌似不是很好,winwaitactive等方法识别不了“无标题 - 记事本"这样的中文标题
ZCh:r|N k0还好,可以利用classname属性来识别控件,如51Testing软件测试网#U*GVR!JK*A'L5{
Set AutoIt = WScript.CreateObject("AutoItX3.Control") ;创建对象
~3aN2\
{d0oautoit.run ("notepad") ;运行记事本
K`AJZmtqb0 51Testing软件测试网gWF"q!d%Y#e
oautoit.winwaitactive ("[CLASS:Notepad]") ;激活记事本窗口51Testing软件测试网-h"F6|
|r7J
oautoit.controlsend "[CLASS:Notepad]","","Edit1","test" ;发送字符串到记事本
'GZ1I{"m!t
Rh0oautoit.winclose "[CLASS:Notepad]" ;关闭记事本
hs v;U"w"S0oautoit.controlclick "[CLASS:#32770]","","Button2" ;单击否按钮51Testing软件测试网_G IhLFY
d`