A guide to automation using AHK with Chrome
What is AHK?A scripting language for desktop automation. Find out more from this link: https://www.autohotkey.com/
What are the requirements?
- Windows Operating system
- Install AHK from https://www.autohotkey.com/
- Install GitHub Desktop https://desktop.github.com/ if you haven't
- Then Git clone https://github.com/G33kDude/Chrome.ahk.git
- Install Google Chrome https://www.google.com/chrome/ if you haven't
On this tutorial, I will be demonstrating some examples of how you can launch a browser, input some fields then click on a few buttons. All can be done automatically!
Click on this GIF for better view 👆Once you have setup above requirements, you can navigate to your Git cloned folder.
Now we right-click on the empty space and create an AutoHotkey Script.
We are going to rename it as Login.ahk
Then right-click on the Login.ahk and select Edit Script
It should open a notepad or you may open with your favourite editor.
Paste in below codes for the sample.
#SingleInstance Force #Include ../Chrome.ahk FileCreateDir, ChromeProfile ChromeInst := new Chrome("ChromeProfile") PageInst := ChromeInst.GetPage() PageInst.Call("Page.navigate", {"url": "https://dagiccross.github.io/bootstrap_sample_page/index.html"}) PageInst.WaitForLoad() Sleep 1500 PageInst.Evaluate("document.getElementById('Email').value='example@email.com'") Sleep 1000 PageInst.Evaluate("document.getElementById('Password').value='Mypassword'") Sleep 1000 PageInst.Evaluate("document.querySelector('#Remember').click()") Sleep 1000 PageInst.Evaluate("document.querySelector('body > div > select').value=""1""") Sleep 1000 PageInst.Evaluate("document.querySelector('#customCheck1').checked = true") Sleep 1000 PageInst.Evaluate("document.getElementById('submit').click()") ;PageInst.Call("Browser.close") ;PageInst.Disconnect() ;ExitApp return
Now watch the automation goes live like the GIF I showed above! 😀
Free feel to comment below if anything you wish to know more or some roadblock setting this up.
I might be able to explain more of how the code works in the future when I got free time! 🙏
Now let's do the same on Powershell?
ReplyDeletehttps://www.techmation.xyz/2020/06/how-to-automate-website-actions-using.html
Deletethere you go!