Correct syntax to use for multiple window titles?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Correct syntax to use for multiple window titles?

22 Jun 2021, 20:53

As per example below, if I want to retain setTitleMatchMode, 2 while letting it work in either YouTube, Vimeo or Dailymotion, how should I write the syntax?

Code: Select all

#IfWinActive YouTube ahk_group MyBrowsers
#If WinActive("ahk_exe .exe") ||  WinActive("ahk_exe .exe") ||  WinActive("ahk_exe .exe") ; this is usually how I write for multiple apps but it does not accept both ahk_exe/group and the title itself?


User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Correct syntax to use for multiple window titles?

22 Jun 2021, 20:59

See GroupAdd for using the command itself and the examples for referring to the created group.

To use multiple window definitions with an #If directive, the multiple WinActive() calls would work if done right.
User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: Correct syntax to use for multiple window titles?

23 Jun 2021, 04:11

boiler wrote:
22 Jun 2021, 20:59
See GroupAdd for using the command itself and the examples for referring to the created group.

To use multiple window definitions with an #If directive, the multiple WinActive() calls would work if done right.
Got it, so it should look like this:

Code: Select all

GroupAdd, VideoSites, YouTube ahk_group MyBrowsers
GroupAdd, VideoSites, Vimeo ahk_group MyBrowsers
GroupAdd, VideoSites, DailyMotion ahk_group MyBrowsers
For Vimeo, I notice there's no unique identifier in the window title. how do I use GroupAdd to add specific domains under the group?
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Correct syntax to use for multiple window titles?

23 Jun 2021, 06:11

I guess you’re saying that if there is a Vimeo video in the browser, nothing in the title says “Vimeo” or anything else other than the name of the video itself, correct? Can you show a typical title as displayed by the Window Spy tool for a Vimeo video?
User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: Correct syntax to use for multiple window titles?

23 Jun 2021, 07:09

boiler wrote:
23 Jun 2021, 06:11
I guess you’re saying that if there is a Vimeo video in the browser, nothing in the title says “Vimeo” or anything else other than the name of the video itself, correct? Can you show a typical title as displayed by the Window Spy tool for a Vimeo video?
that's correct. it shows in public vimeo videos, but for unlisted videos, only the video title is shown. As such, it will be better to detect the root domain if possible.

Image
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Correct syntax to use for multiple window titles?

23 Jun 2021, 07:15

Well, you hid the only part I was interested in seeing because I knew the rest. I was hoping the actual video title might have some particular format, for example text in quotes followed by a dash and more text or something along those lines. If it's nothing that's repeatable, then I don't see how you could distinguish it from other random titles. I suppose you could look for something in the source HTML, but that would be nowhere near as straightforward.
User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: Correct syntax to use for multiple window titles?

23 Jun 2021, 07:28

boiler wrote:
23 Jun 2021, 07:15
Well, you hid the only part I was interested in seeing because I knew the rest. I was hoping the actual video title might have some particular format, for example text in quotes followed by a dash and more text or something along those lines. If it's nothing that's repeatable, then I don't see how you could distinguish it from other random titles. I suppose you could look for something in the source HTML, but that would be nowhere near as straightforward.
yup there isn't anything "standard" in the title at all. Literally just

Code: Select all

Title - Google Chrome
is there an easy way to add the domain name using GroupAdd?
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Correct syntax to use for multiple window titles?

23 Jun 2021, 08:10

It only works with window title information, not anything to do with the domain/URL, unless a site happens to include it in its window title, which is not the case here.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Correct syntax to use for multiple window titles?

23 Jun 2021, 08:22

  1. install ur favorite userscript extension
  2. make a new script

    Code: Select all

    // ==UserScript==
    // @name         Add Hostname to Window Title
    // @namespace    http://tampermonkey.net/
    // @version      0.1
    // @author       You
    // @include        *
    // @grant        none
    // ==/UserScript==
    
    (function() {
        'use strict';
        document.title += ' - ' + document.location.hostname
    })();
  3. proceed with ur AHK window title coding endeavors
User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: Correct syntax to use for multiple window titles?

23 Jun 2021, 19:13

swagfag wrote:
23 Jun 2021, 08:22
  1. install ur favorite userscript extension
  2. make a new script

    Code: Select all

    // ==UserScript==
    // @name         Add Hostname to Window Title
    // @namespace    http://tampermonkey.net/
    // @version      0.1
    // @author       You
    // @include        *
    // @grant        none
    // ==/UserScript==
    
    (function() {
        'use strict';
        document.title += ' - ' + document.location.hostname
    })();
  3. proceed with ur AHK window title coding endeavors
I got this installed on TamperMonkey, but how do I use AutoHotkey in conjunction with this script? What does the syntax look like and how do I add a domain or subdomain with wildcards?
E.g.

Code: Select all

#If WinActive("Vimeo.com/*")
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Correct syntax to use for multiple window titles?

23 Jun 2021, 19:23

You don’t need wildcards. It would just be:

Code: Select all

#If WinActive("Vimeo.com")
If the title now starts with Vimeo.com, then that’s all you need. If it’s not at the start but somewhere else in the title, which is what looks to be the case, then you need to have set the following in the auto-execute section to cause it to match anywhere within the title:

Code: Select all

SetTitleMatchMode, 2

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada and 301 guests