Hi -
It's late and I can't think anymore. But I need something, and hopefully I can get a push in the right direction.
I have a dialog in a script that asks the user to decide something. The answer is yes or no.
If yes, I Goto>here, and if no, I Goto>there. Pretty routine stuff.
However, I can anticipate the situation where the user will be absent, and what I want to do is to wait for maybe 30 seconds, and if I don't get an answer, I'll make the decision for the user, dismiss the dialog, and Goto>here and have the script work as if the user had clicked YES.
I haven't a clue about how to do this. If you can think of a way, by all means, I'd love to see it in the AM.
Thanks everyone.
Self-closing dialog after timeout
Moderators: JRL, Dorian (MJT support)
Self-closing dialog after timeout
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey
Re: Self-closing dialog after timeout
OK, here's an idea:
At the beginning of the script, I launch a second script that lurks in the background and waits for the dialog to appear. It waits for X seconds, and checks to make sure the dialog is gone. If it isn't, it presses the YES button and closes.
Barring the "right" way to do it, that's what I'll do tomorrow.
At the beginning of the script, I launch a second script that lurks in the background and waits for the dialog to appear. It waits for X seconds, and checks to make sure the dialog is gone. If it isn't, it presses the YES button and closes.
Barring the "right" way to do it, that's what I'll do tomorrow.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey
Re: Self-closing dialog after timeout
Here's one way.
Code: Select all
Dialog>Dialog1
object Dialog1: TForm
BorderIcons = []
Caption = ' ?'
ClientHeight = 127
ClientWidth = 285
object Label1: TLabel
Left = 56
Top = 24
Caption = 'Are you available to make a choice?'#13#10'You have 30 seconds to decide.'
end
object MSButton1: tMSButton
Left = 54
Top = 67
Width = 75
Height = 25
Caption = 'Yes'
end
object MSButton2: tMSButton
Left = 143
Top = 67
Width = 75
Height = 25
Caption = 'No'
end
end
EndDialog>Dialog1
AddDialogHandler>Dialog1,MSButton1,OnClick,YesWasPicked
AddDialogHandler>Dialog1,MSButton2,OnClick,NoWasPicked
Show>Dialog1
Timer>ThisTime
Label>Loop
Wait>0.01
Timer>NextTime
Let>TotalTime=%NextTime%-%ThisTime%
Let>TimeAvailable={round(30-(%TotalTime%/1000))}
SetDialogProperty>Dialog1,Label1,Caption,Are you available to make a choice?%crlf%You have %TimeAvailable% seconds to decide.
If>TotalTime>30000
//Rather than picking "Yes" This script picks "Yes" or "No" randomly
Random>2,Choice
If>Choice=1
GoSub>YesWasPicked
Goto>Continue
Else
GoSub>NoWasPicked
Goto>Continue
EndIf
EndIf
If>ContinueFlag=1
Goto>Continue
EndIf
Goto>Loop
SRT>YesWasPicked
CloseDialog>Dialog1
MDL>Yes
Let>ContinueFlag=1
END>YesWasPicked
SRT>NoWasPicked
CloseDialog>Dialog1
MDL>No
Let>ContinueFlag=1
END>NoWasPicked
Label>Continue
Message>Script continues sans dialog
Wait>2
Message>GoodBye...
Wait>2
CloseWindow>Macro Scheduler Message
Exit>0
Re: Self-closing dialog after timeout
JRL,
It took me a little while to get my mind wrapped around this. In the end, I simplified your structure a lot, but the code you provided helped immensely.
Thanks for the help.
It took me a little while to get my mind wrapped around this. In the end, I simplified your structure a lot, but the code you provided helped immensely.
Thanks for the help.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey