Page 1 of 1

Partial web automation - keyboard shortcuts

Posted: 22 Oct 2019, 10:29
by foo-barbie
I am looking for a way to partially automate a website based on where you are on a page, similar to "IfWinActive" command in AHK.

For example, if I am in page 1 and click F1, it does A, if I am in page 2 and click F1, it does B.

Is this possible in AHK?

Re: Partial web automation - keyboard shortcuts

Posted: 22 Oct 2019, 10:41
by gregster
Yes, via IE COM interface, Chrome.ahk oder Selenium webdriver - but it isn't necessarily beginner level stuff.
If you know some javascript - that would help.

Well, if you only want to check for a specific active tab and send a key, you could probably work instead with window titles and commands again. That would be easier... but you don't give enough details. Please elaborate!

Re: Partial web automation - keyboard shortcuts

Posted: 22 Oct 2019, 14:04
by Getfree
There are myriads of shortcut managers that do this on Chrome and other browsers. Just google "shortcut manager for <browser_name>".

If you want a recommendation, use this one: AutoControl Shortcut Manager
It can redefine Chrome's native shortcuts (like F1 in your case).

Otherwise, just search for one in the web store of your favorite browser. There's no need for coding a custom solution unless you want to do really advanced stuff.

Re: Partial web automation - keyboard shortcuts

Posted: 23 Oct 2019, 04:35
by foo-barbie
@gregster

I cannot match based on window title, because it does not change when I am navigating that specific website.

I need some solution where I can match based on website URL or some other page element, e.g. "H1", e.g.:
- If "foo.bar/mainpage" is active, then F1 clicks on a button to post stuff.
- If "foo.bar/optionspage" is active, then F1 unchecks three checkboxes and chooses a specific option form a dropdown.

Re: Partial web automation - keyboard shortcuts

Posted: 23 Oct 2019, 20:38
by johnqflorida
A non-AHK answer, is to look at Selenium, which includes Selenium IDE, a record and playback tool where you can start simple-ish, and take it as far as you want beyond the IDE if you were so inclined. It can wait for, click, check, read anything, including page loads, whether page elements exist or not including XPath, DOM, or CSS identifiable elements.

Like AHK, it's got a large base of people who love it, and a lot of Selenium users naturally use AHK in conjunction with it..

Also with the IDE (firefox only), the browser add-in responds to user input, so you could get creative, using AHK to right click and use some Selenium features without specifically creating a Selenium script. Or, go crazy, it's got a full programming framework too. But the IDE is a start.