Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workaround for synthesizing text #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

workaround for synthesizing text #50

wants to merge 2 commits into from

Conversation

ahxxm
Copy link

@ahxxm ahxxm commented Sep 15, 2018

#44 mentioned: # synthesize text - does not work on Mojave (for now..)

this PR adds option -a to simplify configuration of keystroke-sequence, previously:

ctrl - j : skhd -k "1"; skhd -k "w"; skhd -k "2"; skhd -k "w"; skhd -k "3"; skhd -k "q"; skhd -k "e"; skhd -k "4"; skhd -k "e"; skhd -k "w"; skhd -k "q"

new:

ctrl - j : skhd -a "1w2w3qe4ewq"

@koekeishiya
Copy link
Owner

I don't want to be making any changes related to this until Mojave GM is released, as there is no indication in their documentation that any changes have been made to the API we use to implement this. As such, I believe this is just a bug or unintended change.

This feature also uses non-deprecated APIs which make my point above seem more valid.
If Mojave is released and this is still a problem,I will consider different ways to replicate said functionality (with utf8 support).

@ahxxm
Copy link
Author

ahxxm commented Sep 25, 2018

-t works here after upgrade to Mojave(10.14), but it works only in text area, didn't trigger keystroke as observed from Chrome tab..

@koekeishiya
Copy link
Owner

koekeishiya commented Sep 25, 2018

This is not working for me either. The part that has changed in Mojave is the following function call:
https://developer.apple.com/documentation/coregraphics/1456028-cgeventkeyboardsetunicodestring

It no longer appears to respect the override that we could do before.
As mentioned in the description (at the referenced page):

By default, the system translates the virtual key code in a keyboard event 
into a Unicode string based on the keyboard ID in the event source. 
This function allows you to manually override this string. 
Note that application frameworks may ignore the Unicode string in a keyboard 
event and do their own translation based on the virtual keycode and perceived event state.

Basically, we need to be able to do the reverse translation; find the virtual key code for the Unicode symbol, and set the virtual key code in the event instead.

I'm not sure at this moment how Unicode symbols are mapped into the virtual key code space.

@yigitkonur yigitkonur mentioned this pull request Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants