Home > Language Reference > Windows Management Functions > Click

Click

The Click function clicks the speficied button, checkbox, radio button or tab.

Usage

Used to automate a click on a Windows control.  The Click function is object-oriented (compared to ClickMouse function) and will replay correctly even if the control has been moved. Only standard Windows controls work with Click function. If the control to click on is not properly recognized, you can still automate the click by using the keyboard shortcut for the control (with SendKeys function) or by using ClickOnText function or by using ClickOnTextOCR function. If the button is just a bitmap without any text, use ClickMouse function. If the application under automation supports the UI Automation framework and if you use the 64 bit automation software, you can automate a click with the ClickUIA function

Syntax

ret=Click(button|check|radio|tab, <control_text> [, on|off])

Parameters

button|check|radio|tab, keyword, type of the control.

<control_text>, string, text of the control.

on|off, optional keyword for checking/unchecking the control. 

Return value

ret, optional numeric return value. If the specified control has been successfully clicked within 30 seconds (this default value can be changed using #ActionTimeout, the function returns 0. If the function fails, the return value is a nonzero value (see Window Functions Error Codes).

Remarks

Click function only works with standard Windows controls.

If the application under automation supports the UI Automation framework and if you use the 64 bit automation software, you can automate a click with the ClickUIA function.

See also

ClickMouse
ClickOnText
ClickOnTextOCR
ClickUIA

Example

'Different uses of the Click function.
'Launch directly Control Panel/Date and Time
shell("control.exe timedate.cpl")
UseWindow("RUNDLL32.EXE|#32770|Date and Time",1)
'Click the Internet Time Tab
 Click(Tab,"Internet Time")
UseWindow("RUNDLL32.EXE|#32770|Internet Time",1)
'Click Change settings button
 Click(Button,"&Change settings...")
UseWindow("RUNDLL32.EXE|#32770|Internet Time Settings",1)
'Click Synchronize with an Internet time server checkbox - OFF option forces to OFF
 Click(Check,"&Synchronize with an Internet time server",OFF)
'Click Cancel button
 Click(Button,"Cancel")
'On the Date and Time screen, click Cancel button
UseWindow("RUNDLL32.EXE|#32770|Date and Time",1)
 Click(Button,"Cancel")