How to check if a web page is already loaded in a chrome tab.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
GratefulJim
Posts: 4
Joined: 04 Nov 2019, 14:10

How to check if a web page is already loaded in a chrome tab.

04 Nov 2019, 14:31

I am looking for something specific.

I researched how to load a specific web page into a new chrome tab ... but my one and only final issue is how to determine if that page is actually loaded.

I am trying to determine if a specific web page is running in a tab in chrome.
I'm doing this as part of a AHK script to load my WAMP development environment all in one shot.

1) Loads the apache/MySql server manager console if not already running ( working )
2) Loads the web / code authoring tool ( Dreamweaver ) .. if not already running ( Working )
3) If chrome is not running, loads chrome. Then loads specific localhost web pages into separate tabs. ( Working ).
OR ..
If chrome is already running.. loads specific localhost web pages into separate tabs.


The final stage I want to complete is to be able to determine if any of the pages i loaded into new tabs is not running.. and simply reopen that tab page.
This will allow me to simply hit my key combo for the AHK script and load any page whose tab was accidentally closed or closed legitimately .. but i need to reopen.

If i hit the key combo to run the script.. it will simply open NEW tabs of all the defined AdminURL pages... and not ones that are not already opened.. and i dont want to open up duplicate tabs of pages i already have open.

The following is my script:

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

; -----------------------------------------------------------------------------------------
; Declare variables for the local system path of referenced applications and URL's
ServerConsoleApp := "K:\WAMP\manager-windows.exe"
DreamweaverApp := "C:\Program Files\Adobe\Adobe Dreamweaver CC 2019\Dreamweaver.exe"
ChromeApp := "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"

AdminPageURL1 := "http localhost /phpmyadmin/"  Broken Link for safety
AdminPageURL2 := "http localhost /Applications//phpMyEdit/"  Broken Link for safety
AdminPageURL3 := "http localhost /Applications/LuxCal/"  Broken Link for safety
AdminPageURL4 := "http localhost /phpbb/"  Broken Link for safety

; Perform the script functions once the (Windows Key + z) key combination is pressed.
#z::

If !WinExist("ahk_exe manager-windows.exe")  ; If the server manager isnt running..   RUN IT. ...(Equivalent to IfWinNotExist)
{
	Run, %ServerConsoleApp%
	
	; Wait until we can detect the program is running - FORMAT:(WinWait, useProcessName, ProcessName, , Timeout in seconds).
	WinWait, ahk_exe manager-windows.exe, , 5
	if ErrorLevel
	{
		MsgBox, WinWait timed out opening WAMP Server control program !
		return
	}
}


; Open up the web authoring / coding program you want to use.
If !WinExist("ahk_exe Dreamweaver.exe")  ; If the web authoring / coding program isnt running..   RUN IT.
{
	Run, %DreamweaverApp%
	
	; Wait until we can detect the program is running - FORMAT:(WinWait, useProcessName, ProcessName, , Timeout in seconds).
	WinWait, ahk_exe Dreamweaver.exe, , 5
	if ErrorLevel
	{
		MsgBox, WinWait timed out opening Dreamweaver !
		return
	}
}


; Open up the browser with the tabs for the admin pages.
If !WinExist("ahk_exe chrome.exe")  ; If the browser isnt running..   RUN IT.
{
	Run, %ChromeApp%
	
	; Wait until we can detect the program is running - FORMAT:(WinWait, useProcessName, ProcessName, , Timeout in seconds).
	WinWait, ahk_exe chrome.exe, , 5
	if ErrorLevel
	{
		MsgBox, WinWait timed out opening Chrome !
		return
	}
	else
	{		
	; Load the admin pages to access in separate new tabs.
		Run, %ChromeApp% %AdminPageURL1%
		Run, %ChromeApp% %AdminPageURL2%
		Run, %ChromeApp% %AdminPageURL3%
		Run, %ChromeApp% %AdminPageURL4%
	}
}
else 
{
	; Chrome is already running..  so just open the admin pages to access in separate new tabs.
	Run, %ChromeApp% %AdminPageURL1%
	Run, %ChromeApp% %AdminPageURL2%
	Run, %ChromeApp% %AdminPageURL3%
	Run, %ChromeApp% %AdminPageURL4%
}
return
; -----------------------------------------------------------------------------------------

Any help is appreciated.

[Mod edit: Topic moved to 'Ask For Help']

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 308 guests