Jump to content
Sign in to follow this  

read value

Recommended Posts


Hi, is there a way for me to get the value of my slider? I tried using GUICtrlRead() but it's not working for me. I don't know if I'm in the wrong or not. I'm trying to get the value of the slider then change it to another value. Any help would be appreciated.

Here's my code:

Func Slider()
    ;User Input
;~  Local $input = InputBox("Brightness", "Set Brightness to:", "")
    ;Start automation
    Local $hWnd = WinWait("[Class:Shell_TrayWnd]", "", "[CLASS:Button; INSTANCE:1]")
    ControlClick($hWnd, "", "[CLASS:Button; INSTANCE:1]") ;open the start menu
    Send("Display Settings", 10) ;Type the Display Settings in the start menu

    AutoItSetOption("MustDeclareVars", 1)

    Local $oP2 = _UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Settings;controltype:=UIA_WindowControlTypeId;class:=ApplicationFrameWindow", $treescope_children)
    _UIA_Action($oP2, "setfocus")
    Local $oP1 = _UIA_getObjectByFindAll($oP2, "Title:=Settings;controltype:=UIA_WindowControlTypeId;class:=Windows.UI.Core.CoreWindow", $treescope_children)
    _UIA_Action($oP1, "setfocus")
    Local $oP0 = _UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_PaneControlTypeId;class:=ScrollViewer", $treescope_children)
;~ First find the object in the parent before you can do something
;~$oUIElement=_UIA_getObjectByFindAll("Changebrightness.mainwindow", "title:=Change brightness;ControlType:=UIA_SliderControlTypeId", $treescope_subtree)
    Local $Slider = _UIA_getObjectByFindAll($oP0, "title:=Change brightness;ControlType:=UIA_SliderControlTypeId", $treescope_subtree)
    _UIA_action($Slider, "click")

    Local $value = GUICtrlRead($Slider)
    MsgBox($MB_SYSTEMMODAL, "", "Brightness is at: " & $value)
    Local $setValue = GUICtrlSetData($Slider, 50)

    ;UI for verification
    Local $iTimeout = 1
    MsgBox(0, "Change Brightness", "Brightness Changed.", $iTimeout)

    WinClose("Settings") ;Close the active window
EndFunc   ;==>Slider


Share this post

Link to post
Share on other sites

@bowker it is exceedingly difficult to offer assistance when you provide non-runnable code. This small snippet shows that doing a GuiCtrlRead on a slider works just fine:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $hGUI = GUICreate("Test", 300, 300)
Local $slider = GUICtrlCreateSlider(10, 10, 280, 50)


    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ConsoleWrite(GUICtrlRead($slider) & @CRLF)

If possible, please post a runnable code that reproduces your issue.

√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post

Link to post
Share on other sites
Posted (edited)

@JLogan3o13 The code is working fine for me. I think error would be the UIWrappers. The code needs to be in the same directory with the wrapper package in order for you to run the code without errors.
These are the packages

#include <IE.au3>
#include <MsgBoxConstants.au3>
#include <GuiSlider.au3>
#include <GUIConstants.au3>
#include "UISpy\UIAWrappers\UIAWrappers.au3"

Edited by bowker

Share this post

Link to post
Share on other sites

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
Sign in to follow this