Search code examples
macoswindowapplescriptcountingcontain

Count windows that contain a determined word


I've always counted windows using this command:

set windowsnumber to count windows

Now I'm in the need of counting windows that contain a specific string.

E.g. If a process has 5 windows opened (windows "A", "B", "A", "C", "D"), I need something like "count windows that contains "A" in their title", should return 2 in this example.

Is this feasible with applescript?


Solution

  • Use the whose filter :

    set windowsnumber to count (windows whose title contains "A")