pilot Posted September 24, 2011 Posted September 24, 2011 I would like to know whether i can decide my selection of radio button before reading the text of the radio button. For Example every software installation has installation options like Typical and Custom. I would like to confirm the respective text of the radio button before my selecting the option. Hope this is possible in AutoIt. I have gone through many examples, but many of the examples were created with AutoIt UI and they used the handle of a the particular control to read the text. But they are getting the handle while creating the control. I'm unable to get a handle of an existing control of 3rd party GUI. #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $menu1, $n1, $n2, $msg, $menustate, $menutext GUICreate("My GUICtrlRead") ; will create a dialog box that when displayed is centered $menu1 = GUICtrlCreateMenu("File") $n1 = GUICtrlCreateList("", 10, 10, -1, 100) GUICtrlSetData(-1, "item1|item2|item3", "item2") $n2 = GUICtrlCreateButton("Read", 10, 110, 50) GUICtrlSetState(-1, $GUI_FOCUS) ; the focus is on this button GUISetState() ; will display an empty dialog box ; Run the GUI until the dialog is closed Do $msg = GUIGetMsg() If $msg = $n2 Then MsgBox(0, "Selected listbox entry", GUICtrlRead($n1)) ; display the selected listbox entry $menustate = GUICtrlRead($menu1) ; return the state of the menu item $menutext = GUICtrlRead($menu1, 1) ; return the text of the menu item MsgBox(0, "State and text of the menuitem", "state:" & $menustate & @LF & "text:" & $menutext) EndIf Until $msg = $GUI_EVENT_CLOSE EndFunc ;==>Example Here I don't know how to get the $n1 value if I didn't created the GUI, that already exist. So I may not have the value of $n1. If my post is unclear pls let me know so that I can make it more clear on that part. Any help is appreciated. Thanks in Advance.
martin Posted September 24, 2011 Posted September 24, 2011 See what the AutoItInfo tool can tell you about the handles for the radio controls in the third party GUI. If that works then you can do something in AutoIt to get the information you want. Also, look up ControlCommand which might be all you need, but your explanation of what you want to do is not clear to me. If there is a radio button I expect that the text for that button will always be the same but maybe what you want to know is which radio button is checked. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
pilot Posted September 26, 2011 Author Posted September 26, 2011 Thanks for your help Martin. I have tried third party handle with no success. Below is my code will be called in front of the GUI Example() Func Example() Local $handle, $msg $handle = ControlGetHandle("[CLASS:TWizardForm]", "", "TNewNotebookPage2") $checkState = ControlCommand("[CLASS:TWizardForm]", "", "TNewNotebookPage2","IsChecked", "") $getText = ControlGetText("[CLASS:TWizardForm]", "", "TNewNotebookPage2") ; GUICtrlSetState(-1, $GUI_FOCUS) GUISetState() ; will display an empty dialog box ; Run the GUI until the dialog is closed MsgBox(1, "Status", $checkState) MsgBox(0, "Status 2", $getText) MsgBox(0, "State", StringFormat("GUICtrlRead=%d\nGUICtrlGetState=%d", GUICtrlRead($handle), GUICtrlGetState($handle))) EndFunc Regarding ControlCommand, I have checked the radio button is selected or not. It always returns the $checkState value as 0 irrespective of the state of the button.As you said I need the text of the radio button that is selected. So that I can make use of IF statement to expect the next GUI in the installation. Still I'm having problem in getting the text of the selected button. I'm still not sure of the above code that I'm missing something important. Below is the control I'm getting for that GUI>>>> Window <<<<Title: Setup - Installing XYZ SoftwareClass: TWizardFormPosition: 468, 243Size: 503, 385Style: 0x16CA0000ExStyle: 0x00000100Handle: 0x0003039E Following image is the GUI I'm discussing.Uploaded with ImageShack.us >>>> Control <<<<Class: TNewNotebookPageInstance: 2ClassnameNN: TNewNotebookPage2Name: Advanced (Class): [CLASS:TNewNotebookPage; INSTANCE:2]ID: 131946
bogQ Posted September 26, 2011 Posted September 26, 2011 (edited) did you try ID: 131946 ControlCommand ( "title", "text", controlID or [CLASS:TNewNotebookPage; INSTANCE:2] instead controlID? note that you need to test 2 radios with diffrent ID, not just 1 Edited September 26, 2011 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
pilot Posted September 27, 2011 Author Posted September 27, 2011 Thanks a lot bogQ, your last line did the magic. Actually I have mistakenly taken the control of whole text instead of particularly focusing on radio buttons. I have changed the code as below Example() Func Example() Local $handle, $msg $handle = ControlGetHandle("[CLASS:TWizardForm]", "", "TRadioButton1") $checkState = ControlCommand("[CLASS:TWizardForm]", "", "TRadioButton1","IsChecked", "") $getText = ControlGetText("[CLASS:TWizardForm]", "", "TRadioButton1") ; GUICtrlSetState(-1, $GUI_FOCUS) GUISetState() ; will display an empty dialog box ; Run the GUI until the dialog is closed MsgBox(1, "Status", $checkState) MsgBox(0, "Status 2", $getText) MsgBox(0, "State", StringFormat("GUICtrlRead=%d\nGUICtrlGetState=%d", GUICtrlRead($handle), GUICtrlGetState($handle))) EndFunc All worked perfectly and I started a day with success. Thank You, once again.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now