Forum Discussion
Dmitry_Nikolaev
13 years agoStaff
Hi Suvidh,
Here is another solution that does not require debug information for the tested application.
To find out whether a specific item is checked, you need to save images of the checked and/or unchecked boxes to the Stores | Regions collection and compare an item's actual image with the saved image. Here is the script routine that saves an image of the checked box to the checkBox_Checked item of the Stores | Regions collection. Correct the values of the checkedBoxCaption and listBox variables in this routine to make them valid for your application. The checkedBoxCaption variable must contain the caption of a checked item.
Once the image is saved, you do not need to run this routine anymore. You can use the below isListBoxItemChecked routine in order to find out whether a specific item is checked.
To check a corresponding item of a list box, you need to simulate a click to the check box area of the needed item. The following CheckItem routine demonstrates this:
Here is a sample script demonstrating how to use this approach. The script works with the CheckListBox sample application available on the Codejock web site.
Here is another solution that does not require debug information for the tested application.
To find out whether a specific item is checked, you need to save images of the checked and/or unchecked boxes to the Stores | Regions collection and compare an item's actual image with the saved image. Here is the script routine that saves an image of the checked box to the checkBox_Checked item of the Stores | Regions collection. Correct the values of the checkedBoxCaption and listBox variables in this routine to make them valid for your application. The checkedBoxCaption variable must contain the caption of a checked item.
Sub SaveCheckBoxCheckedImage
checkedBoxCaption = "Menu Bar"
Set listBox = Sys.Process("CheckListBox").Window("#32770", "Codejock Check List Box Sample").Window("ListBox")
Set bounds = listBox.wItemBounds(checkedBoxCaption)
Set checkedBoxImg = listBox.Picture(bounds.Left, bounds.Top, bounds.Height, bounds.Height)
Call Regions.AddPicture(checkedBoxImg, "checkBox_Checked")
End Sub
Once the image is saved, you do not need to run this routine anymore. You can use the below isListBoxItemChecked routine in order to find out whether a specific item is checked.
Function isListBoxItemChecked(listBox, itemCaption)
Set bounds = listBox.wItemBounds(itemCaption)
Set checkBoxImg = listBox.Picture(bounds.Left, bounds.Top, bounds.Height, bounds.Height)
isListBoxItemChecked = Regions.Compare("checkBox_Checked", checkBoxImg, True, False, False, 0, lmNone)
End Function
To check a corresponding item of a list box, you need to simulate a click to the check box area of the needed item. The following CheckItem routine demonstrates this:
Sub CheckItem(listBox, itemCaption, check)
If Not (check = isListBoxItemChecked(listBox, itemCaption)) Then
Set bounds = listBox.wItemBounds(itemCaption)
Call listBox.ClickItemXY(itemCaption, bounds.Height / 2, bounds.Height / 2)
End If
End Sub
Here is a sample script demonstrating how to use this approach. The script works with the CheckListBox sample application available on the Codejock web site.
Sub Test1
Set listBox = Sys.Process("CheckListBox").Window("#32770", "Codejock Check List Box Sample").Window("ListBox")
' Check "Standard"
Call CheckItem(listBox, "Standard", True)
' Uncheck "Advanced"
Call CheckItem(listBox, "Advanced", False)
End Sub
Related Content
- 11 months agoIrinaManea
- 6 months agonado
Recent Discussions
- 18 hours agoMW_Didata