Partial web automation - keyboard shortcuts

Get help with using AutoHotkey and its commands and hotkeys
foo-barbie
Posts: 2
Joined: 22 Oct 2019, 10:24

Partial web automation - keyboard shortcuts

22 Oct 2019, 10:29

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?
gregster
Posts: 3389
Joined: 30 Sep 2013, 06:48

Re: Partial web automation - keyboard shortcuts

22 Oct 2019, 10:41

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!
Getfree
Posts: 217
Joined: 12 Oct 2014, 18:00

Re: Partial web automation - keyboard shortcuts

22 Oct 2019, 14:04

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.
foo-barbie
Posts: 2
Joined: 22 Oct 2019, 10:24

Re: Partial web automation - keyboard shortcuts

23 Oct 2019, 04:35

@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.
johnqflorida
Posts: 5
Joined: 22 Oct 2019, 09:02

Re: Partial web automation - keyboard shortcuts

23 Oct 2019, 20:38

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.

Return to “Ask For Help”

Who is online

Users browsing this forum: DMDComposer, Google [Bot] and 255 guests