Micro Focus QTP (UFT) Forums
How can i check all the buttons are enabled or not using programming ? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: How can i check all the buttons are enabled or not using programming ? (/Thread-How-can-i-check-all-the-buttons-are-enabled-or-not-using-programming)



How can i check all the buttons are enabled or not using programming ? - njnirmal - 07-16-2009

HI ..
I am using a window based application .? NOw i want to check all the buttons whether all the buttons are enabled or not ? SO How can i check ?
Plseae send me script so that all the buttons are checked in a one time whether they are enabled or disabled ?


RE: How can i check all the buttons are enabled or not using programming ? - supputuri - 07-16-2009

Hi njnirmal,

Please check the below LOC. I have taken the Flight Reservation window.
'*******************************************************************
'*******************************************************************
Code:
Set chld=Description.Create
chld("micclass").value = "WinButton"
Set chldcln = Window("Flight Reservation").ChildObjects(chld)
msgbox chldcln.count
Flag = True
DisBut = 0
For num = 0 to chldcln.count-1
    'To highlight the button in the application
    chldcln(num).highlight
    If chldcln(num).GetRoProperty("enabled") <> True Then
        Flag = False
        DisBut = DisBut+1
    End If
Next
msgbox Flag
If Flag = True Then
    msgbox "All the Buttons in the window are enabled."
Else
    msgbox "In the Window" & "''" & DisBut & "'' buttons out of ''"& chldcln.count &"'' are disabled."
End If
'################
Object Release
'################
Set chld = Nothing
Set chldcln = Nothing
'*******************************************************************
'*******************************************************************

Please let me know if you need any more info.


RE: How can i check all the buttons are enabled or not using programming ? - QTPgrd - 07-16-2009

Hi Guys,

The below script would also get you the result, but may not be compatible with all windows application as Iam filtering with the 'value' of Windows Style (which would vary from application to application"). Anyhow here it is............

=======================================
Code:
SystemUtil.Run "calc","","C:\Documents and Settings\Administrator",""

Set obj_AllButtonDesc = Description.Create
obj_AllButtonDesc("Class Name").value = "WinButton"
Set AllButtons = Window("Calculator").ChildObjects(obj_AllButtonDesc)
msgbox AllButtons.count

Set obj_DisButtonDesc = Description.Create
obj_DisButtonDesc("windowstyle").value = "1476395019"
Set DisabledButtons = Window("Calculator").ChildObjects(obj_DisButtonDesc)

msgbox DisabledButtons.count

If  AllButtons.count = DisabledButtons.count Then
    Msgbox( "All the buttons in your application are  currently enabled")
    Else
    Msgbox( "Few buttons in your application are currently disabled")
End If
=======================================


RE: How can i check all the buttons are enabled or not using programming ? - QTPian - 07-16-2009

Hi QTPgrd,

I belive the "windowstyle" property will differ from application to application. The script provided by QTPKing is correct.

Please let me know of your comments.

Thanks,