This script gets ~3,000 Downloads per week! And is an amazingly popular sub-thread on the AutoHotkey forum
The tool was first created in April of 2012. This means for nearly 10 years Rodolfo has worked on this on his own time! If you’ve ever benefited from using the tool, please consider donating to him. I did as, when I was first learning AHK, I used his tool to help see what code was being generated.
If you want to take it to the net level with AutoHotkey_H, you can watch this AutoHotkey Webinar where HotkeyIt (author of AutoHotkey_H) walks through the “long way” to compile an AutoHotkey script with AutoHotkey_H. It’s really complicated and doesn’t add too much more of protection so I highly recommend doing the approach I do in the video!
We had an awesome webinar today! Jean Lalonde, author of Quick Access Popup, lead us on a great webinar today regarding how to use GitHub to with our AutoHotkey scripts & programs. BTW we streamed the webinar live to this AutoHotkey Facebook group.
AutoHotkey script for Automating Chrome to Set Text & Click a button
#Include ;Remember to put Chrome in your library folder
page:=Chrome.GetPageByTitle("AutoHotkey Community","contains") ;This will connect to the second index of a specific tab
MsgBox % "That wasn' t object / the page wasn't found"
Variable =document.querySelector('#keywords').value ='Chrome.ahk'
page.Evaluate("document.querySelector('#keywords').value ='" var "'")
page.Evaluate("document.querySelector('#search > fieldset > button').value ='Chrome.ahk'")
Notes for Automating Chrome to Set Text & Click a button
00:36 Go to AutoHotkey.com/boards/
00:44 Connect to tab using Chrome.GetPageByTitle(“AutoHotkey Community”) ;the default matchtype is “starts with”
01:23 Look at page structure using right-click and Inspect. This opends Devtools with that element selected.
01:46 It has an ID of “keywords”, copy js path. Which will give you queryselector(“#keywords”)
02:26 Use the .value to set some text in that box.
05:54 The button is right next to the input. You can go back to the page and right-click the button, then hit Inspect
06:13 Test the new js path. Instead of using .value, use .click
06:42 Test in Chrome developer tool
07:18 When running an Evaluate method, it waits for the previous Evaluate to finish (so no need to sleep between them).
07:44 If you run into a problem where you think it is happening too quickly, check the forum for some solutions
08:40 Sometimes what you want to input won’t always be a static string. If you’re trying to reference a variable, you need to use the expression syntax. In an expression, you’re not just assigning text, you’re doing math or making function calls.
page.Evaluate(“document.querySelector(‘#keywords’).value ='” var “‘”) “‘”)
10:48 This works because AutoHotkey splits everything up on a given line. First is a name of a function, then says this is inside the function, then this is text inside a function. Then builds from left to right as to the string that will be used.
12:15 AutoHotkey proceeds left to right when evaluating an expression
12:40 when you use := you’re in expression assignment mode.
13:25 With just single = you’re in plain-text mode. It reads it as text
15:00 When automating a site, you don’t know what kind of buffer’s they have to prevent scraping / botting.
15:49 When you start automating, you might start seeing Captcha’s everywhere
16:04 Sites get really good at looking like a normal site to a user, but looking like an impenetrable fortress to code