Using applescript to time a click of a button on a webpage?

Joined
Jan 16, 2012
Messages
5
Reaction score
0
Points
1
Hi,

Would like to apologize if i didn't post this thread in the correct location.

I've been looking into automation to help me solve a work flow but i cant seem to find any specified "language",work flow, or command line inscription that would allow me to accomplish what it is i need to do.

Basically what i need to do is click on a post bottom with in a web page to be executed at a certain time.

I did find this but its an add on only compatible for Windows.

Automate timed mouse clicks with ClickWhen

That application pretty much does exactly what it is what i am looking for.


Does any one have any idea !!!!! or where i could find command lines to do this sort of thing. Any help or inspirations would be grateful.

Thx,

Jon
 
OP
J
Joined
Jan 16, 2012
Messages
5
Reaction score
0
Points
1
Hi,

Thanks for directing me to that application!! I cant seem to find the actual action that i have to pick. What would you recommend me doing?

let me know thanks!

Jon
 
Joined
Sep 30, 2007
Messages
9,962
Reaction score
1,235
Points
113
Location
The Republic of Neptune
Your Mac's Specs
2019 iMac 27"; 2020 M1 MacBook Air; macOS up-to-date... always.
I'm not sure what you meant by clicking on a "post bottom of page", but I assume you meant a button on a web page. What you'll need to do first is set up a macro whose trigger is a certain time. Then add a Move or Click Mouse action. From here, you will need to enter mouse coordinates. There are several options available for the coordinates. You can set them as being relative to a corner of the screen, or a corner of the window of the app of interest. The advantage to the latter option is that the positioning of the window won't have to be fixed in place. The hard part is figuring out the coordinates. There's an app on the Mac App Store that will give mouse coordinates, which is relative to the screen and would work if you run your web browser in full screen mode under Lion. You can also plug in number and hit Try at the bottom.

Once you have the coordinates, make sure you have the action set to Click, or set to Move and Click (if you want the cursor to move also). See my screen cap for an example here. It's set to Move at the moment.

120118-0001.jpg
 
OP
J
Joined
Jan 16, 2012
Messages
5
Reaction score
0
Points
1
lifeisabeach,

Thanks for showing me the screen capture. Having asked around. It looks like i would have to write up a JS code and trigger the Button on the web page. The reason why automation would work is because i have to move the location of the button. Plus have to trigger to as many as 15 buttons.

Hear is the closest explanation I've gotten:

Trying to get javascript to click a link when function is called - WebDeveloper.com

iam going to spend the rest of the week trying to write up a code that suits my objective. Wish me luck. (i have a feeling that this is going to be a ahead ache).

If anyone still has a better way. let me know!!!
 
Joined
Sep 30, 2007
Messages
9,962
Reaction score
1,235
Points
113
Location
The Republic of Neptune
Your Mac's Specs
2019 iMac 27"; 2020 M1 MacBook Air; macOS up-to-date... always.
Hmmmmm. Can the button be selected by hitting the TAB key a certain number of times? If so, and if that number wouldn't change as the button moves, you can automate this by a macro that passes a TAB key press enough times, followed by passing ENTER.

There is also an action for KM named Press a Button that you can try.
 
OP
J
Joined
Jan 16, 2012
Messages
5
Reaction score
0
Points
1
Looks like i can select the tab that i want clicked!!! Not a bad idea!!

How do I trigger the tab through KM then? The thing is , is that i cant record the movement. The tab has to be programed to be clicked once in the future.

any suggestions?
 
Joined
Sep 30, 2007
Messages
9,962
Reaction score
1,235
Points
113
Location
The Republic of Neptune
Your Mac's Specs
2019 iMac 27"; 2020 M1 MacBook Air; macOS up-to-date... always.
step instructions for an example would be awesome !

I'm at work at the moment, but look for an action titled some like "Type a Keystroke". If you have to have TAB pressed more than once, add the "Repeat" action first, then drop the "Keystroke" one inside it. I can post a detailed walkthrough late tonight or early tomorrow if need be.
 
Joined
Sep 30, 2007
Messages
9,962
Reaction score
1,235
Points
113
Location
The Republic of Neptune
Your Mac's Specs
2019 iMac 27"; 2020 M1 MacBook Air; macOS up-to-date... always.
Ok, here's a tutorial with screen caps. First thing I need to mention is that when you build this, make sure you start counting the TABs needed while nothing is selected anywhere on the page. I recommend just clicking on a blank part of the page before starting, then tapping TAB to see how many it takes. That also needs to hold true when actually running the macro.

Ok, after launching Keyboard Mastro, you will need to create a new Group by clicking the + button at the bottom of the Groups column, then give it a name. Determine what apps this group of macros will be available in and whether or not you want this group to be available always, or under certain conditions.

For the sake of this demo, I will make this group available only within Safari, and activated only when I tap on the group's entry in a floating palette that Keyboard Maestro will have available on-screen.

Result of step 1.jpg

Next you need to create and name a new Macro by clicking the + button at the bottom of the Macro column. You will need to determine how the macro will be triggered (by hot key, at a specified time, etc). Note… the macro will not run no matter what the trigger is unless the group it belongs to has been activated.

To start adding commands, click on New Action to pull up the a list of available actions.

For the sake of this demo, I will assume you want this macro to run at 1:30 p.m. on Tuesdays and Wednesdays. By default, it appears that all days are selected (test this yourself to be sure), so deselect the ones you don't want it run on. I am also going to assume it takes 5 TAB presses to reach the button of interest, so I will also first add a Repeat action (found easily using the filter up top).

Results of step 2.jpg

Next, add the Type a Keystroke action INSIDE the Repeat action. Click on the box next to Simulate Keystroke and press the TAB key.

Add a new Type a Keystroke action UNDER the Repeat action. Drag it over and watch for the blue highlight to show where it will drop, or click on a blank space, then double-click on it. If it's in the wrong spot, drag it to where it needs to be. By default, the keystroke is RETURN, so leave it be.

Results of step 3.jpg

Once this is done, you should try it out. To do so may require using a different trigger from the date/time option, but you can easily change that at will. Quit Keyboard Maestro once you set your temporary trigger. The menubar extra will stay running to make the commands available. When you open Safari, you will see the floating palette pop up. Click on it and select your macro group to activate it. Then run the macro using your temporary trigger to see if it functions as expected. If so, you can go back and change the trigger back to the timed one.

Obviously you will need to tweak the steps to match your specific task, but this should get you on the right track.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top