john denver abella
john denver abella

Reputation: 51

AHK - Is there a way to know if the webpage is already loaded in google chrome?

I just wanted to ask if there is a way to know if the webpage is already loaded in google chrome using AHK? like if we using autohotkey to navigate to the webpage sometimes we use sleep function to kinda set intervals before the script continue to run, but using this methos is not that accurate and sometime some webpages load versy slowly and it will messed up your script. is there a way to know if the page is already loaded before the script continue on running?

Thank you

Upvotes: 0

Views: 864

Answers (1)

LDB
LDB

Reputation: 11

First things first. I am a non professional self taught BASIC Spaghetti programmer from the 80's. What you see below is what you get.

AHK and the browsers do not work well together. I use AHK mostly with FireFox but it seems to behave the same with Chrome

I use a script to send music to my stereo and do many mundane chores while I navigate through my daily news, whether, sports and click bait routine.

I can find the names of individual windows running within Firefox. The individual windows may each have a number of tabs but I can only see the name of the active tab within each of the individual FireFox windows.

Below is some code I copied out of the script that finds window names. All the individual FireFox window names end in "— Mozilla Firefox"

WinGet, WinList, List
Loop %WinList% 
{
  ID := WinList%A_Index%
  WinGetTitle, Title, ahk_id %ID%

  If (MusicPlayer = "Sting`nRay")
  {
     If (ID = IDStingRay)
     {
        Gosub GetSongTitle
        Break
     }
  }
  Else If InStr(Title, "Radio Caroline")
  {
     If InStr(Title, "www.radiocaroline") or InStr(Title, "Radio Caroline playlist")
     {
        RadioCarolinePlaylistTitle := "Radio Caroline playlist — Mozilla Firefox"
        RadioCarolineToolTip := "Caroline On Line"
        ToolTip, %RadioCarolineToolTip%, %TTx%, 24, 3
        Break
     }
     Else If InStr(Title, "Caroline Community Radio")
     {
        RadioCarolinePlaylistTitle := "Caroline Community Radio — Mozilla Firefox"
        RadioCarolineToolTip := "Caroline Community Radio On Line"
        Break
     }
     Else If InStr(Title, "| Radio Caroline — Mozilla Firefox")
     {
        Gosub GetSongTitle
        Break
     }
  }
}

One of the mundane tasks this script does is to make a list of the songs that play while the script is running.

In the above code the two windows titles that are actually playing music are "Sting Ray" and the one ending with "| Radio Caroline — Mozilla Firefox".

The others pages appear when announcers are announcing. For those that prefer music to announcing give Radio Caroline a listen. Much more playing than announcing and the announcing is mostly about the playing.

I would like to find the names of all the individual tabs within each FireFox window but that is beyond my pasta programing abilities.

Upvotes: 1

Related Questions