I have this code allready
!^j::
If WinExist("The Title")
WinActivate
else
Run, https://webpage/index.php
Return
Whenever I hit the hotkey, if the web page wanted is open, then the browser is maximized. But if the web page is not open, I have to open the browser (or a new Tab if browser allready open) and go to that page. Up to now everything seems good, but there is one problem...
If the browser is open, and that page is also open but the browser is no sitting in that tab the program open a new tab, which means that every time the browser is in another Tab than the one containing the page looked for, a new tab will be open, how to prevent this?
Is there anyway to fix it? like a function to get all browser tabs and doing a loop?
Edit: Thanks to @Jsmith2800, now I have this code:
!^j::
SetTitleMatchMode, 2
WinActivate, - Mozilla Firefox
SetTitleMatchMode, 1
If WinExist("The Title")
WinActivate
else {
winGetActiveTitle, Title
loop{
send ^{TAB}
If WinExist("The Title")
break
If WinExist(Title)
break
}
If WinExist(Title)
Run, https://webpage/index.php
}
Return
First, I have to open the browser window, so the Ctrl+Tab actually change tab. So the first 3 lines are for opening Mozilla Firefox.
Then I ask if the page I'm looking for is in the current tab, if it is, then only activate that tab. But if it is not, then get the current Title and start a loop.
In that loop, first change tab, then ask again if that new tab is the one I was looking for. If the new tab is the one, break the loop and return. If not, ask if the new tab is the same one before starting the loop, if that is true, then the wanted page is not openned, so open it and break the loop.
This is working right, except for one little thing: The tabs are acceded in a random way, so sometimes it goes back to the Title page before reaching the wanted one How can I make it not random. Allready tried with SetWinDelay, 250 but didn't work.