Hmm. Your AppleScript version returns an error here on Ventura:"VoiceOver got an error: Connection is invalid." But VoiceOver read the screen in Script Editor.
What is it that item chooser does? I see it in the VoiceOver dictionary under menu but I don't quite grasp how it might be used.
I notice that "item chooser" doesn't appear (as a command name string) (in that formulation or spelling) in the SDEF scripting dictionary for VoiceOver
Might it, for example, be a rough translation from an original in a non EN localisation ?
menu enum
help menu : Help menu
applications menu : Applications menu
windows menu : Windows menu
commands menu : Commands menu
item chooser : Item chooser
web menu : Web menu
contextual menu : Contextual menu
JXA is the same except the enums are double-quoted:
"item chooser" : Item chooser
When run from AS it appears to pop a list of interface elements in the frontmost window, if you select one that moves the "accessibility box" to that element ready for interaction.
Still get the same error in JXA though -- and I don't know enough about JXA to work out why
No -- as mentioned, the AS works fine, and barfs if you don't quote item chooser. As does JXA. I've tried the obvious case permutations, without success. Using something too different, like 'item_chooser', results in an eventual timeout failure -- so it looks like the syntax and command are correct, it "just doesn't work".
Thanks for your reply.
I tried on Ventura, it's the same for me. AppleScript works, but not jxa.
Item chooser gather all the UI elements from current window, and present them to VoiceOver (MacOS screen reader). However, item chooser doesn't really matter particularly to my question. I just used as an example.
VoiceOver has hundreds of commands, and you are supposed to be able to execute those commands useing commander.performCommand(...).
I tried bunch of combination with upper case and lower case.
Item Chooser, item chooser, Item chooser, open the item chooser, Open The Item Chooser, Open the Item Chooser, and so on...
Unfortunately none of them worked...
I have literally hundreds of JXA scripts that make certain apps more usable with screen reader. Technically I can do that, but going back and forth between AS and JXA will be nightmare especially when different scripts communicate among each other.
Even Chat GPT-4 gave up on JXA! lol
ChatGPT:
JavaScript for Automation (JXA) in macOS is a bit more complex than AppleScript when it comes to interacting with system applications like VoiceOver.
Unfortunately, as of my knowledge cutoff in September 2021, it seems like there's a limitation with JXA where certain system commands, especially the ones tied to assistive technologies like VoiceOver, might not work as expected.
The error "Error 6: An error occurred" is a generic message and can come up in a variety of situations. The issue you're experiencing might be due to a lack of support for the specific API used by VoiceOver in JXA, or due to a limitation in the JXA language itself.
As of my last update, the Apple community has not provided a direct solution for this specific case. It would be best to look for more recent updates or ask for help in the relevant Apple forums or communities.
I recommend using AppleScript for interacting with system applications like VoiceOver, as it is more straightforward and less error-prone for such tasks.
Actually believe or not, it does fairly well with fixing relatively short codes in popular languages.
I thought I would give it a shot in desperation (and for fun) even though JxA is rare.
I'd add "...for questions that are near enough to something already answered on the interwebz and, ideally, answered consistently in the same way".
Don't get me wrong -- I think that what's been achieved with Chat GPT so far is frickin' awesome! And I can't wait for the day when it can answer all me users' questions for me and I can spend all my time here But they aren't there yet and, importantly, its habit of giving seemingly authoritative answers on things it "knows" little about and that are actually demonstrably wrong means that, in many cases, you're better off doing your own web search and then assessing the results in context.
And don't get me started on the mis-application of the term AI...
At which point Nige_S dismounts from his hobby-horse and walks carefully away, slightly saddle-sore...
While 'Approximated Inference' might be closer, inference still implies thinking, which presently requires a brain. Elon hasn't yet demoed a convincing brain-computer interface. Lt. Barclay in the SNG ep. 'The Nth Degree' does instruct the Holodeck to create the required interface, but they cut to the next scene before we hear the instructions
There is nothing except a commitment to invest the resources that prevents a trained neural network on the relevant materials to produce a natural language interface to coding Keyboard Maestro or anything else (or so says the non-coding village idiot.)
The more interesting (Outback Lounge) question is why we choose to invest our limited time in the things we do or in other words, what is our long-term vision and how aligned are our immediate actions with that vision remembering that even the finest vision must be paid for.