MatejGolian / ReaHotkey

An AutoHotkey script for blind musicians and REAPER users
9 stars 2 forks source link

Kontakt 7 can now present a menu with some accessibility, but I need a way to detect the menu is visible and have ReaHotkey give up control of the Enter key #21

Open ScottChesworth opened 2 months ago

ScottChesworth commented 2 months ago

I'm scripting a Kontakt library here (Fairview from RS Drums), just getting some buttons done on the their Drums tab so I can choose kit pieces, may also do switching to the settings tab and clicking the dropdown for mapping presets. In all of these cases, once I've clicked the initially inaccessible graphic to drop down a menu, turns out Kontakt 7 is building menus that are keyboard navigable and the options contained within are reported, much like how the top menus nowadays. However, seems these are child controls. With ReaHotkey running, I can't hit Enter and make a selection in the menu. Seems like ReaHotkey doesn't know it's there and still has control over the Enter key. I say that because if I route mouse pointer to a choice within the menu and simulate a click, then selection works as expected, even with ReaHotkey running. Is there a way to detect that a menu is visible? In case it helps, I noticed part of an entry that stays consistent in the NVDA log for the topmost control of each menu: UIA className: LumenMenuItem_QMLTYPE_678 The number after the underline changes each launch, but maybe there's some sort of usefulness in detecting the LumenMenuItem part? Dunno

Any advice appreciated!

MatejGolian commented 2 months ago

I think you've identified the situation/problem correctly. It's a bit hard for me to determine the best solution since I don't have that particular library, but one thing that could work immediately without the need to write extra code is using the 'hack' that I already have in place elsewhere. In case you are using HotspotButtons, try adding this as the 5th parameter:

Kontakt.OpenPluginMenu (I assume you're working with Kontakt in Reaper and not the standalone version.) The problem is that those menus, although accessible, are not standard Windows context menus and so ReaHotkey does not know that it should give up control as long as they are open. If the above does not work, I'll try coming up with something else.

ScottChesworth commented 2 months ago

Well right now it doesn't work, but I'm not sure whether I'm using the suggestion correctly. When I opened the issue my control looked like this:

FairviewOverlay.AddHotspotButton("Snare selector", 476, 454, CompensatePluginPointCoordinates, CompensatePluginPointCoordinates)

I tried adding your suggestion as an extra parameter like this: FairviewOverlay.AddHotspotButton("Snare selector", 476, 454, CompensatePluginPointCoordinates, CompensatePluginPointCoordinates, Kontakt.OpenPluginMenu)

Guessing that's not right because ReaHotkey throws this error next time I run it: Error: Too many parameters passed to function. Specifically: HotspotButton.Prototype.__New

Figured maybe I miscounted parameters, tried this instead; FairviewOverlay.AddHotspotButton("Snare selector", 476, 454, CompensatePluginPointCoordinates, Kontakt.OpenPluginMenu)

ReaHotkey now runs, but the hotspot no longer works. It's still reachable in the tab order but doesn't appear to do anything.

Any ideas?

MatejGolian commented 2 months ago

The line below should work:

FairviewOverlay.AddHotspotButton("Snare selector", 476, 454, CompensatePluginPointCoordinates, [CompensatePluginPointCoordinates, Kontakt.OpenPluginMenu]) Since you want to execute 2 custom functions once the button's clicked, you need to make the last parameter an array. HTH

ScottChesworth commented 2 months ago

Gotcha. ReaHotkey runs without any errors, hotspot appears in the tab order, still doesn't work though. Is there anything I can provide to make diagnosing it easier?

MatejGolian commented 2 months ago

Sorry to hear that - I so hoped that that would work. Honestly, I don't know why it didn't. Unfortunately, there's nothing that comes to mind immediately as far as diagnosing the issue is concerned. Again, it's pretty hard to do without having access to the library in question. That being said, if you send me your files, who knows, maybe I'll be able to figure something out even without the lib. We can also do it via GitHub, but in that case I don't know how exactly to go about it so that it doesn't mess up the main branch. As you can tell I'm pretty much still battling the basics of working with GitHub.