5

The initial cursor position is essential to my app's function. I could preserve the cursor location with a screen capture (using keystrokes only) but I'm hoping to avoid writing a handler to wrest the cursor's location from the picture. I am running macOS High Sierra 10.13.3.

4

You can set a keyboard shortcut to run your AppleScript, either from anywhere or only with certain conditions such as only in a certain application or with certain data selected.

  1. Open Automator.app and create a new Service.

  2. Add the Run AppleScript action to your workflow and paste your AppleScript code into the marked location.

  3. At the top of the workflow, set the service options to receiving ‘no input’ in ‘any application’ so that the service is available anywhere. Alternatively, specify a type of data and/or application to limit when you can activate this service.

  4. Save the workflow with a suitable service name.

  5. Open System Preferences → Keyboard → Shortcuts → Services and find your service in the list. If you chose ‘no input’, your service will be under General, otherwise it will be under the type of data you chose as input.

    Set a shortcut to activate the service.

    Service set shortcut

3

It sounds like the best option would be to use the keyboard to launch your AppleScript app.

If it is an actual AppleScript Application, you could launch it with Spotlight (by invoking Spotlight via ⌘Space). If it is just an .applescript or .scpt file, you could use a third party launcher such as LaunchBar or Alfred (which are basically Spotlight on steroids), or you could use the very versatile Keyboard Maestro.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .