Home > Language Reference > Windows Management Functions > ClickOnText


The ClickOnText function clicks on the specified text (or near it).


Mainly used to click tree items. If ClickOnText function does not recognize the text, you can use ClickOnTextOCR function.
Video: How to use ClickOnText for right clicking a text and opening a context menu. An error case is also shown in this video.


ret=ClickOnText(<text>, <offset_x>, <offset_y>, single|double, left|right)


<text>, string, text to click. 

<offset_x>,<offset_y>, integers specifying an offset distance for the click. If set to 0, the click is done on the middle of the text.

single|double, keyword indicating the click action.

left|right, keyword, type of mouse button to click.

Return value

ret, optional numeric return value. If the specified text has been successfully clicked within 30 seconds (this default value can be changed using #ActionTimeout), the function returns 0. If the text is not found, the return value is 1 (see Windows Management Functions Error Codes for the other possible return values).

Script execution does NOT stop in case of an error while executing ClickOnText.


Generate the ClickOnText syntax using its wizard: in the Language pane of the WinTask Editor, double-click the ClickOnText function name to start the wizard (if the Language pane is not displayed, press F4 or select Insert/Statement menu.)

See also



'Launch notepad
'Type some text
UseWindow("NOTEPAD.EXE|Edit|Untitled - Notepad|1",1)
 SendKeys("ClickOnText Test")
UseWindow( "NOTEPAD.EXE|Edit|Untitled - Notepad|1",1 )
'Click in the middle of Test text
'Result seen for 3 seconds
 Pause 3
'Click right a bit down and left from Test text, it opens a context menu