Popup window while running a task
When you run a task, a window/error message can popup ; WinTask script must be able to do an action on this popup window and continue, and if the popup window does not appear, the script just continues on with the task. The function ExistW plus a condition do easily that. The script below with Wordpad clicks Yes button in the popup window asking if the file has to be replaced, popup window which appears only if the file to save already exists.
Shell("wordpad",1)
UseWindow("WORDPAD.EXE|RichEdit20W|Document - WordPad|1",1)SendKeys("Hello")
UseWindow("WORDPAD.EXE|WordPadClass|Document - WordPad",1)
ChooseMenu(Normal,"&File|Save &As...")
'In Save as window, we type the filename and click Save button
UseWindow("WORDPAD.EXE|Edit|Save As|1",1)
SendKeys("c:\test wordpad")
UseWindow("WORDPAD.EXE|#32770|Save As",1)
Click(Button,"&Save")
pause 1'If the file already exists, a new window appears and we click Yes button.
If existW("WORDPAD.EXE|Button|&Yes")=1 thenUseWindow("WORDPAD.EXE|#32770|Save As",1)
Click(Button,"&Yes")
Endif
CloseWindow("WORDPAD.EXE|WordPadClass|test wordpad.rtf - WordPad",1)
If you want to do an action when a specific window can be displayed at an erratic time during the process, use OnAction (not available in WinTask Lite).