Как прочитать значение из ползунка управления? - PullRequest
0 голосов
/ 07 июня 2018

Я использовал simplespy.au3 для нацеливания на ползунок в окне настроек Windows, используя _UIA_action().Попросив пользователя ввести значение, я посылаю левую и правую клавиши для перемещения ползунка.

Но я не знаю, как получить текущее значение моего ползунка.Я пытался GUICtrlRead(), но это не работает.Как получить текущее значение элемента управления ползунка?

Мой код:

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

Slider()

Func Slider()
    ;User Input
    $Default = ""
    $input = ""

    While 1
        $input = InputBox("Brightness", "Set Brightness to:", "", " M", -1, -1)
        If @error Then ExitLoop
        If $input < 0 Or $input > 100 Then
            MsgBox(48, "Error!", "Minimum value for brightness is 0 and the Maximum brightness is 100")
            $Default = $input
            ContinueLoop
        ElseIf StringLen($input) > 0 Or $input < 100 Then
            ExitLoop
        EndIf
        If @error = 1 Then
            Exit
        EndIf
    WEnd

    ;Start automation
    Local $iTimeout = 1
    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
    Sleep(1000)
    Send("{ENTER}")
    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 $oUIElement = _UIA_getObjectByFindAll($oP0, "title:=Change brightness;ControlType:=UIA_SliderControlTypeId", $treescope_subtree)
    _UIA_action($oUIElement, "setfocus")

    Send("{LEFT $input}"`enter code here`)

    Sleep(1000)
    Local $value = GUICtrlRead($oUIElement)
    MsgBox($MB_SYSTEMMODAL, "", "Brightness is at: " & $value, $iTimeout)
    Local $setValue = GUICtrlSetData($oUIElement, 50)

    ;UI for verification
    MsgBox(0, "Change Brightness", "Brightness Changed.", $iTimeout)
    Sleep(1000)
    WinClose("Settings") ;Close the active window
EndFunc   ;==>Slider

1 Ответ

0 голосов
/ 09 июня 2018

Не манипулируйте слайдером.Вместо этого используйте WinAPI: _WinAPI_SetDeviceGammaRamp .

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...