如何使用AutoIT识别calc中的按钮

时间:2015-04-05 07:47:05

标签: autoit

我已经看过这个示例代码..

Run("Calc.exe")
WinWaitActive("Calculator")
WinActive("Calculator")
Sleeper()
ControlClick("Calculator", "", "Button5", "Left") ;Click the number 1
Sleeper()
ControlClick("Calculator", "", "Button11", "Left") ;Click the number 2
Sleeper()
ControlClick("Calculator", "", "Button23", "Left") ;Click the + button
Sleeper()
ControlClick("Calculator", "", "Button16", "Left") ;Click the number 3
Sleeper()
ControlClick("Calculator", "", "Button28", "Left") ;Click the Equal button
Func Sleeper()
   Sleep(1000)
EndFunc

前几行确定。但是其他行按钮5,按钮11等,如果我们从左侧计算它正在变得正确..

相反,是否有任何命令发送(25),发送(+),发送(20)发送(" =")...

1 个答案:

答案 0 :(得分:1)

这就是你要找的东西:

Run("Calc.exe")
WinWaitActive("Calculator")
;this way you dont have to write separate statements for each button
ControlSend("Calculator", "", "#327701", "12345678")
;but you will have to write the statement for selecting operator separately
ControlClick("Calculator", "", "Button23", "Left")
ControlSend("Calculator", "", "#327701", "356")
ControlClick("Calculator", "", "Button28", "Left")

编辑:  #327701是:

enter image description here