Home > Language Reference > Program Flow Functions > Disable

Disable

The Disable function disables an event or all events. The specified event will not be anymore triggered by OnAction.

Usage

Used to stop an event triggering.

Syntax

Disable(<action_identifier>)
or
Disable()

Parameters

<action_identifier>, constant, identifier of the event to disable. If not specified, all the events are disables. 

Remarks

The Compiler checks if <action_identifier> has been previously defined and returns a compilation error if not.

The Disable function can only be used in the script after the event has been activated.

The Disable function can be inserted in the Sub managing the <action_identifier>; the event is then taken out of the list of events to be managed and execution continues.

See also

Enable
OnAction
Sleep

Example

'Use of OnAction/Disable/Enable functions for clicking the OK button of an IE popup window
Sub close()
Disable(popup)
res=msgbox("Would you like to close the message box? ",4,"EXAMPLE")
if res=6 then
' if res=6, close the popup and stop the script
UseWindow("IEXPLORE.EXE|#32770|Message from webpage",topinstance())
Click(Button,"OK")
stop
endif
Enable(popup)
EndSub

OnAction popup
'OnAction triggers when the popup window appears
WinStatus(Active)
InWindowAnyInstance("IEXPLORE.EXE|#32770|Message from webpage")
DoSub close
EndAction

StartBrowser("IE", "www.wintask.com/demos",3)

UsePage("WinTask Demonstration Pages")
 ClickHTMLElement("A[INNERTEXT= 'Form']")

UsePage("Form")
'Make the popup window appear
 ClickHTMLElement("A[INNERTEXT= 'Popup window']")

sleep()
'Leave the management of the random events active.