Trying to click various places and insert text using sys event / keystroke, but keystroke doesnt happen when it should

Joined
Jun 21, 2021
Messages
1
Reaction score
0
Thank you for taking the time to read this. I am trying to automate a small task in Safari using various clicks with delay, and inserting text using sys event keystroke, but for some reason the keystroke happens at a later time and the order doesnt make sense.

Here is a super cut version of what I'm trying to do:

tell application "System Events"
click at {2100,200}
end tell

delay 1

tell application "System Events"
keystroke "carrier ineligible"
end tell

delay 1

tell application "System Events"
click at {1800,200}
end tell
However it basically clicks the one place, then the other, and keystrokes in the wrong place as a result. I can only seem to get a single keystroke to work, so long as there is nothing happening afterward.

I want it to click A area, B area C area, enter text at C area, click D area, E area, F area, enter text at F area, click G area H area etc.

Even though the script is written as "click A area, enter text ar A area, click B area", it executes as "click A area, click B area, enter text on click B area"

But why does lack of order happen? Its like click events take priority no matter how the order its written.

P.S. I actually dont have direct access to AppleScript, I am using an app called TextExpander which has accessibility access and I can still create Apple Scripts, I just have to call it with a keyboard shortcut. This shouldnt affect the ability of AS at all. I am able to use sys events and all that. Its a work computer. I'm basically just trying to automate a small work task which comes up very very frequently. It would save me like an hour over the day.
 

Cory Cooper

Moderator
Joined
May 19, 2004
Messages
11,098
Reaction score
500
Hello and welcome.

I have very little experience with Automator/AppleScript. Another member may chime in, or you can try the folks over at MacScripter, as they may be able to help.

C
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top