automate.wbt
- Code: Select all
AddExtender("wwctl44i.dll")
;--- credentials ---
if param0 < 3
Message("Warning","You need to provide all 3 parameters (ie: username password dsn)")
Exit
else
username = param1
password = param2
dsn = param3
endif
CurrentDir = DirHome()
cmd = Environment("COMSPEC")
Run(cmd, "/c %CurrentDir%foobar.exe")
;--- login window ---
myResult = WinWaitExist("~Login", 10)
If myResult == 0
Message("Error", "Login Error")
Exit
EndIf
parentHwnd = DllHwnd('~Login')
cSetFocus(parentHwnd)
SendKeysTo("~Login", "%username%{tab}%password%{tab}%dsn%")
btnObject = cWndbyclass(parentHwnd, 'Button') ;OK
cClickButton(btnObject)
TimeDelay(1)
;--- other window ---
myResult = WinWaitExist("~Other Window", 10)
If myResult == 0
Message("Error", "Other Window Error")
Exit
EndIf
parentHwnd = DllHwnd("~Other Window")
;--- old way, works, but not as intended ---
;childObject1 = cWndbyid(parentHwnd, 5) ;ThunderRT6PictureBoxDC
;childObject2 = cWndbyid(childObject1, 10) ;update
;childObject2 = cWndbyid(childObject1, 9) ;close
;cClickButton(childObject2)
;--- better way, keepin' it simple stupid ---
SendKeysTo("~Other Window", "!u") ;sends alt-u (update) key
;--- ok/close window ---
;TimeDelay(1)
;SendKey("~") ;sends {enter} key
Exit
So far this works amazingly successful, market it! sell it! lol j/k... But towards the end, while running the program (the update sql part), it fails (the exe), and pretty much halts the automation script (the wbt file).
