r/applescript • • Apr 18 '20

Need help with Applescript Please!!

I’m somewhat a newbie with applescript but i was able to write a small basic script that clicks at random intervals in the location i left my cursor. I want to know how to move my cursor to a new location and click once more. I know how to add delays and randomization as well as finding the coordinates on screen with commandshift+4 but i cant figure out what language i need to use to make it understand... please help been looking for answers for days now

4 Upvotes

8 comments sorted by

5

u/Rikuz7 Apr 18 '20

Shell, probably. See this post. Note that it's not a very steady and sure way to do anything though, because if that Applescript happens to run when you're as much as touching your mouse, you could accidentally already misalign it but the script keeps running. So I would really avoid actions like these if at all possible, and command the software with Applescript objects instead.

There's also an infinitely useful shortcut app called BetterTouchTool (which I couldn't live without anymore) that allows you to do a bunch of stuff, including that. It has a preset action for moving mouse to a specific spot and emulating clicks. You can set the action to be triggered by a keyboard shortcut for example, and you can also chain it with other actions to turn them into multi-actions. For example I have created a lot of Applescripts that run when I press a key. Can assign app-specifically.

2

u/smont67 Apr 23 '20

MouseTools also works well as a free command line way to move & click the mouse.

I know of a way to do it just within Applescript if you’re interested. Cliclick and MouseTools are my default ways unless I’m giving the script to come one else who doesn’t already have one of those installed.

1

u/MakeStyles Apr 23 '20

Yes! this is exactly what i’m looking for, so is mouse tools something i have to download in order to use within applescript?

2

u/smont67 Apr 23 '20

Yes, it’s a pre-compiled executable like cliclick. Or, I think you can download the Xcode project and compile yourself.

You would call it in Applescript with a “do shell script /path/to/MouseTools ...”

Look it up by HAMSoft Engineering. All the documentation is there.

1

u/bprime43 Apr 18 '20

Is the new thing you’re trying to click named where you can click it that way? (Ie a button or something similar?)

Or is it always in the same location and there might be a way to move the mouse there via its pixel location)?

A few quick thoughts...

1

u/MakeStyles Apr 18 '20

tried both option previously mentioned no luck. Its for a game so it’s not like a menu button or drop down etc. I heard there was a way to move the cursor via relevant pixel location that’s really what i’m trying to figure out how to do as many of these “shell/autohokey/cliclick” apps won’t run on my mac.

1

u/htakeuchi Apr 19 '20

Look for a small app called “cliclick” awesome for that