The following steps are a solution for automating the repeat clicking of a mouse, back and forth, at two different fixed positions within a web page -- i.e. clicking two buttons or links within in a web-page, with a user-defined delay between each click.
All this is, is a slight modification of what was described over in this thread -- this one being for two website "buttons" rather than one.
IMPORTANT -- this automation does NOT work in the background. In other words, you can't be doing something else on your computer at the same time this automation is running. In addition, your browser can't move its physical position on your screen after the automation begins, because you're literally telling the computer to press two buttons at fixed X,Y pixel coordinates. The "buttons" on the web-page, therefore need to stay at the same spots on your screen for this to work.
Steps as follow:
- Click the Apple icon (upper left), select "System Preferences." Type "security" in the upper-right search window. This should highlight Security & Privacy. Open that.
- Click lock icon, enter your password, click Unlock.
- Click Accessibility from the scrollable list (blue icon). Now click the plus sign below the box on the right. Then navigate to Applications and scroll down to Utilities. From within there, put check marks on Terminal AND Script Editor. Then finally select whichever web browser you use under the Applications list. You can then close out of this window.
- Launch Terminal. (I do this by typing "Terminal" as a Spotlight search (the magnifying glass icon, upper right of screen)).
- Remember (generally speaking) what that bottom-most line appears like when Terminal opens up. You'll want Terminal to revert back to whatever that is after each of two short downloads occur within terminal -- both are idiot-proof. `
- First Download -- Home Brew. As strange as this sounds, all you do to download this "program" is copy the single line of text you see below "Install Home Brew" on its website. Paste that text into Terminal, hit Enter and wait for the process to complete. When the bottom line in Terminal appears as it was when you first launched it, you're done.
- Second Download -- CliClick (second download). Simply type these three words in Terminal, then hit by Enter:
brew install cliclick
(note: CliClick took about 90 seconds to install as I recall)
- When the download is complete, you can minimize Terminal -- as you're done with it now. Close it entirely if you're certain cliclick has been downloaded.
- Next, simply determine the X,Y pixel coordinates for both website "buttons" you want the robot to click on. Before doing this, I recommend placing the browser window on your screen in such a way that its upper-left corner abuts the upper-left corner of your display. To determine the coordinates, simply press COMMAND+SHIFT+4 and jot down both sets of numbers atop each "button" you over over. The top digits are X coordinates and the bottom are therefore Y. You'll end up with two pairs of numbers for each button, obviously. Write these down somewhere, then press Escape to turn off the crosshairs.
- Launch Script Editor. Like Terminal, I did this by typing "script editor" as a Spotlight search
- Now, copy and paste ALL of the following text into Script Editor. It must show up there exactly ias it does below, including indents etc:
tell application "Google Chrome"
repeat 208 times
do shell script "/usr/local/bin/cliclick c:" & "132,286"
do shell script "/usr/local/bin/cliclick c:" & "1100,230"
Now you're pretty much home free! All you do is replace the first set of comma-separated digits with the coordinates you of your first website button in X,Y format. Leave the quote marks as they are. Repeat this for your second button and change the delays as you wish, which are in seconds.
Finally, set repeat value to the amount of loops you want to run and save the script. Voila! Pressing "play" in Script Editor will roll the press. You can stop it by simply stealing your pointer back and clicking on the "stop" button, which I did multiple times to change the delays based on internet speed and server speed.