1
votes

I am using a msgbox with timeout = 2 sec, i want to continue run the script after msgbox timeout.

for example my code is like this:

$log = 'C:\notepad.log'
Run("notepad.exe")

WinWaitActive("Untitled - Notepad")
Send("This is first line{ENTER}okay{ENTER}")
sleep (200)
msgbox (1,"debug","debug",2)

Send("This is second line{ENTER}okay{ENTER}")
sleep (200)
Send("This is third line{ENTER}okay{ENTER}")
sleep (200)
Send("!f")

send ("{DOWN}{DOWN}{ENTER}")
sleep (500)
Send($log)
sleep (1000)
Send("{ENTER}")

sleep (200)

WinClose("[CLASS:Notepad]")

*############## Here I have use "msgbox (1,"debug","debug",2)" which timeout after 2 sec & after this it wont send the command

Send("This is second line{ENTER}okay{ENTER}")
sleep (200)
Send("This is third line{ENTER}okay{ENTER}")

Please suggest how to handle this timeout.

Please note my application required to define TIMEOUT & then continue the script.

2

2 Answers

0
votes

The problem is that after your msgbox is displayed, notepad is potentially no longer the active window.

Put a WinActivate command after your msgbox line to reactivate the notepad window

WinActivate("Untitled - Notepad")
0
votes

Yeh Richard is right , you have to re-activate the the window and your could should be

$log = 'C:\notepad.log'
Run("notepad.exe")

WinWaitActive("Untitled - Notepad")
Send("This is first line{ENTER}okay{ENTER}")
sleep (200)
msgbox (1,"debug","debug",2)
WinActivate("Untitled - Notepad")


Send("This is second line{ENTER}okay{ENTER}")
sleep (200)
Send("This is third line{ENTER}okay{ENTER}")
sleep (200)
Send("!f")

send ("{DOWN}{DOWN}{ENTER}")
sleep (500)
Send($log)
sleep (1000)
Send("{ENTER}")

sleep (200)

WinClose("[CLASS:Notepad]")