Automatically detecting URL and clicking buttons

Hi there all!

I was wondering whether it is possible to create a macro that when it automatically detects that a URL has been opened in Safari it will either click a button or enter a username/password and then click a button?

I am familiar with the ‘click a button’ function, but I am hoping to trigger the macro when it detects a particular URL, which I don’t necessarily want to type. I am hoping that sites I frequently visit with warnings about security certificates etc, or the need to constantly enter username and passwords to get on the wireless network at uni will be done automatically.

Thanks, in advance, for any assistance or advice you are able to offer!

No, there is no way to trigger a macro when you visit a URL - there is no system hook I could watch for that, so it would mean polling and then would be prohibitively expensive in CPU/energy.

You will have to trigger the macro by some other means. The triggered macro could then detect the current web page and behave appropriately for that web page, so you could use a single macro which you just trigger every time a web page annoys you and Keyboard Maestro “fixes” it.

1 Like

How about every time Safari comes to front, KM checks to see if the URL matches a specified address, and if so it proceeds to execute additional actions?

Keyboard Maestro won’t do it, but it might be possible.

“UI Actions brings “universal attachability” to AppleScript, greatly enhancing your control over applications running on your computer. Attach a UI Action script to any standard native Mac OS X application, and UI Actions automatically runs the script whenever you perform specified user actions in the target application. You write the script, and you select the user action that triggers it, such as choosing a menu item, changing the value of a text field, opening a drawer or window, or activating an application.”

You have to be willing to shell out $35.00 U.S. though, and it’s not very simple to use (last time I looked).

There is a demo.