How to pass JavaScript variable, array, objects to/from Auto Hotkey in Chrome.ahk
Code: Select all
#NoEnv
SetBatchLines, -1
#Include <Chrome>
#SingleInstance, force
FileCreateDir, ChromeProfile
chrome := new Chrome("ChromeProfile")
page := chrome.GetPage()
if !(page := chrome.GetPage())
{
MsgBox, Could not retrieve page!
chrome.Kill()
}
else
{
page.Call("Page.navigate", {"url": "https://www.daraz.com.bd/smartphones/"})
JS =
(;Javascript Code
var cart = [];
var card = document.querySelectorAll(".c16H9d");
for (var i=0; i<card.length; i++){
cart.push(card[i].innerText);
}
)
page.WaitForLoad()
page.Evaluate(JS)
MsgBox, % page.Evaluate("JSON.stringify(cart)").value
}
ExitApp
return
- 1. cart := page.Evaluate(JS).value
2. cart := page.Evaluate(JS).key
3. cart := page.Evaluate(JS).data
4. cart := page.Evaluate(JS)
5. adding function to js
6. searching answer everywhere possible
7. eventcallback included with Chrome.ahk
I just need a way to pass variable to ahk or write json from javascript.I want to check certain websites for product with class loop. Than check every products if they already owned by me with the help of json or similar technique, if not owned I want to purchase theme. Add new purchased products to database.
Thank you for reading.