Invoke Virtual Keyboard on Desktop (Apple)?

All flavors welcome.
Forum rules
Be kind.
User avatar
tperry2x
Posts: 3210
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: Invoke Virtual Keyboard on Desktop (Apple)?

Post by tperry2x »

Feel free to give this a go on a mac. Completely untested, and it may not work at all.
mac-keyboard-maybe.oxtstack
(1.24 KiB) Downloaded 45 times
User avatar
richmond62
Posts: 4833
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Invoke Virtual Keyboard on Desktop (Apple)?

Post by richmond62 »

Code: Select all

tell application "Finder"
if application "KeyboardViewer" is running then
      quit application "KeyboardViewer"
  else
      activate application "KeyboardViewer"
  end if
end tell
Not round these parts (MacOS 12).
Attachments
KeyBoarder.oxtstack.zip
(990 Bytes) Downloaded 44 times
https://richmondmathewson.owlstown.net/
User avatar
tperry2x
Posts: 3210
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: Invoke Virtual Keyboard on Desktop (Apple)?

Post by tperry2x »

You had the same idea as me, but your stack is missing some returns in the script.
I'm hoping mine might give you different results, but then again, it might not.
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Invoke Virtual Keyboard on Desktop (Apple)?

Post by OpenXTalkPaul »

richmond62 wrote: Fri Sep 13, 2024 7:30 pm

Code: Select all

tell application "Finder"
if application "KeyboardViewer" is running then
      quit application "KeyboardViewer"
  else
      activate application "KeyboardViewer"
  end if
end tell
Not round these parts (MacOS 12).
This does not work on macOS Sonoma. And after Googlin around for an answer it seems there's not really a good way to do bring this up programmatically. I don't like AppleScripts that use 'UI Scripting'. For one thing UI scripting needs to first be activated in the assistive services panel. And I also do not trust that they won't break the next time Apple makes some change to the macOS UI. However AppleScript seems to be the only solutions for this problem on StackOverflow.

For a cross platform solution with no external dependencies could maybe use this:
https://github.com/OpenXTalk-org/OpenXT ... enKeyboard

Also (a bit off topic here but since you asked...)
The libhidapi.dylib goes in the extension's 'code' folder specific to the platform:
OpenXTalk-HIDAPI/code/x86_64-mac/libhidapi.dylib
The only change I did (so far) was to drop in a newer version of that binary.
Which worked fine on macOS 11, hopefully it fixes issue with not loading on Sonoma.
Nice thing about making wrappers around foreign libraries like that, all I had to do to update it to current was drop in the new binary into that folder, and unload/reload the extension in the IDE.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest