We have an in-house app that I can send commands to by accessing certain URLs. (it's super convoluted but it's the best we can do right now). So I want to be able to use my AHK script to launch the URL in chrome (in incognito mode so when I close it, it doesn't re-open the next time chrome opens and send a bunch of commands) then wait like 2 seconds and close it. And we can't use a different browser, it has to be chrome. We tried IE, firefox, and edge and all of them fail to send the commands.
Code: Select all
Run, "chrome.exe" %targetURL% "--incognito",,, VarPID
Process, Exist, %VarPID%
msgbox, VarPID = %VarPID%
sleep, 2000
process, close, %VarPID%
But when I run the above code, it opens the webpage in incognito mode fine and it gets a PID. So I'll look in task manager to see what that PID is associated with, and it just doesn't exist. The window is still there, just with a different PID so "process, close, %VarPID%" doesn't close the window.
My goal is to add "--headless" to the run command so the window doesn't exist and my script isn't popping open random chrome windows but I don't know how to do that without getting the PID problem sorted
I'm guessing that chrome runs a process which runs another process to make the incognito window. So the original process that I get the PID of exists for less than a second. Then the incognito window has a new PID.
If that is what's happening, I have no idea how to work with that. I'd probably just end up not making it headless and using "winclose, URL - Google Chrome" instead.
Anyone have any ideas?