Hi All!
I'm just starting out with AutoHotKey. I've been able to open a webpage using Chrome.ahk and interact via javascript, but I've hit a roadblock:
I work at a facility that uses a web-based application for manufacturing planning. I'm attempting to automate some repetitive click/fill sequences. I always have this application open, often in several tabs. Is there a way to maintain a connection to the chrome debugging port at all times and interact with the current active tab instead of opening a new tab to perform a task? For example: I often write or modify work instructions in an embedded text editor. My ultimate goal is to map hotkeys to a macropad to quickly activate certain font setting combinations (size, color, bold, etc). I don't intend to open said page using AHK, just to interact with it at any given time. I appreciate any help you can give.
Thanks Much,
Chris
Connect to Existing Tab with Chrome.ahk
Re: Connect to Existing Tab with Chrome.ahk
I hope the following example would help.
Code: Select all
#Include Chrome.ahk
if !IsChromeDebugRunning() ; checkling is chrome running with debug mode
{
ChromeInst := new Chrome("C:\ChromeProfile","https://www.google.com/")
}
else
{
msgbox, no debugging mode is found
return
}
msgbox, press f1 get window by url
return
f1::
Page := Chrome.GetPageByURL( "https://www.google.com","contains")
if isobject(Page)
msgbox, % "Page URL "Page.Title
else
msgbox, URL not found
return
IsChromeDebugRunning()
{
try
{
http := ComObjCreate("WinHttp.WinHttpRequest.5.1")
http.open("GET", "http://127.0.0.1:9222")
http.send()
if http.responseText
return 1
else
return 0
}
}
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
-
- Posts: 75
- Joined: 06 Oct 2016, 15:57
Re: Connect to Existing Tab with Chrome.ahk
One solution is to simply modify your shortcut to chrome so that it automatically launches in dev/debug mode. See step 2 in the following tutorial:
https://jacks-autohotkey-blog.com/2020/11/02/installing-chrome-ahk-autohotkey-web-page-automation-tools/
using this method will cause ALL tabs to be in debug mode all the time. If you are not on a relatively safe network I would not recommend doing this as it does leave your browser open to attacks.
https://jacks-autohotkey-blog.com/2020/11/02/installing-chrome-ahk-autohotkey-web-page-automation-tools/
using this method will cause ALL tabs to be in debug mode all the time. If you are not on a relatively safe network I would not recommend doing this as it does leave your browser open to attacks.