Created
April 11, 2016 16:26
-
-
Save erajanraja24/f5c20991270fc974a99fcfbfbf9c3f01 to your computer and use it in GitHub Desktop.
Autoit in Excel VBA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub autoit() | |
'Create and initialize an object | |
Dim autoit As AutoItX3 | |
Set autoit = New AutoItX3 | |
'Check autoit installation | |
If IsNull(autoit) Then | |
MsgBox "Autoit Is Not installed on your machine", vbCritical + vbOKOnly, "Verify" | |
Exit Sub | |
End If | |
'Launch Calculator | |
autoit.Run "calc.exe", "C:\Windows\System32" | |
autoit.Sleep "2000" | |
If autoit.WinExists("Calculator", "") Then | |
'Click Button "1" and wait for one Second | |
autoit.ControlClick "Calculator", "", "131" | |
autoit.Sleep "1000" | |
'Click Button "+" and wait for one Second | |
autoit.ControlClick "Calculator", "", "93" | |
autoit.Sleep "1000" | |
'Click Button "2" and wait for one Second | |
autoit.ControlClick "Calculator", "", "132" | |
autoit.Sleep "1000" | |
'Click Button "=" and wait for one Second | |
autoit.ControlClick "Calculator", "", "121" | |
autoit.Sleep "1000" | |
'Close the calculator | |
autoit.WinClose "Calculator", "" | |
End If | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment