Condition Relating to a Menubar App?

I would like the If Then Else action to depend on whether I am currently using a certain menubar app. The app is a site-specific browser created by Unite: you click on the menubar icon, and a window drops down with the site, which you can then interact with. In the image below, the app is the leftmost, white-and-blue icon, and the webpage in the window that drops down is scrolled to "December 7":

Unfortunately, the Front Browser tokens don't work here. Does anyone know a way to test whether this drop-down window is showing?

I don't know if there's an AppleScript way to do it, but you could very probably do it using the "Find Image" action in KM. But I can't be sure because you have shown only about 5% of the menu that appears (i.e., the site that appears.)

Even with the little that you've shown, I think you could do it using the Find Image search and the image you would use to search for is the blue icon with the triangle underneath it. That would likely work, but if you show more of the full image, we might find a better image to search for.

The triangle is transparent, so it's not reliable—but turns out I actually can do it with a found image, something that floats on the page wherever you scroll to. Thanks!

You underestimate my ability to make Find Image work.

1 Like

That's great. That's what I would have been looking for. Is this issue solved?

Yes, resolved!

Hey Phil,

Change this as necessary for spelling, etcetera.

See what you get for winList when Unite is open.

-Chris

tell application "System Events"
   tell application process "Unite"
      set winList to windows
   end tell
end tell
1 Like

For Unite, I get

{window 1 of application process "Unite" of application "System Events"}

For the menubar app I created with Unite, "Planner," I get

{window "Planner — /" of application process "Planner" of application "System Events"}

What do you get when no windows are open?

Unite always has a single window. For the "Planner" app in the menubar, I get the same result whether the dropdown window is showing or not. (To test, I inserted a delay to give me time to click on the menubar icon down before the rest of the script ran.)

Run this, and see if anything is unique when windows are and are not open.

tell application "System Events"
   tell application process "Unite"
      set windowPropertyList to window properties
      return windowPropertyList
   end tell
end tell

Thanks! I got an error:

**error** "System Events got an error: Can’t make {class:application process, has scripting terminology:false, bundle identifier:\"com.BZG.unite.4\", file:alias \"Phil's Macintosh HD:Applications:Unite.app:\", creator type:\"????\", subrole:missing value, entire contents:{}, selected:missing value, application file:alias \"Phil's Macintosh HD:Applications:Unite.app:\", orientation:missing value, role:\"AXApplication\", accepts high level events:true, file type:\"APPL\", value:missing value, position:missing value, id:5858710, displayed name:\"Unite\", name:\"Unite\", background only:false, frontmost:false, size:missing value, visible:true, Classic:false, role description:\"application\", maximum value:missing value, architecture:\"x86_64\", partition space used:0, short name:\"Unite\", focused:missing value, minimum value:missing value, help:missing value, title:\"Unite\", accepts remote events:false, total partition size:0, description:\"application\", accessibility description:missing value, enabled:missing value, unix id:20260} into type integer." number -1700 from {*class*:*application process*, has scripting terminology:*false*, bundle identifier:"com.BZG.unite.4", *file*:*alias* "Phil's Macintosh HD:Applications:Unite.app:", creator type:"????", subrole:*missing value*, entire contents:{}, selected:*missing value*, application file:*alias* "Phil's Macintosh HD:Applications:Unite.app:", orientation:*missing value*, role:"AXApplication", accepts high level events:*true*, file type:"APPL", value:*missing value*, position:*missing value*, id:5858710, displayed name:"Unite", name:"Unite", background only:*false*, frontmost:*false*, size:*missing value*, visible:*true*, Classic:*false*, role description:"application", maximum value:*missing value*, architecture:"x86_64", partition space used:0, short name:"Unite", focused:*missing value*, minimum value:*missing value*, help:*missing value*, title:"Unite", accepts remote events:*false*, total partition size:0, description:"application", accessibility description:*missing value*, enabled:*missing value*, unix id:20260} to *integer*

This is what the script editor window looked like after I got the error:

Agh... Sorry – this is the correct syntax:

tell application "System Events"
   tell application process "Unite"
      set windowPropertyList to properties of windows
      return windowPropertyList
   end tell
end tell
1 Like

Okay! With Unite—which is the one-window app for creating the browser apps—I get:

{{minimum value:*missing value*, orientation:*missing value*, position:{496, 112}, *class*:*window*, accessibility description:*missing value*, role description:"standard window", focused:*false*, title:"", size:{448, 530}, help:*missing value*, entire contents:{}, enabled:*missing value*, maximum value:*missing value*, role:"AXWindow", value:*missing value*, subrole:"AXStandardWindow", selected:*missing value*, name:*missing value*, description:"standard window"}}

With "Planner," the menubar app I created with Unite, when the dropdown window is showing, I get only this:

{}

(This is me using the same script as with Unite, but with the application name changed to "Planner" and a delay to allow me to click the menubar icon so the window dropdown appears.)

Hey Phil,

Run this:

set AppleScript's text item delimiters to linefeed
tell application "System Events"
   set appNameList to name of processes as text
end tell

set shCMD to "echo " & quoted form of appNameList & " | open -f "

do shell script shCMD

Then search for “Planner”.

The process name might be different.

-Chris

"Planner" appears in the results. However, the results do not differ between when the Planner dropdown window is closed and when it is open. (I inserted a delay in the script to allow me to click on the menu item icon.)

“Planner” should appear in the running process list no matter whether it is open or not (as long as it is running).

The question is whether there is a window associated.

Since I can't test myself I'm out of ideas for now.

-Chris