jdelaney Posted January 6, 2016 Posted January 6, 2016 I'm trying to setup a function that will return the text or checked state of a button...when the button is a checkbox or a radio, return the "ischecked", else return the button's text...I'm not seeing anything that would return the style. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
careca Posted January 6, 2016 Posted January 6, 2016 (edited) https://www.autoitscript.com/autoit3/docs/functions/GUIGetStyle.htmWhat do you think?EDIT: wait, you mean the style of the button? Edited January 6, 2016 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
jdelaney Posted January 6, 2016 Author Posted January 6, 2016 (edited) Yes, the style of the button...I attempted to pass the handle of the control to that function, and no good...returns 0:Here is a slightly modified help file function...:#include <GUIConstantsEx.au3> #include <GuiButton.au3> #include <WindowsConstants.au3> _Main() Func _Main() Local $btn, $btn2 $h = GUICreate("Buttons", 400, 400) GUISetState() $btn = GUICtrlCreateButton("Button1", 10, 10, 90, 50) $btn2 = GUICtrlCreateButton("Button2", 10, 70, 90, 50) $btn3 = GUICtrlCreateButton("Button3", 10, 130, 90, 50) MsgBox(4096, "Information", "Setting Button Style") _GUICtrlButton_SetStyle($btn, $BS_AUTORADIOBUTTON) _GUICtrlButton_SetStyle($btn2, $BS_AUTOCHECKBOX) $hB1 = ControlGetHandle($h,"",$btn) $hB2 = ControlGetHandle($h,"",$btn2) $hB3 = ControlGetHandle($h,"",$btn3) $sStyleB1 = GUIGetStyle($hB1) $sStyleB2 = GUIGetStyle($hB2) $sStyleB3 = GUIGetStyle($hB3) ConsoleWrite($hB1 & " " & $sStyleB1 & @CRLF) ConsoleWrite($hB2 & " " & $sStyleB2 & @CRLF) ConsoleWrite($hB3 & " " & $sStyleB3 & @CRLF) EndFunc ;==>_Main While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Edited January 6, 2016 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Moderators Melba23 Posted January 6, 2016 Moderators Posted January 6, 2016 jdelaney,when the button is a checkbox or a radio, return the "ischecked", else return the button's textThis script will do that:expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cRadio_1 = GUICtrlCreateRadio(" Radio control 1", 10, 10, 200, 20) $cRadio_2 = GUICtrlCreateRadio(" Radio control 2", 10, 40, 200, 20) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cRadio_1, $cRadio_2 $sMsg = "" If GUICtrlRead($cRadio_1) = $GUI_CHECKED Then $sMsg &= "State: Radio 1 checked" Else $sMsg &= "Text: " & GUICtrlRead($cRadio_1, 1) EndIf $sMsg &= @CRLF If GUICtrlRead($cRadio_2) = $GUI_CHECKED Then $sMsg &= "State: Radio 2 checked" Else $sMsg &= "Text: " & GUICtrlRead($cRadio_2, 1) EndIf MsgBox($MB_SYSTEMMODAL, "Result", $sMsg) EndSwitch WEndIf you actually want the style, then you need to call the API as explained in the Setting Styles tutorial in the Wiki:#include <Constants.au3> ; Do not forget these include files! #include <WinAPI.au3> $iStyle = _WinAPI_GetWindowLong(GUICtrlGetHandle($cControlID), $GWL_STYLE) $iExStyle = _WinAPI_GetWindowLong(GUICtrlGetHandle($cControlID), $GWL_EXSTYLE)M23 careca 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
jdelaney Posted January 6, 2016 Author Posted January 6, 2016 Thanks Melba, I posted that just as an example, I'm working with a 3rd party application so the Gui* funcs won't do it for me...I'll look into _WinAPI_GetWindowLong. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
jdelaney Posted January 6, 2016 Author Posted January 6, 2016 (edited) Got it...thanks again Melba...just need to add a check if there is a BitAND of either $BS_RADIOBUTTON or $BS_AUTORADIOBUTTON...if not, it's a button.:expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiButton.au3> #include <WindowsConstants.au3> _Main() Func _Main() Local $btn, $btn2 $h = GUICreate("Buttons", 400, 400) GUISetState() $btn = GUICtrlCreateButton("Button1", 10, 10, 90, 50) $btn2 = GUICtrlCreateButton("Button2", 10, 70, 90, 50) $btn3 = GUICtrlCreateButton("Button3", 10, 130, 90, 50) _GUICtrlButton_SetStyle($btn, $BS_AUTORADIOBUTTON) _GUICtrlButton_SetStyle($btn2, $BS_AUTOCHECKBOX) $hB1 = ControlGetHandle($h,"",$btn) $hB2 = ControlGetHandle($h,"",$btn2) $hB3 = ControlGetHandle($h,"",$btn3) $sStyleB1 = _WinAPI_GetWindowLong(GUICtrlGetHandle($btn), $GWL_STYLE) $sStyleB2 = _WinAPI_GetWindowLong(GUICtrlGetHandle($btn2), $GWL_STYLE) $sStyleB3 = _WinAPI_GetWindowLong(GUICtrlGetHandle($btn3), $GWL_STYLE) If BitAND($sStyleB1,$BS_CHECKBOX)=$BS_CHECKBOX Or BitAND($sStyleB1,$BS_AUTOCHECKBOX)=$BS_AUTOCHECKBOX Then ConsoleWrite("Button 1 is a checkbox" & @CRLF) ElseIf BitAND($sStyleB1,$BS_RADIOBUTTON)=$BS_RADIOBUTTON Or BitAND($sStyleB1,$BS_AUTORADIOBUTTON)=$BS_AUTORADIOBUTTON Then ConsoleWrite("Button 1 is a radio" & @CRLF) Else ConsoleWrite("Button 1 is only a button" & @CRLF) EndIf If BitAND($sStyleB2,$BS_CHECKBOX)=$BS_CHECKBOX Or BitAND($sStyleB2,$BS_AUTOCHECKBOX)=$BS_AUTOCHECKBOX Then ConsoleWrite("Button 2 is a checkbox" & @CRLF) ElseIf BitAND($sStyleB2,$BS_RADIOBUTTON)=$BS_RADIOBUTTON Or BitAND($sStyleB2,$BS_AUTORADIOBUTTON)=$BS_AUTORADIOBUTTON Then ConsoleWrite("Button 2 is a radio" & @CRLF) Else ConsoleWrite("Button 2 is only a button" & @CRLF) EndIf If BitAND($sStyleB3,$BS_CHECKBOX)=$BS_CHECKBOX Or BitAND($sStyleB3,$BS_AUTOCHECKBOX)=$BS_AUTOCHECKBOX Then ConsoleWrite("Button 3 is a checkbox" & @CRLF) ElseIf BitAND($sStyleB3,$BS_RADIOBUTTON)=$BS_RADIOBUTTON Or BitAND($sStyleB3,$BS_AUTORADIOBUTTON)=$BS_AUTORADIOBUTTON Then ConsoleWrite("Button 3 is a radio" & @CRLF) Else ConsoleWrite("Button 3 is only a button" & @CRLF) EndIf EndFunc ;==>_Main While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Edited January 6, 2016 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
jdelaney Posted January 7, 2016 Author Posted January 7, 2016 Well, the above works on the simple controls created by autoit, but not for my 3rd party app.Is there a way to get the actual size of the button within the controlgetpos area? IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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