I am attempting to automate the Slider control for the voice speed within Microsoft Edge Read Aloud Bar's submenu. Image attached. This is built specifically for Edge browser and can be accessed on any webpage by the following shortcut: Ctrl+Shift+U. It is a very nice built-in tool that gives free access to reading text on websites coupled with in-page text highlighting of the current word being read.
These features can actually be accessed in an isolated environment by going to these URLs:
1) edge://read-aloud-bar/pane
2) edge://read-aloud-bar/bar
I am currently using the UIA library published by Descolada (viewtopic.php?style=2&t=104999) to try and change the value of the slider with no success. It is also very curious that I am able to change the slider position manually with the Left/Right arrow keys, however, when I attempt to do so using SendInput, I do not get any response from the slider.
Here is my current code attempt:
Code: Select all
#Persistent
#NoEnv
#SingleInstance, Force
SendMode Input
SetTitleMatchMode 2
SetWorkingDir, %A_ScriptDir%
#include %A_ScriptDir%/UIAutomation/Lib
#include UIA_Interface.ahk
initializeUIA()
; MANUALLY OPEN THE READ ALOUD BAR USING CTRL+SHIFT+U (I have written a script to automate this process and check for when the read aloud bar is present, but it is not pertinent to my current issue so was not included.)
g::
openMsReadAloudSubmenu()
return
h::
changeMsReadAloudSpeed()
return
initializeUIA() {
global UIA
UIA := UIA_Interface() ; Initialize UIA interface
global UIA_Edge_Element
UIA_Edge_Element := UIA.ElementFromHandle(WinExist("ahk_class Chrome_WidgetWin_1 ahk_exe msedge.exe")) ; Get the element for the target window
}
openMsReadAloudSubmenu() {
global UIA_Edge_Element
voice_options_button := UIA_Edge_Element.FindFirstByNameAndType("Read aloud", "Document").FindFirstByNameAndType("Voice options", "Button")
voice_options_button.Click()
}
changeMsReadAloudSpeed() {
global UIA_Edge_Element
voice_options_button := UIA_Edge_Element.FindFirstBy("ClassName=RootView AND LocalizedControlType=dialog").FindFirstByNameAndType("Read aloud", "Document").FindFirstByType("Group").FindByPath("1.2")
voice_options_button.SetFocus()
voice_options_button.SetValue(2) ; does not work
voice_options_button.GetCurrentPatternAs("LegacyIAccessible").SetValue(2) ; does not work
SendInput, {Right} ; does not work, but if you manually press the right arrow button, the slider value changes.
}