|
|
#1 |
|
Script to cause a delayed click on webpage link?
I have a computer setup for remote control that is connected to the internet via a Clear Atlas wimax internet modem. I'm looking for a way to reset this modem remotely. There is a disconnect/connect button in it's local control webpage that when clicked disconnects the modem from the internet. I've found that when in front of this computer I can wait a few seconds and click connect again and it does what what I need it to do as far resetting. I'd like to write a script so that I can do this disconnect then reconnect routine while remotely controlling it. Basically, I need a way to cause another mouse click on the same button after some set amount of time. I started to play around with automator but had some problems. I'm looking for help and ideas about how to make this work.
|
|
|
|
0
|
|
|
#2 |
|
So interacting with a link/button on a page is probably a task best suited to Javascript.
Do you ever visit this page and NOT do what you are trying to do? If not, then you could pretty easily make a Safari Extension that checks the URL of the page, and if it matches certain criteria it executes the JS to do what you are trying to do. Then simply make shell or applescript to open safari, visit that url, and close the safari window. |
|
|
|
0
|
|
|
#3 |
|
Probably the easiest way is to just use a macro program. I like Keyboard Maestro for general purpose macros, but BetterTouchTool will work as well and it's free.
In BTT, you can define a shortcut (keyboard or mouse) to perform a series of actions. First define your shortcut to perform a left click, then attach two additional actions: a delay, followed by another left click. It's a bit of a kludge, but it's decidedly easier than mucking about with Javascript. |
|
|
|
0
|
|
|
#4 | |
|
Quote:
But I guess your creativity depends on what you are comfortable with. Behold the 'mucking' about it would take to click a button and then click it again after 5 seconds in Javascript. ![]() Code:
document.formName.buttonName.click();
setTimeout("document.formName.buttonName.click()", 5000);
|
||
|
|
0
|
|
|
#5 | |
|
Quote:
Great. Now how do you activate this code on a page that's dynamically generated by a wireless modem and may or may not have names actually assigned to the form and/or button in question? |
||
|
|
0
|
|
|
#6 |
|
If you are comfortable with html there is a simple programming method you can use.
Assuming this is a page hosted by your router, it probably doesn't have anything fancy going on in the html. Clicking the button probably just sends a post request to the form URL with a parameter. Most scripting languages have something equivalent to an HTTP Request object. You can populate the Request object's properties (url, post paramters, etc) with the information from the webpage. In effect, you build a script that sends a packet to the router saying that the restart button has been clicked. It will be one simple transaction that can be triggered by a timer or other event and does not requires doing any GUI hooks. I can walk you through the process if you need help. |
|
|
|
0
|
|
|
#7 | |
|
Quote:
The code would be activated by an installed safari extension. http://developer.apple.com/library/s...roduction.html It is very easy to make an extension, with a single global JS file that would effectively be triggered on every page you visit. Then a simple string compare with document.location.href to make sure you're on the page you want to run it on, and you're golden. In general, I'd probably look at the page itself and see if the same behavior could be duplicated by just using GET or POST parameters, or visiting a certain URL. If so I'd just script it with wget or curl. Either way, with only a marginal increase to the time it would take to script or set this up you could have it run every night at 3AM, run when you email yourself a certain subject line etc. |
||
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 01:21 AM.










Linear Mode
