[Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No IE!

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
Sabestian Caine
Posts: 528
Joined: 12 Apr 2015, 03:53

Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!

Post by Sabestian Caine » 02 Jan 2023, 11:19

@Gh0sTG0
PLEASE HELP ME SIR REGARDING THE ABOVE QUESTION....̣.,,🙏🙏🙏
I don't normally code as I don't code normally.

Gh0sTG0
Posts: 55
Joined: 25 Jun 2018, 07:58

Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!

Post by Gh0sTG0 » 02 Jan 2023, 11:22

@Sabestian Caine
Sorry, no ideas what's not right with facebook. Never used that platform.

User avatar
Sabestian Caine
Posts: 528
Joined: 12 Apr 2015, 03:53

Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!

Post by Sabestian Caine » 02 Jan 2023, 12:17

@Gh0sTG0
OK SIR...THANK YOU SO MUCH....
I don't normally code as I don't code normally.

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!

Post by swagfag » 02 Jan 2023, 12:26

jesus christ, my dear sirs. just learn CSS selectors already!! lmao
ure posting the same question every other month, except adjusted for whatever element u happen to not be able to find at the time...

close ahk now. open internet explorer. start reading this page https://developer.mozilla.org/en-US/docs/Web/API/Document_object_model/Locating_DOM_elements_using_selectors. any link u are unable to immediately say what its about, u click on and continue reading its doc page. do that for 1 week straight, then go back to writing ur ahk

ure unfriending people with too restrictive a selector that breaks as soon as the DOM updates. u need to think and craft a different selector, capable of accounting for whatever shenanigangs the DOM ends up throwing at u, not copypaste whatever hardcoded selector the browser happen to generate for the element u were looking at

User avatar
Sabestian Caine
Posts: 528
Joined: 12 Apr 2015, 03:53

Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!

Post by Sabestian Caine » 03 Jan 2023, 11:59

@swagfag

ok thank you sir... :thumbup:
I don't normally code as I don't code normally.

rapp
Posts: 7
Joined: 22 May 2019, 23:19

Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!

Post by rapp » 20 Jan 2023, 12:33

Whenever I run any script that utilizes chrome.ahk, I get the SecurityError referenced above. Chrome.ahk worked really well for at least a year. Something must have changed on my system. I have increased the number of sockets but still get the same error. Any suggestions?

leosouza85
Posts: 90
Joined: 22 Jul 2016, 16:28

Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!

Post by leosouza85 » 21 Jan 2023, 14:23

edit: wrong topic
Last edited by leosouza85 on 21 Jan 2023, 14:44, edited 1 time in total.

gregster
Posts: 9002
Joined: 30 Sep 2013, 06:48

Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!

Post by gregster » 21 Jan 2023, 14:28

@leosouza85, is your post really related to this topic, Chrome.ahk? To me, it seems pretty offtopic...

leosouza85
Posts: 90
Joined: 22 Jul 2016, 16:28

Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!

Post by leosouza85 » 21 Jan 2023, 14:44

gregster wrote:
21 Jan 2023, 14:28
@leosouza85, is your post really related to this topic, Chrome.ahk? To me, it seems pretty offtopic...
Man!!!!! Im so sorry!!!! Wrong topic

rapp
Posts: 7
Joined: 22 May 2019, 23:19

Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!

Post by rapp » 21 Jan 2023, 16:34

I have been running various scripts using chrome.ahk for at least a year and everything worked fine. Now I get the SecurityError warning on every script. I suspect that something changed in my system but I cannot figure out what it is. I have increased the number of FEATURE_WEBSOCKET_MAXCONNECTIONSPERSERVER as identified above. I checked the registry and the change was made correctly. Any suggestions would be appreciated.

thaihoa3189
Posts: 35
Joined: 23 Mar 2022, 22:10

Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!

Post by thaihoa3189 » 02 Feb 2023, 00:11

@geek
Now ahk ver2 is official, please convert chrome.ahk to ver2 please, this library is awesome, great geek!

malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!

Post by malcev » 05 Feb 2023, 15:02

edhalsim wrote:
12 Dec 2022, 15:58
I hope this isn't a stupid question. Is there any way to get the contents of an iFrame whose domain is different? I know cross-domain scripting may prevent it, but I need to check the attributes of an element inside the iframe. If Autohotkey doesn't support it, can you think of any other scripting solutions for Chrome that may allow it?

Thanks.
Need to add 2 command line switches --disable-web-security --user-data-dir="C://YourDir".

User avatar
Xeo786
Posts: 759
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!

Post by Xeo786 » 07 Feb 2023, 05:01

malcev wrote:
05 Feb 2023, 15:02
edhalsim wrote:
12 Dec 2022, 15:58
I hope this isn't a stupid question. Is there any way to get the contents of an iFrame whose domain is different? I know cross-domain scripting may prevent it, but I need to check the attributes of an element inside the iframe. If Autohotkey doesn't support it, can you think of any other scripting solutions for Chrome that may allow it?

Thanks.
Need to add 2 command line switches --disable-web-security --user-data-dir="C://YourDir".
"--disable-site-isolation-trials" Would also be needed, see
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

jekko1976
Posts: 97
Joined: 10 Oct 2014, 07:03

Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!

Post by jekko1976 » 16 Feb 2023, 08:43

@thaihoa3189
@geek
I too really wish that it will be converted

edhalsim
Posts: 9
Joined: 18 Nov 2022, 11:34

Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!

Post by edhalsim » 25 Feb 2023, 10:38

Hi. How can I run two instances of Chrome simultaneously each with their own commands? For example, in one Chrome I want to press F1 and have it execute and in another Chrome I want to press F2 and do something else. I tried hard coding the debugger port on a copy of Chrome.ahk to 9223 and having one script use that and one script use the regular one, but that doesn't work. Chrome.ahk has code in it to change debugger ports on its own, but so far I haven't been able to get it to do what I want.

Thanks for the help.

User avatar
kagato
Posts: 10
Joined: 04 Dec 2015, 16:48
Location: 127.0.0.1

Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!

Post by kagato » 01 Mar 2023, 10:02

edhalsim wrote:
25 Feb 2023, 10:38
Hi. How can I run two instances of Chrome simultaneously each with their own commands? For example, in one Chrome I want to press F1 and have it execute and in another Chrome I want to press F2 and do something else. I tried hard coding the debugger port on a copy of Chrome.ahk to 9223 and having one script use that and one script use the regular one, but that doesn't work. Chrome.ahk has code in it to change debugger ports on its own, but so far I haven't been able to get it to do what I want.

Thanks for the help.

I was doing this for awhile as I had a vendor app that used the same portal URL but landed you differently based on login credentials. Rather than logging in/out all the time to switch instances, I just launched a second Chrome instance on port 9223 that I could log in with different credentials. The difference is the second instance had it's own profile path.

Code: Select all

DebugPort := 9222
DebugPortTwo := 9223

IF (Chromes := Chrome.FindInstances()).HasKey(DebugPort)
{
	ChromeInst := {"base": Chrome, "DebugPort": "9222"}
}	
ELSE ; If port 9222 debug instance of Chrome found, launch one
{
	AHKProfilePath = C:\Users\%A_UserName%\AppData\Local\Google\Chrome\AHK
	IFNotExist, %AHKProfilePath%
	{
		FileCreateDir, %AHKProfilePath%
	}
	ChromeInst := new Chrome(AHKProfilePath,,"--start-maximized",,9222)
}
 
IF (ChromesTwo := Chrome.FindInstances()).HasKey(DebugPortTwo)
{
	ChromeInstTwo := {"base": Chrome, "DebugPort": "9223"}
}	
ELSE 
{
	AHKProfilePathTwo = C:\Users\%A_UserName%\AppData\Local\Google\Chrome\AHKTwo
	IFNotExist, %AHKProfilePathTwo%
	{
		FileCreateDir, %AHKProfilePathTwo%
	}
	ChromeInstTwo := new Chrome(AHKProfilePathTwo,,"--start-maximized",,9223)
}

FirstInst := ChromeInst.GetPage()
SecondInst := ChromeInstTwo.GetPage()
Chuck Norris doesn't need garbage collection because he doesn't call .Dispose(), he calls .DropKick().

neogna2
Posts: 590
Joined: 15 Sep 2016, 15:44

Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!

Post by neogna2 » 01 Mar 2023, 14:43

It appears the recent Windows update related to Internet Explorer made Chrome.ahk stop working on a Windows 10 PC I have.
https://arstechnica.com/gadgets/2023/02/microsoft-will-forcibly-remove-internet-explorer-from-most-windows-10-pcs-today/

Chrome starts but I then get an error popup saying "Websocket Error!".

Trying to start Internet Explorer now redirects to Edge. There are still ways to force open Internet Explorer but none of the IE settings proposed earlier in this thread as workarounds for the websocket error solves it now.

Does anyone here have that update installed on Windows 10 yet still have working Chrome.ahk scripts?
Did you have to change some new setting to get it working?

What's the current best alternative (if one exists) for headless browser scripting through AutoHotkey (v1 or v2)?

User avatar
labrint
Posts: 379
Joined: 14 Jun 2017, 05:06
Location: Malta

Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!

Post by labrint » 03 Mar 2023, 01:31

Dear All,

I've already asked here: viewtopic.php?f=6&t=103186&p=510368#p510368 but the edge.ahk modification of chrome.ahk has a smaller community, and very similar libraries so I thought I'd ask here as well.

When running the edge for the first time 2 or 3 pages come up that ask for edge preferences, to allow or not allow. How do we get past those programmatically?

It looks like this:
image.png
image.png (249.46 KiB) Viewed 2426 times
Really good job, I managed to use it to automate some logins and data extractions.

CN60633
Posts: 1
Joined: 08 Mar 2023, 20:38

Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!

Post by CN60633 » 08 Mar 2023, 20:50

neogna2 wrote:
01 Mar 2023, 14:43
It appears the recent Windows update related to Internet Explorer made Chrome.ahk stop working on a Windows 10 PC I have.
https://arstechnica.com/gadgets/2023/02/microsoft-will-forcibly-remove-internet-explorer-from-most-windows-10-pcs-today/

Chrome starts but I then get an error popup saying "Websocket Error!".

Trying to start Internet Explorer now redirects to Edge. There are still ways to force open Internet Explorer but none of the IE settings proposed earlier in this thread as workarounds for the websocket error solves it now.

Does anyone here have that update installed on Windows 10 yet still have working Chrome.ahk scripts?
Did you have to change some new setting to get it working?

What's the current best alternative (if one exists) for headless browser scripting through AutoHotkey (v1 or v2)?
I also get this problem suddenly from yesterday. All scripts applied Chrome.ahk worked fine before. I didn't even touch the computer. The Windows Update Log seems didn't have any new updates recently.

AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: [Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium!

Post by AHK_user » 09 Mar 2023, 03:08

I tried disabeling this redirect, but is does not seems to have effect. Now internet is not redirecting to edge anymore.
Is it maybe possible that the cause is the latest update of Chrome?
3. Edit registry to stop Internet Explorer to Edge redirect
You can stop Internet Explorer to Edge redirect by disabling the IEToEdge Browser Helper Object (BHO) from the registry editor. Here’s how.

Open the registry editor.
Paste the below path in the address bar and press Enter.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Ext\CLSID
On the right panel, double-click on the “{1FD49718-1D00-4B19-AF5F-070AF6D5D54C}” value.
Change the Value Data from “1” to “0”.
Click on the “Ok” button.
Close the registry editor.
Restart Windows 10.

Post Reply

Return to “Scripts and Functions (v1)”