You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey @jordanbaird, your package is exactly what I was looking for. Thanks a lot. But unfortunately it doesn't work for me. I created a minimal console application to give it a try. I expect this line to open TextEdit and put the string "Hello".
But unfortunately only TextEdit opens but not text appears. I already grant accessibility permissions for my console application. Do you have any idea what else could be missing?
EDIT 1: I found out that the behaviour described is related to that: https://stackoverflow.com/q/63094246. The conclusion is that adding a sleep after the line above helps. Does anyone knows a better solution?
Cheers
mahush
The text was updated successfully, but these errors were encountered:
Looks like this is a lot more finicky than I'd originally thought. I've been experimenting with using DispatchQueue instead of sleep, as running it async seems like the better option, rather than holding up the entire process. It works, as long as the target app (in this case, TextEdit) is completely closed beforehand. If it's already running I'm having trouble getting it to work consistently.
EDIT: After more experimentation, it looks like the process that's doing the sending is finishing before it has the chance to actually send anything, so I think DispatchQueue is a no go. When KeySender opens an app, it just runs the open command, waits for it to finish, then tries to send the event. I'm guessing it works in that case because of the delay in waiting for the command to finish, which is keeping the process alive longer. I'll keep trying things, but I feel like it's ultimately going to come down to some sort of sleep function, which isn't ideal. I guess there's the option of using some sort of background helper process, if we want to go down that route.
Hey @jordanbaird, your package is exactly what I was looking for. Thanks a lot. But unfortunately it doesn't work for me. I created a minimal console application to give it a try. I expect this line to open TextEdit and put the string "Hello".
try KeySender(for: "Hello World").openApplicationAndSend("TextEdit")
But unfortunately only TextEdit opens but not text appears. I already grant accessibility permissions for my console application. Do you have any idea what else could be missing?
EDIT 1: I found out that the behaviour described is related to that: https://stackoverflow.com/q/63094246. The conclusion is that adding a sleep after the line above helps. Does anyone knows a better solution?
Cheers
mahush
The text was updated successfully, but these errors were encountered: