Page 2 of 2

Re: Invoke Virtual Keyboard on Desktop (Apple)?

Posted: Fri Sep 13, 2024 7:30 pm
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 46 times

Re: Invoke Virtual Keyboard on Desktop (Apple)?

Posted: Fri Sep 13, 2024 7:30 pm
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).

Re: Invoke Virtual Keyboard on Desktop (Apple)?

Posted: Fri Sep 13, 2024 7:33 pm
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.

Re: Invoke Virtual Keyboard on Desktop (Apple)?

Posted: Fri Sep 13, 2024 8:45 pm
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.