I have a function that I need to use on a number of scroll wheel hotkeys, the function increases or decreases a value on controls found on a inactive window, the following is a use case example:
a & WheelUp:: ;increment control #1
lazy_rulers("++", 1, "a")
return
a & WheelDown:: ;decrement control #1
lazy_rulers("--", 1, "a")
return
b & WheelUp:: ;increment control #2
lazy_rulers("++", 2, "b")
return
b & WheelDown:: ;decrement control #2
lazy_rulers("--", 2, "b")
return
c & WheelUp:: ;increment control #3
lazy_rulers("++", 3, "c")
return
c & WheelDown:: ;decrement control #3
lazy_rulers("--", 3, "c")
return
z & WheelUp:: ;increment control #26
lazy_rulers("++", 26, "z")
return
z & WheelDown:: ;decrement control #26
lazy_rulers("--", 26, "z")
return
Each time I need to increase/decrease this value, I need to perform two steps:
- Because the window is QT5 based and the control positions are not constant, I first I have to find a controls relative coordinates using Descolada’s UIA
- Then using
controlClick
sendwheelUp
/wheelDown
to the windows coordinates
This works reliably but its very slow. I have looked at it closely, step 2 (controlClick
) works fast, its step 1 that is slow, which consists of multiple query’s to UIA.
Since I only need to know the controls position once, which is upon the first <letter>
+ <wheel>
event, then while the parent key (letter) is down, I want to skip the UIA step, but I am not sure how to go about this, I tried a number of approaches (keywait
, while
with getKeystate
) but failed.
What is making it difficult is the fact that the code is wrapped in a function, which I need to do so to make use of it in a lot of places, the following is pseudo code:
lazy_rulers(value := "", index := "", key := ""){
if (???){ ; Only enter this branch on the very first wheel scroll (when the letter is first held down, along with the first wheel scroll)
UIA := UIA_Interface()
hwnd := WinExist("Lazy Nezumi Pro ahk_exe LazyNezumiPro.exe")
el := UIA.ElementFromHandle(hwnd)
pos := el.findFirstBy("ControlType=spinner AND AutomationId=LazyNezumi.centralWidget.widgetDetails.animWidgetRulers.frameRulers." rulerParam).GetCurrentPos("window")
}
;Run the follwoing on every wheel scroll
if (value = "++")
ControlClick,,% pos.x + 10,% pos.y + 10, wu,,, Lazy Nezumi Pro ahk_exe LazyNezumiPro.exe
else
ControlClick,,% pos.x + 10,% pos.y + 10, wd,,, Lazy Nezumi Pro ahk_exe LazyNezumiPro.exe
The function is a lot more involved than the above, but I feel the above gets my point across, I would appreciate any ideas or solutions on this.