- Is there a way to get the urls for all open tabs directly? Instead of Ctrl+Tab and using Acc/Ctrl+C.
- Many thanks for this GeekDude.
[Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No IE!
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
DanielToward13 wrote:Thanks GeekDude. That’s great!
You could run some javascript on the page that gets the scroll position and use the returned value. For example:DanielToward13 wrote:is there a way to get the scroll bar position in order to know where in the page the current view is?
Code: Select all
Loop
{
Position := Tab.Evaluate("window.pageYOffset / (document.body.clientHeight - window.innerHeight)").value
ToolTip, %Position%
Sleep, 500
}
Chrome.GetTabs() returns an array of all loaded tabs/pages/documents (including also extension configuration pages).jeeswg wrote:- Is there a way to get the urls for all open tabs directly? Instead of Ctrl+Tab and using Acc/Ctrl+C.
Code: Select all
for Index, Tab in Chrome.GetTabs()
MsgBox, % "type: " Tab.type "`nurl: " Tab.url
jeeswg wrote:- Many thanks for this GeekDude.
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Extremely interesting! Bookmarked.
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
How do turn off the left|right|other tab?
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Good stuff, was wondering if anyone has played around with any chromecast automation yet? Haven't had much luck here...
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
First fix was easy. Simply add https://github.com/G33kDude/WebSocket.ahk , https://github.com/cocobelgica/AutoHotkey-JSON to the already existing (empty) Folders.
But then i got this error mesage by starting example https://github.com/G33kDude/Chrome.ahk/ ... jectJS.ahk
This error happens inside Jxon_Dump(obj, indent:="", lvl:=1){ ... https://github.com/cocobelgica/AutoHotk ... n.ahk#L174
i dont know why this recursive call not works. hmm
But then i got this error mesage by starting example https://github.com/G33kDude/Chrome.ahk/ ... jectJS.ahk
This error happens inside Jxon_Dump(obj, indent:="", lvl:=1){ ... https://github.com/cocobelgica/AutoHotk ... n.ahk#L174
Code: Select all
------- AHKVersion 1.1.28.00 --------------------
InjectJS.ahk > Jxon.ahk (174) : ==> Call to nonexistent function.
Specifically: Jxon_Dump(k) : q . k . q ) . ( indent ? ": " : ":" )
>Exit code: 2 Time: 0.5602
github>g_IntelliSense + next improvements + forum
ahk..org>onlineAHKprettyfy, ahk..com>Refactoring
ahk..com>newposts Unanswrd myposts, Donations are appreciated if I could help you
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
ahk..org>onlineAHKprettyfy, ahk..com>Refactoring
ahk..com>newposts Unanswrd myposts, Donations are appreciated if I could help you
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Chrome.ahk depends on this specific version https://github.com/G33kDude/AutoHotkey- ... 38238f81e1 of AutoHotkey-JSON that has been forked and modified from Cocobelgica's original to allow for Boolean JSON values and to allow it to exist alongside other versions of AutoHotkey-JSON. You can find that version by clicking through the repository on the GitHub webpage, or by going to the releases tab and downloading the release which includes all of the required dependencies.SL5 wrote:First fix was easy. Simply add https://github.com/G33kDude/WebSocket.ahk , https://github.com/cocobelgica/AutoHotkey-JSON to the already existing (empty) Folders.
But then i got this error mesage by starting example https://github.com/G33kDude/Chrome.ahk/ ... jectJS.ahk
This error happens inside Jxon_Dump(obj, indent:="", lvl:=1){ ... https://github.com/cocobelgica/AutoHotk ... n.ahk#L174i dont know why this recursive call not works. hmmCode: Select all
------- AHKVersion 1.1.28.00 -------------------- InjectJS.ahk > Jxon.ahk (174) : ==> Call to nonexistent function. Specifically: Jxon_Dump(k) : q . k . q ) . ( indent ? ": " : ":" ) >Exit code: 2 Time: 0.5602
GeekDude wrote:Make sure you're downloading the release file "Chrome.ahk_v1.0.zip" from the releases page, not the source code. As you have learned, GitHub does not include submodules (i.e. AutoHotkey-JSON and WebSocket.ahk) in its source downloads. The release has all the #Include's built in (no lib folder needed ).
-
- Posts: 1259
- Joined: 16 Apr 2015, 09:41
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
In the "pastebin.ahk" example that GeekDude was nice enough to include in the release package, the Tab.Call("DOM.setAttributeValue", {"nodeId": NameNode.NodeId, "name": "value", "value": "ChromeBot"}) line assigns a value to an input field. How would I go about retrieving the value after it was assigned?
Looking over the protocol documentation, there does not appear to be a DOM.getAttributeValue or anything similar. The following snippet is the best I could come up with, but all I get is a single message box with "attributes" = ""...
Looking over the protocol documentation, there does not appear to be a DOM.getAttributeValue or anything similar. The following snippet is the best I could come up with, but all I get is a single message box with "attributes" = ""...
Code: Select all
NameNode := Tab.Call("DOM.querySelector", {"nodeId": RootNode.nodeId, "selector": "input[name=name]"})
Tab.Call("DOM.setAttributeValue", {"nodeId": NameNode.NodeId, "name": "value", "value": "ChromeBot"})
TheNode := Tab.Call("DOM.getAttributes", {"nodeId": NameNode.NodeId})
For k, v in TheNode
MsgBox "%k%" = "%v%"
- Joe Glines
- Posts: 771
- Joined: 30 Sep 2013, 20:49
- Location: Dallas
- Contact:
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
I don't have an example I can post right now but I "solved this" by inserting Java script.Shadowpheonix wrote:In the "pastebin.ahk" example that GeekDude was nice enough to include in the release package, the Tab.Call("DOM.setAttributeValue", {"nodeId": NameNode.NodeId, "name": "value", "value": "ChromeBot"}) line assigns a value to an input field. How would I go about retrieving the value after it was assigned?
Sign-up for the HK Newsletter
AHK Tutorials:Web Scraping | | Webservice APIs | AHK and Excel | Chrome | RegEx | Functions
Training: AHK Webinars Courses on AutoHotkey
YouTube
Quick Access Popup, the powerful Windows folders, apps and documents launcher!
AHK Tutorials:Web Scraping | | Webservice APIs | AHK and Excel | Chrome | RegEx | Functions
Training: AHK Webinars Courses on AutoHotkey
YouTube
Quick Access Popup, the powerful Windows folders, apps and documents launcher!
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
I want to do Page.printToPDF with a few parameters on a local .html file. Can Chrome.ahk help me do that without rendering the .html in the Chrome window? Any code examples for that would be very appreciated. I want to do the conversion with as little delay as possible.
There is also the simpler and headless command line method
But apparently the printToPDF parameters aren't and won't be implemented for the command line command.
There is also the simpler and headless command line method
Code: Select all
chrome --headless --disable-gpu --print-to-pdf="C:/test/1.pdf" "C:\test\1.html"
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Any particular reason to use Chrome to print pdfs? There are headless solutions which easy scripting options:
* http://phantomjs.org/ (google phantomjs print pdf for example scripts, you don't need to install it, just unzip the download)
* https://github.com/wkhtmltopdf/wkhtmltopdf/
* http://phantomjs.org/ (google phantomjs print pdf for example scripts, you don't need to install it, just unzip the download)
* https://github.com/wkhtmltopdf/wkhtmltopdf/
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Thanks for your work on this, GeekDude! It's a bit above my ability to fully understand, but I wonder: Would it be possible to use this for setting the default printer in Chrome? I have a nice AHK script that (at system startup) reads my IP address, then sets my default Windows printer. Chrome doesn't use the Windows default printer though. It merely reverts to whatever printer was last used.
ste(phen|ve) kunkel
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
No super strong reason really.Guest wrote:Any particular reason to use Chrome to print pdfs? There are headless solutions which easy scripting options:
* http://phantomjs.org/ (google phantomjs print pdf for example scripts, you don't need to install it, just unzip the download)
* https://github.com/wkhtmltopdf/wkhtmltopdf/
But whtmltopdf hasn't been updated since 2016 and the Phantomjs main dev have called it quits and says Headless Chrome is the future.
So I figure I might as well try to learn to work with Headless Chrome. Chrome.ahk looks like a convenient way to start for me, compared to going down the Node and Puppeteer path.
- ramonstart
- Posts: 16
- Joined: 26 Apr 2016, 09:00
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Hello
Why does the Jxon_Dump method return the "menor preu00E7o do livro" value when the correct text is "menor preço do livro"?
I'm using the call below to bring the content of the list that is in the url https://www.estantevirtual.com.br/livro ... 20Kiyosaki
Would you help me?
Why does the Jxon_Dump method return the "menor preu00E7o do livro" value when the correct text is "menor preço do livro"?
I'm using the call below to bring the content of the list that is in the url https://www.estantevirtual.com.br/livro ... 20Kiyosaki
Would you help me?
-
- Posts: 1259
- Joined: 16 Apr 2015, 09:41
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Joe Glines wrote:I don't have an example I can post right now but I "solved this" by inserting Java script.Shadowpheonix wrote:In the "pastebin.ahk" example that GeekDude was nice enough to include in the release package, the Tab.Call("DOM.setAttributeValue", {"nodeId": NameNode.NodeId, "name": "value", "value": "ChromeBot"}) line assigns a value to an input field. How would I go about retrieving the value after it was assigned?
If you happen to come up with an example you can post, it would be most appreciated.
- Joe Glines
- Posts: 771
- Joined: 30 Sep 2013, 20:49
- Location: Dallas
- Contact:
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
I'll try and work on it this weekend. I was in the middle of converting all of my examples to functions (so they'd be easy to adapt) when I got busy...Shadowpheonix wrote:If you happen to come up with an example you can post, it would be most appreciated.
Sign-up for the HK Newsletter
AHK Tutorials:Web Scraping | | Webservice APIs | AHK and Excel | Chrome | RegEx | Functions
Training: AHK Webinars Courses on AutoHotkey
YouTube
Quick Access Popup, the powerful Windows folders, apps and documents launcher!
AHK Tutorials:Web Scraping | | Webservice APIs | AHK and Excel | Chrome | RegEx | Functions
Training: AHK Webinars Courses on AutoHotkey
YouTube
Quick Access Popup, the powerful Windows folders, apps and documents launcher!
- Joe Glines
- Posts: 771
- Joined: 30 Sep 2013, 20:49
- Location: Dallas
- Contact:
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Okay, I created a function which should help some people (noobs). It leverages GeekDude's Chrome class.
You can get the function here
And this is a video walking through how to use it. It isn't great, but will help some people get their feet wet.
You can get the function here
And this is a video walking through how to use it. It isn't great, but will help some people get their feet wet.
Sign-up for the HK Newsletter
AHK Tutorials:Web Scraping | | Webservice APIs | AHK and Excel | Chrome | RegEx | Functions
Training: AHK Webinars Courses on AutoHotkey
YouTube
Quick Access Popup, the powerful Windows folders, apps and documents launcher!
AHK Tutorials:Web Scraping | | Webservice APIs | AHK and Excel | Chrome | RegEx | Functions
Training: AHK Webinars Courses on AutoHotkey
YouTube
Quick Access Popup, the powerful Windows folders, apps and documents launcher!
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
Is there any reason everytime chrome opens, it shows something about windows defender wanting to reset my chrome preferences and adobe and google drive keep wanting to install? this is weird.
-
- Posts: 1259
- Joined: 16 Apr 2015, 09:41
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
This function definitely has a lower learning curve to it than Tab.Call() and Tab.Evaluate() for writing values. Thank you for posting it.Joe Glines wrote:Okay, I created a function which should help some people (noobs). It leverages GeekDude's Chrome class.
You can get the function here
And this is a video walking through how to use it. It isn't great, but will help some people get their feet wet.
However, this still leaves me clueless as to how to read an existing value from a web page in Chrome without having to install Selenium.
-
- Posts: 1259
- Joined: 16 Apr 2015, 09:41
Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!
This sounds like a problem with either your Chrome profile or with an extension/plugin you have installed in Chrome.fenchai wrote:Is there any reason everytime chrome opens, it shows something about windows defender wanting to reset my chrome preferences and adobe and google drive keep wanting to install? this is weird.
If you haven't already done so, try running with a brand new profile in Chrome and see if the issue still occurs. I am not sure what else to suggest if that fails.
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: Chunjee and 96 guests