Break at new website

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
macmastermac
Posts: 4
Joined: 04 Apr 2017, 16:29

Break at new website

16 Sep 2021, 19:00

Hi,

I've been looking for a script that stops the script once the website link has changed.
I only found a few amount on threads here about them and they confuse me. They're made so complicated when all I want seems so simple.

My idea was like:

Code: Select all

^j::

Loop,
{
Send, {LButton}
Sleep, 60000
}

^g::Pause
^z:ExitApp
And somewhere in that code, if let's say, youtube.com changed to youtube.com/explore, the script ends...
But where, and how?
User avatar
mikeyww
Posts: 26851
Joined: 09 Sep 2014, 18:38

Re: Break at new website

17 Sep 2021, 05:44

Here is an easy method that looks to see whether the window title has changed.

Code: Select all

#IfWinActive ahk_exe chrome.exe
^j::
SoundBeep, 1500
SetTimer, Check, 60000
Check:
last := wTitle
WinGetActiveTitle, wTitle
If (last > "" && wTitle != last) {
 SetTimer,, Off
 SoundBeep, 1000
} Else Click
Return
#IfWinActive
macmastermac
Posts: 4
Joined: 04 Apr 2017, 16:29

Re: Break at new website

17 Sep 2021, 14:33

mikeyww wrote:
17 Sep 2021, 05:44
Here is an easy method that looks to see whether the window title has changed.

Code: Select all

#IfWinActive ahk_exe chrome.exe
^j::
SoundBeep, 1500
SetTimer, Check, 60000
Check:
last := wTitle
WinGetActiveTitle, wTitle
If (last > "" && wTitle != last) {
 SetTimer,, Off
 SoundBeep, 1000
} Else Click
Return
#IfWinActive
Hi,

Thanks I tried this. But it isn't exactly working like I thought. If I am at like youtube.com and type in the search bar some text, or hover my cursor over a video and it plays a little, the script ends... While still being on the same website

What I was looking for is if you are at let's say youtube.com/subscriptions and the URL changes to youtube.com/explore, then the script ends!

(Sorry if I double posted my previous post is missing?)
User avatar
mikeyww
Posts: 26851
Joined: 09 Sep 2014, 18:38

Re: Break at new website

17 Sep 2021, 14:55

OK. You may need others to chime in here about a better solution to meet your need. You can get the URL "manually" through sending sequences such as !d^c, but there may also be faster or more reliable ways through the Chrome.ahk library or other approaches. Simply using the clipboard is probably not the way to go here.

Some relevant posts:

viewtopic.php?style=17&t=85383

https://autohotkey.com/boards/viewtopic.php?t=3702

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: ReyAHK, Spawnova and 285 guests