Hi, Nick
Thank you for your quick and positive response. The app I want to use is a dictionary viewer called EBMac. It’s an application from Japan. The site is also in Japanese. Sorry for this.
The EBMac Dictionary Viewer has a Service feature that works well, except for the built-in Preview application. So I made a simple snippet for looking up for in pdf files with Preview app, but has a minor problem.
If you run this script before/without launching the dictionary application, there is a problem that you cannot look for because the search field is not focused. However, as long as the application is up and running, there is no problem. You can search as expected.
Nice Job. I didn’t download the app because the download page had so many ads and fake butttons, I got freaked out about the app. I edited you post to turn the snippet into code block with ```
I’ve found sometimes with AppleScript and executing keycodes / keypresses you may need to introduce slight delay calls. Like before any keystrokes I’ve do a
delay 0.5
It also may be a good idea to move your tell system events block to inside the tell Music block. This kinda ensures the keystroke are happening “towards” the music app.
After the activate is a good place to add the delay 0.5
This will ensure that the music app has been brought to the for front and gives a bit of time to settle before the keystrokes