Was having the same issue trying to activate a tab.dominicx wrote: ↑03 Apr 2020, 08:38This library is great! . I have one question which I cannot figure out how to solve.
If Chrome in the debug mode is already open,above commands are performed in the background without activating Chrome.Code: Select all
IfNotExist, %ChromeProfileDirectory% FileCreateDir, ChromeProfile if (Chromes := Chrome.FindInstances()) ChromeInst := {"base": Chrome, "DebugPort": Chromes.MinIndex()} ; or if you know the port: ChromeInst := {"base": Chrome, "DebugPort": 9222} Page.Call("Page.navigate", {"url": url}) ; Navigate to url Page.WaitForLoad()
How do find Chrome debug mode and use something like WinActivate to activate it?
FindInstance() from the library is going through winmgmts but info from there is useless for the WinActivate because it does not retrieve anything that can be used with WinActivateCode: Select all
FindInstances() { static Needle := "--remote-debugging-port=(\d+)" Out := {} for Item in ComObjGet("winmgmts:") .ExecQuery("SELECT CommandLine FROM Win32_Process" . " WHERE Name = 'chrome.exe'") if RegExMatch(Item.CommandLine, Needle, Match) Out[Match1] := Item.CommandLine return Out.MaxIndex() ? Out : False }
I have tried this to see if any attribute for chrome debug would be available in WinGet but none are useful either
Please helpCode: Select all
WinGet, ID, list, ahk_class Chrome_WidgetWin_1 Loop, %id% { this_id := id%A_Index% WinActivate, ahk_id %this_id% WinGetClass, this_class, ahk_id %this_id% WinGetTitle, this_title, ahk_id %this_id% MsgBox, 4, , Visiting All Windows`n%a_index% of %id%`nahk_id %this_id%`nahk_class %this_class%`n%this_title%`n`nContinue? IfMsgBox, NO, break }
In your example, after
Page.Call("Page.navigate", {"url": url})
Add
Page.Call("Page.bringToFront")