Find open Chrome tabs and waiting for page loading Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
roysubs
Posts: 114
Joined: 29 Sep 2018, 16:37

Find open Chrome tabs and waiting for page loading

16 Oct 2018, 03:52

I've seen a lot of information about different Chrome libraries but I've had no success with them (just errors etc, maybe Chrome has changed since they were written). Would be great if someone has a recipe for these basic Chrome interactions:

1. Look at existing Chrome sessions and see if I already have an open page matching part or all of a title?
2. Look at existing Chrome sessions and see if I already have an open page matching part or all of a url?
3. Activate Chrome and jump to either of 1 or 2 above if found?
4. Open a page and wait for it to complete loading before doing something with it?

For 1, 2 and 3 I don't even know where to start (and as before, not had any luck with googling and using libraries).

For 4, I did the below, but it breaks a lot as I can't reliably say when the page has finished loading... (I can only use WinWaitActive for the application, and cannot test the tab inside there unless someone has a nice bit of code for this?).

Code: Select all

Open_Chrome(url)
{
    Sleep 200
    if WinExist("ahk_exe Chrome.exe")       ; or WinExist("ahk_class" . ClassName)
    {
        WinActivate ahk_exe chrome.exe
        WinWaitActive ahk_exe chrome.exe   ; Activates the last found and open a new tab
        Send ^l       ; Ctrl-l to activate address bar
        Sleep 100
        Send ^t       ; Ctrl-t to open a new tab
        Sleep 100
        Send ^l       ; Ctrl-l to activate address bar
        Sleep 100
        Send %url%{Enter}
        Sleep 100
    }
    else
    {
        Run % "chrome.exe --new-tab" url
        WinActivate ahk_exe chrome.exe
        WinWaitActive ahk_exe chrome.exe   ; Activates the last found and open a new tab
        Sleep 100
        Send ^l       ; Ctrl-l to activate address bar
        Sleep 100
    }
}
roysubs
Posts: 114
Joined: 29 Sep 2018, 16:37

Re: Find open Chrome tabs and waiting for page loading

17 Oct 2018, 04:48

I thought folk must have done tons of things like this in their personal toolkits? :(
Does anyone have a little cheat sheet on basic Chrome interactions like this that they use? :-)
User avatar
jeeswg
Posts: 5286
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Find open Chrome tabs and waiting for page loading  Topic is solved

17 Oct 2018, 05:02

I have these functions, but they can only handle tab names, not urls.
Firefox/Chrome, get tab names/focus tab - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26947

These links may be helpful:
[Library] Chrome.ahk - Automate Google Chrome using native AutoHotkey. No Selenium! - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=42890
Using Selenium with AutoHotkey- Cross browser automation! - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=32323
roysubs
Posts: 114
Joined: 29 Sep 2018, 16:37

Re: Find open Chrome tabs and waiting for page loading

17 Oct 2018, 09:25

Excellent, many thanks jeeswg. I think the Chrome.ahk was the one giving me a lot of errors, but I'll start clean and see what happens.
Tab names is great, that will be a huge help to be able to focus on a specific tab. Ta.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], roysubs and 123 guests