CheckedW

Windows management function.

The CheckedW function retrieves the state of the specified check box or radio button. Not available in WinTask Lite.

Syntax

ret=CheckedW(<window_name> [,<item_name>])

 

Parameters

<window_name>, window name of the check box or radio button. If all the buttons are within a unique window, then <window_name> is the name of this unique window, and you specify <item_name>.

<item_name>, string, optional parameter, text of the check box or radio button to check ; it has to be used if the check box or radio button is not a window by itself, and so window_name does not specify uniquely the item to test. WinTask is case sensitive for finding the <item_name> at replay, so a good way to be sure to type it properly, you can use Recording mode for checking the item, it will generate a ChooseItem statement with the exact <item_name> and you can then paste that name in the CheckedW statement.

 

Return value

Ret, numeric return code. When the specified check box or radio button is checked, the function returns 1 ; otherwise it returns 0. If the item to test is not recognized as a check box or radio button, or the window name does not exist, the return code is -1.

 

Remarks

When you have to use the <item_name> parameter, it's easy to make a spelling error ; to avoid that, use Recording mode and check/uncheck the checkbox item that you want to test - stop Recording mode, two lines are generated, a UseWindow that you have to delete, and a ChooseItem which gives you the exact <item_name>. Then you can write manually the CheckedW line where you use Spy for finding the <window_name> and you copy/paste the <item_name>. At the end delete the ChooseItem line.

CheckedW does not include a synchronization mechanism, so you have to wait that the window <window_name> is really displayed before running the CheckedW.

As a check box or a radio button can have three states (Checked, Enabled, Hidden), the table below gives the return code of the three WinTask functions which deal with this kind of window, ExistW, EnabledW and CheckedW :

Checked

Enabled

Hidden

ExistW

EnabledW

CheckedW

0

0

0

1

0

0

0

0

1

0

0

-1

0

1

0

1

1

0

0

1

1

0

0

-1

1

0

0

1

0

1

1

0

1

0

0

-1

1

1

0

1

1

1

1

1

1

0

0

-1

Example code

This example tests a checkbox status in the window Find of WordPad.

 

Shell("wordpad",1)

UseWindow("WORDPAD.EXE|RICHEDIT50W|Document - WordPad|1",1)

SendKeys("Hello")

 

UseWindow("WORDPAD.EXE|WordPadClass|Document - WordPad",1)

ChooseMenu(Normal,"&Edit|&Find... Ctrl+F")

 

'Is Match case checkbox checked ?

ret=CheckedW("WORDPAD.EXE|Button|Match &case")

msgbox(ret)

 

This example tests a checkbox status in the window Internet options, Advanced Tab of Internet Explorer.

 

StartBrowser("IE")

UseWindow("IEXPLORE.EXE|ReBarWindow32|about:blank - Microsoft Internet Explorer|1",1)

ChooseItem(ToolBar, "|4", "&Tools", dropdown, left )

 

UseWindow("IEXPLORE.EXE|IEFrame|about:blank - Microsoft Internet Explorer",1)

ChooseMenu(Context,"Internet &Options...")

 

UseWindow("IEXPLORE.EXE|#32770|Internet Options",1)

Click(Tab,"Advanced")

'As all the checkboxes are within the same window, we specify the checkbox text in CheckedW function.
ret=CheckedW("IEXPLORE.EXE|SysTreeView32|Settings","Disable script debugging")

msgbox(ret)