if the chrome console returns some result using that same JS code then it should return the same result with evaluate() method.
make sure to use that JS on most outer / Parent frame in chrome console.
if the chrome console returns some result using that same JS code then it should return the same result with evaluate() method.
Thanks for the follow up. I thought that would be the case too. As you can see below, running the code in the 'top'/parent frame in the chrome console returns 'true' but unfortunately I cannot access it in the vResponsive variable. I will try to think of another way to check if the check boxes are checked.
Thank you very much!Xeo786 wrote: ↑11 Aug 2022, 03:52You need to Run chrome with headless parameter.Yogi wrote: ↑07 Aug 2022, 19:49Can you run chrome:
1) in the background
and
2) take a screenshot of a webpage using this without ever seeing the application?
Browny points for being able to tell it the region to capture.
I liked the IE.Visible = False command to get quick updates on things without launching the browser but sites don't really support it anymore.Code: Select all
Chrome := new Chrome(ProfileFolder,URL,"--headless")
and you need to call Page.captureScreenshot it will return Base64-encoded image which you need to decode and save.
Is there a chance the website is public? Sound like a problem I have before.Naits55 wrote: ↑17 Feb 2022, 21:16Hello guys,
I'm new to ahk and chrome.ahk... so I hope this question isn't too basic for you guys.
I have read trough the entire thread multiple times, watched all the videos and googled the crap out of this issue I have. But I'm unable to find a solution that works.
So I'm trying to enter a searchterm into a searchbox. The searchbox doesn't have an submit button, only way to activate it is by pressing enter on the keyboard.
I managed to populate the searchbox with:
Now I need to press enter...Code: Select all
document.querySelector(".jss618").innerText = "Example Search Term"
First problem is, that I can only manually select the searchbox. I didn't find a way of putting my cursor into the box. I tried:
are there any other options?Code: Select all
document.querySelector(".jss618").focus() document.querySelector(".jss618").click()
Also I tried manually selecting the box (just for testing) and sending enter key stroke through the console with code like this:
I tried all kinds of different types for this event and combinations I could think of.Code: Select all
page.Call("Input.dispatchKeyEvent", {"type" : "rawKeyDown","windowsVirtualKeyCode" : 13,"unmodifiedText" : "\r","text" : "\r"})
Only thing that works is this:
This will write into the searchbox. But only if i select it manually before sending this line. And also I can only submit by manually pressing enter. Which defeats the purpose of the whole thing.Code: Select all
page.Call("Input.dispatchKeyEvent", {"type" : "char", "text" : "Search Example"})
So does anyone have an idea what I'm doing wrong or what else I could try?
Thanks in advance!
following code will submit text and press enterbezet wrote: ↑26 Aug 2022, 03:14Is there a chance the website is public? Sound like a problem I have before.Naits55 wrote: ↑17 Feb 2022, 21:16Hello guys,
I'm new to ahk and chrome.ahk... so I hope this question isn't too basic for you guys.
I have read trough the entire thread multiple times, watched all the videos and googled the crap out of this issue I have. But I'm unable to find a solution that works.
So I'm trying to enter a searchterm into a searchbox. The searchbox doesn't have an submit button, only way to activate it is by pressing enter on the keyboard.
I managed to populate the searchbox with:
Now I need to press enter...Code: Select all
document.querySelector(".jss618").innerText = "Example Search Term"
First problem is, that I can only manually select the searchbox. I didn't find a way of putting my cursor into the box. I tried:
are there any other options?Code: Select all
document.querySelector(".jss618").focus() document.querySelector(".jss618").click()
Also I tried manually selecting the box (just for testing) and sending enter key stroke through the console with code like this:
I tried all kinds of different types for this event and combinations I could think of.Code: Select all
page.Call("Input.dispatchKeyEvent", {"type" : "rawKeyDown","windowsVirtualKeyCode" : 13,"unmodifiedText" : "\r","text" : "\r"})
Only thing that works is this:
This will write into the searchbox. But only if i select it manually before sending this line. And also I can only submit by manually pressing enter. Which defeats the purpose of the whole thing.Code: Select all
page.Call("Input.dispatchKeyEvent", {"type" : "char", "text" : "Search Example"})
So does anyone have an idea what I'm doing wrong or what else I could try?
Thanks in advance!
Code: Select all
page.evaluate("document.querySelector('.jss618').focus()") ; element into focus
page.Call("Input.dispatchKeyEvent", {"text" : "Search Example`n"}) ; `n will be translated to enter some web pages detect "`r" instead
Code: Select all
IfWinActive, YouTube on TV - Google Chrome
!f4::
chrome.tabs.remove(
tabIds: number | number[],
callback?: function,
)
return
It seems it requires modifying the library code,
Code: Select all
WB.Navigate("about:<!DOCTYPE html><meta http-equiv='X-UA-Compatible'"
. "content='IE=edge'><body></body>")
Code: Select all
WB.silent := true ; < -- this seems to work!
WB.Navigate("about:<!DOCTYPE html><meta http-equiv='X-UA-Compatible'"
. "content='IE=edge'><body></body>")
Code: Select all
browser := new Chrome(a_scriptDir "\ChromeProfile")
page := browser.getPage()
Code: Select all
doc := page.eval("document")
doc.querySelector("body").innerHTML := "
(ltrim
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
)"
Code: Select all
doc.querySelectorAll("li")[0].innerHTML := "<a href='https://autohotkey.com'>AutoHotkey</a>"
doc.querySelectorAll("li")[3].innerHTML := "<a href='https://google.com'>Google</a>"
for i, elem in (doc.querySelectorAll("a"), text := "")
text .= elem.innerText " (" elem.getAttribute("href") ")`n"
MsgBox % text
Code: Select all
func := page.eval("(function(a, b) { return a + b })")
MsgBox % func.call("", 3, 5)
Code: Select all
arr := page.eval("['hello', 'world']")
for i, v in (arr, text := "")
text .= i ": " v "`n"
MsgBox % text
Code: Select all
js := page.eval("window")
js.myVar := "ahk is awsome"
MsgBox % page.eval("myVar")
Code: Select all
for vKey, oPage in Chrome.GetPageList()
if oPage.type = "page"
{
PageInst := Chrome.GetPageBy("id", oPage.id)
Sleep, 10000 ;I set some really big sleeps, so I'm sure that problem is here:
PageInst.Call("Target.activateTarget", {targetId: oPage.id}) ;here chrome window suddenly activates.
Sleep, 10000
; here's some code
PageInst.Disconnect()
}
Code: Select all
for vKey, oPage in Chrome.GetPageList()
if oPage.type = "page"
{
PageInst := Chrome.GetPageBy("id", oPage.id)
Try
PageInst.WaitForLoad()
PageInst.Disconnect()
}
Hi. On basics - in that test script there's some part like this:
Code: Select all
FileCreateDir, ChromeProfile
ChromeInst := new Chrome("ChromeProfile")
Code: Select all
#Include Chrome.ahk
F1::
{
PageInst := Chrome.GetPage(1) ; I'm just connecting to already existing chrome, to latest active tab (that's tab that if opened now).
PageInst.Call("Page.navigate", {"url": "https://autohotkey.com/"}) ; This opens ahk site in tab.
PageInst.WaitForLoad() ; this is waiting untill page will finish loading.
PageInst.Disconnect() ; Don't forget to disconnect from tab when work in that tab is done.
Return
}
I really appreciate the help. Here's what I tried:Gh0sTG0 wrote: ↑18 Nov 2022, 12:15If you want to use chrome.ahk with already created instance of chrome, you should start your script with:
1) you already have chrome launched with debugging port;
2) in your script you have (for example I'm writing mini-script that works on F1 button press):Code: Select all
#Include Chrome.ahk F1:: { PageInst := Chrome.GetPage(1) ; I'm just connecting to already existing chrome, to latest active tab (that's tab that if opened now). PageInst.Call("Page.navigate", {"url": "https://autohotkey.com/"}) ; This opens ahk site in tab. PageInst.WaitForLoad() ; this is waiting untill page will finish loading. PageInst.Disconnect() ; Don't forget to disconnect from tab when work in that tab is done. Return }
Return to “Scripts and Functions (v1)”
Users browsing this forum: PuzzledGreatly and 176 guests