Jump to content

Recommended Posts

Posted

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.
Posted (edited)

https://www.autoitscript.com/autoit3/docs/functions/GUIGetStyle.htm

What do you think?

EDIT: wait, you mean the style of the button?

Edited 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

Posted (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 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
Posted

jdelaney,

when the button is a checkbox or a radio, return the "ischecked", else return the button's text

This script will do that:

#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



WEnd

If 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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (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.:

#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 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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...