[Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No IE!
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Thanks for the link. I really hope we can test and use this soon.
-
- Posts: 144
- Joined: 01 Feb 2017, 22:57
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
@teadrinker Should LightJson also escape special chars in keys? I was using LightJson.stringify to serialize an AHK object with keys having unusal like: "lalt+\" (representing a shortcut), and the output isn't correct. I believe JSON standard allows any string to be keys.
But of course, there's always whether the extra escaping is worth the performance tradeoff ...
But of course, there's always whether the extra escaping is worth the performance tradeoff ...
-
- Posts: 4344
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
@20170201225639
I think you are right, this is a flaw. Fixed:
I think you are right, this is a flaw. Fixed:
Code: Select all
obj := {"a + \": "a + \", "b + /": {"a + \": "a + \"}}
MsgBox, % json := LightJson.Stringify(obj, " ")
obj := LightJson.Parse(json)
MsgBox, % obj["b + /", "a + \"]
class LightJson
{
static JS := LightJson.GetJS(), true := {}, false := {}, null := {}
Parse(json, _rec := false) {
if !_rec
obj := this.Parse(this.JS.JSON.parse(json), true)
else if !IsObject(json)
obj := json
else if this.JS.Object.prototype.toString.call(json) == "[object Array]" {
obj := []
Loop % json.length
obj.Push( this.Parse(json[A_Index - 1], true) )
}
else {
obj := {}
keys := this.JS.Object.keys(json)
Loop % keys.length {
k := keys[A_Index - 1]
obj[k] := this.Parse(json[k], true)
}
}
Return obj
}
Stringify(obj, indent := "") {
if indent|1 {
for k, v in ["true", "false", "null"]
if (obj = this[v])
Return v
if IsObject( obj ) {
isArray := true
for key in obj {
if IsObject(key)
throw Exception("Invalid key")
if !( key = A_Index || isArray := false )
break
}
for k, v in obj
str .= ( A_Index = 1 ? "" : "," ) . ( isArray ? "" : this.Stringify(k, true) . ":" ) . this.Stringify(v, true)
Return str = "" ? "{}" : isArray ? "[" . str . "]" : "{" . str . "}"
}
else if !(obj*1 = "" || RegExMatch(obj, "^-?0|\s"))
Return obj
for k, v in [["\", "\\"], [A_Tab, "\t"], ["""", "\"""], ["/", "\/"], ["`n", "\n"], ["`r", "\r"], [Chr(12), "\f"], [Chr(8), "\b"]]
obj := StrReplace( obj, v[1], v[2] )
Return """" obj """"
}
sObj := this.Stringify(obj, true)
Return this.JS.eval("JSON.stringify(" . sObj . ",'','" . indent . "')")
}
GetJS() {
static Doc, JS
if !Doc {
Doc := ComObjCreate("htmlfile")
Doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
JS := Doc.parentWindow
( Doc.documentMode < 9 && JS.execScript() )
}
Return JS
}
}
-
- Posts: 144
- Joined: 01 Feb 2017, 22:57
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Wow, thanks for the quick update @teadrinker !
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Hello, I am trying to access this node:
<input aria-label="foo" maxlength="10" autocomplete="off" type="text" class="input_input__2qx3X form-control" aria-invalid="false" value="">
using @Geekdude 's trick (I am a really newbie javascript programmer):
[].filter.call(document.querySelectorAll('input'), (e) => e.aria-label.match('foo'))[0]
unfortunately the trick doesn't work (even in the devtools console mode) because "aria-label" contain a minus sign inside of it.
How can I refeer to this kind of node?
Thank you so much
EDIT: SOLVED!
The line below does the trick
[].filter.call(document.querySelectorAll('input'), (e) => e.ariaLabel.match('foo'))[0]
<input aria-label="foo" maxlength="10" autocomplete="off" type="text" class="input_input__2qx3X form-control" aria-invalid="false" value="">
using @Geekdude 's trick (I am a really newbie javascript programmer):
[].filter.call(document.querySelectorAll('input'), (e) => e.aria-label.match('foo'))[0]
unfortunately the trick doesn't work (even in the devtools console mode) because "aria-label" contain a minus sign inside of it.
How can I refeer to this kind of node?
Thank you so much
EDIT: SOLVED!
The line below does the trick
[].filter.call(document.querySelectorAll('input'), (e) => e.ariaLabel.match('foo'))[0]
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Pretty cool, I'll also have a play with it.geek wrote: ↑16 Jan 2018, 17:38Chrome.ahk
Automate Google Chrome using native AutoHotkey.
Watch the full playlist on YouTube
How it works
[...]
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Hi. Can I use chrome.ahk to move content in the window? I mean this, don't know how to name it correct:
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
So I was doing some investigating with an issue that popped up, and noticed when I browse to localhost:9222, I get this message:
Will this have any impact on the ability to interact with Chrome? From the way the way it's worded in the subsequent link, I can't tell if the /json data will still be leveraged but you just won't be able to navigate to the URL in the browser?
Will this have any impact on the ability to interact with Chrome? From the way the way it's worded in the subsequent link, I can't tell if the /json data will still be leveraged but you just won't be able to navigate to the URL in the browser?
Chuck Norris doesn't need garbage collection because he doesn't call .Dispose(), he calls .DropKick().
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
I do agree that is the case, though I haven't reviewed any more information on the subject than you have.kagato wrote: ↑14 Dec 2021, 23:08So I was doing some investigating with an issue that popped up, and noticed when I browse to localhost:9222, I get this message:
Will this have any impact on the ability to interact with Chrome? From the way the way it's worded in the subsequent link, I can't tell if the /json data will still be leveraged but you just won't be able to navigate to the URL in the browser?
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
According to following comment from above issue: https://bugs.chromium.org/p/chromium/issues/detail?id=1232509kagato wrote: ↑14 Dec 2021, 23:08So I was doing some investigating with an issue that popped up, and noticed when I browse to localhost:9222, I get this message:
Will this have any impact on the ability to interact with Chrome? From the way the way it's worded in the subsequent link, I can't tell if the /json data will still be leveraged but you just won't be able to navigate to the URL in the browser?
They will not remove Puppeteer support as Puppeteer uses webSocketDebuggerUrl resolved by url: LocalHost:9222/json/list to control chrome
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Unfortunately, at the link seems to stand the development.Tre4shunter wrote: ↑29 Sep 2021, 12:53@Milchmann ,
afaik there are a few people (Including the G33k himself) working on modifying the lib to use websockets without IE.
Check this thread out:
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=94895&p=421942#p421942
Does anyone have another idea?
Thanks
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Chrome.ahk using websocket client from IE activeX, and there is no IE in windows 11 but activeX is available and I haven't check but chrome.ahk should work fine,Milchmann wrote: ↑28 Jan 2022, 03:53Unfortunately, at the link seems to stand the development.Tre4shunter wrote: ↑29 Sep 2021, 12:53@Milchmann ,
afaik there are a few people (Including the G33k himself) working on modifying the lib to use websockets without IE.
Check this thread out:
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=94895&p=421942#p421942
Does anyone have another idea?
Thanks
I am also sure GeekDude is working on Websocket client.
I have also tried different ways to get a solid Websocket client class which can support Chrome.ahk the link you posted above can make single Websocket connection if you deep dive into it, you find reasons why,
There is also a Websocket client lib written in 100% AHK by Shadownrun based on socket.ahk also by geek dude,
here is the link https://github.com/gustavooavila/Autohotkey-Websocket-Client
I tried to merge this Shadownrun's WS client into chrome.ahk and it worked for short messages, I find Shadownrun's WS client unable to parse/ process fragmented messages due to wrong opcode and fin bit issue, I am into different projects that's why I gave up until I finish those projects. or may be its beyond my understanding, coz I have read through whole RFC https://datatracker.ietf.org/doc/html/rfc6455 spent hours of debugging.
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Thank you for your efforts. I still hope that there will be an alternative in the future, without IE support.
Otherwise I can't use the chrome.ahk anymore.
Are there any other options to Chrome.ahk to work with Chrome? I have neither admin rights nor IE support at work. What works fine so far (until Chrome version 88.0) is viewtopic.php?f=7&t=32323#p150532. That's why I have the Chrome version frozen at the state.
But in the new versions of Chrome there are now windows that are no longer displayed in the old version of Chrome. In perspective, I can only use the current versions.
Thanks
Bert
Translated with www.DeepL.com/Translator (free version)
Otherwise I can't use the chrome.ahk anymore.
Are there any other options to Chrome.ahk to work with Chrome? I have neither admin rights nor IE support at work. What works fine so far (until Chrome version 88.0) is viewtopic.php?f=7&t=32323#p150532. That's why I have the Chrome version frozen at the state.
But in the new versions of Chrome there are now windows that are no longer displayed in the old version of Chrome. In perspective, I can only use the current versions.
Thanks
Bert
Translated with www.DeepL.com/Translator (free version)
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Hello there!
Thanks for the library @geek , i am trying to use it to replace IE COM code in some of my scripts (since IE doesn't work in Windows 11).
However i am getting a security error screen when trying to connect to a chrome instance using Chrome.getpage()
Is this also a Windows 11 problem? Does anyone have any ideas on how to solve this?
Thanks for the library @geek , i am trying to use it to replace IE COM code in some of my scripts (since IE doesn't work in Windows 11).
However i am getting a security error screen when trying to connect to a chrome instance using Chrome.getpage()
Spoiler
Is this also a Windows 11 problem? Does anyone have any ideas on how to solve this?
"What is suitable automation? Whatever saves your day for the greater matters."
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!
Archmage Gray - A fantasy shooter game fully coded in AutoHotkey
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!
Archmage Gray - A fantasy shooter game fully coded in AutoHotkey
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
@Gio, I still sometimes get that error script errors (not sure about the security error). Does it do that for all pages? EDIT: I don't have Windows 11, though. Windows 10.
Regards,
burque505
Regards,
burque505
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Hi @burque505, thanks for the reply.
Yes, it happens even if i try to connect while chrome is displaying some other page. I can't even use the library at all since the issue occurs at the beginning of the chrome code.
I also forgot to mention that i have already tried modifying chromes default path to add --remote-debugging-port=9222 (to no avail).
Yes, it happens even if i try to connect while chrome is displaying some other page. I can't even use the library at all since the issue occurs at the beginning of the chrome code.
I also forgot to mention that i have already tried modifying chromes default path to add --remote-debugging-port=9222 (to no avail).
"What is suitable automation? Whatever saves your day for the greater matters."
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!
Archmage Gray - A fantasy shooter game fully coded in AutoHotkey
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!
Archmage Gray - A fantasy shooter game fully coded in AutoHotkey
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Read first page of the topic.
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
@malcev thank you, the post below solved the issue.
geek wrote: ↑21 Jan 2018, 12:08You can disable this block (not sure how this effects general security of IE) by following the steps in this StackOverflow post.
"What is suitable automation? Whatever saves your day for the greater matters."
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!
Archmage Gray - A fantasy shooter game fully coded in AutoHotkey
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!
Archmage Gray - A fantasy shooter game fully coded in AutoHotkey
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
The following snippet works:
However that tab's page content isn't visible, how do I bring that tab into focus so you can see the alert or more specifically anything I do in that page.
Code: Select all
PageInstance := ChromeInst.GetPageBy("url", "https://recordsearch.naa.gov.au", "startswith")
PageInstance.Evaluate("alert('Got page by URL!');")
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Trydbareis wrote: ↑09 Feb 2022, 00:40The following snippet works:
However that tab's page content isn't visible, how do I bring that tab into focus so you can see the alert or more specifically anything I do in that page.Code: Select all
PageInstance := ChromeInst.GetPageBy("url", "https://recordsearch.naa.gov.au", "startswith") PageInstance.Evaluate("alert('Got page by URL!');")
Code: Select all
PageInstance.Call("Page.bringToFront")