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.
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.
Open Automator.app and create a new Service.
Add the Run AppleScript action to your workflow and paste your AppleScript code into the marked location.
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.
Save the workflow with a suitable service name.
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.
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
.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.