# Apple Script Help: Check if an app is running \[HazeOver\]

**URL:** <https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240>\
**Category:** Configuration Help & General Discussion\
**Tags:** touch-bar\
**Created:** [August 11, 2020, 11:08pm UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240 "2020-08-11T23:08:30Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Future\_Face](https://community.folivora.ai/user_avatar/community.folivora.ai/future_face/32/13410_2.png) [@Future\_Face](https://community.folivora.ai/u/Future_Face)\
**Post date:** [August 13, 2020, 9:23pm UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240/21 "2020-08-13T21:23:55Z")

</div>

![Screenshot of BetterTouchTool (14-08-20, 9-22-51 AM)](https://community.folivora.ai/uploads/default/original/2X/3/307e24a2e044cd007ec7201daab90f3094fbddaa.png)  
the top one is the one currently displayed. the bottom one is the one I want it to switch to when I tap the button, but it doesn't. the trigger still activates and deactivates HazeOver, but the icon doesn't change.

---

<div class="post-metadata">

**Author:** ![Caliguvara](https://community.folivora.ai/user_avatar/community.folivora.ai/caliguvara/32/42570_2.png) [@Caliguvara](https://community.folivora.ai/u/Caliguvara)\
**Post date:** [August 13, 2020, 9:26pm UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240/22 "2020-08-13T21:26:22Z")

</div>

And if you trigger the button, then run the widget scrip in the Script Editor right afterwards, does the script return the correct result?

---

<div class="post-metadata">

**Author:** ![Future\_Face](https://community.folivora.ai/user_avatar/community.folivora.ai/future_face/32/13410_2.png) [@Future\_Face](https://community.folivora.ai/u/Future_Face)\
**Post date:** [August 13, 2020, 9:27pm UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240/23 "2020-08-13T21:27:04Z")

</div>

I don't understand what you mean...

---

<div class="post-metadata">

**Author:** ![Caliguvara](https://community.folivora.ai/user_avatar/community.folivora.ai/caliguvara/32/42570_2.png) [@Caliguvara](https://community.folivora.ai/u/Caliguvara)\
**Post date:** [August 13, 2020, 9:28pm UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240/24 "2020-08-13T21:28:26Z")

</div>

Let me turn it the other way around, what does the toggle (the associated action) do? What happens if you just tap the button, independent to the script of the widget.

---

<div class="post-metadata">

**Author:** ![Caliguvara](https://community.folivora.ai/user_avatar/community.folivora.ai/caliguvara/32/42570_2.png) [@Caliguvara](https://community.folivora.ai/u/Caliguvara)\
**Post date:** [August 13, 2020, 9:31pm UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240/25 "2020-08-13T21:31:54Z")

</div>

1. Run the Apple Script in the Apple Script Editor
2. Tap your Touch Bar button
3. Run the Apple Script in the Apple Script Editor

Does the result change?

---

<div class="post-metadata">

**Author:** ![Future\_Face](https://community.folivora.ai/user_avatar/community.folivora.ai/future_face/32/13410_2.png) [@Future\_Face](https://community.folivora.ai/u/Future_Face)\
**Post date:** [August 13, 2020, 10:35pm UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240/26 "2020-08-13T22:35:23Z")

</div>

no it doesn't

---

<div class="post-metadata">

**Author:** ![Future\_Face](https://community.folivora.ai/user_avatar/community.folivora.ai/future_face/32/13410_2.png) [@Future\_Face](https://community.folivora.ai/u/Future_Face)\
**Post date:** [August 14, 2020, 5:08am UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240/27 "2020-08-14T05:08:07Z")

</div>

ive just quit the app hazeover and it now does return 'quit'

---

<div class="post-metadata">

**Author:** ![Caliguvara](https://community.folivora.ai/user_avatar/community.folivora.ai/caliguvara/32/42570_2.png) [@Caliguvara](https://community.folivora.ai/u/Caliguvara)\
**Post date:** [August 14, 2020, 7:35am UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240/28 "2020-08-14T07:35:54Z")

</div>

That's what I thought. What does the associated action do? If it does not quit/launch the app, then it will have no effect on your widget, as that's what the script is checking.

---

<div class="post-metadata">

**Author:** ![Future\_Face](https://community.folivora.ai/user_avatar/community.folivora.ai/future_face/32/13410_2.png) [@Future\_Face](https://community.folivora.ai/u/Future_Face)\
**Post date:** [August 14, 2020, 10:12am UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240/29 "2020-08-14T10:12:39Z")

</div>

it activates and deactivates hazeover, command control option H

---

<div class="post-metadata">

**Author:** ![Caliguvara](https://community.folivora.ai/user_avatar/community.folivora.ai/caliguvara/32/42570_2.png) [@Caliguvara](https://community.folivora.ai/u/Caliguvara)\
**Post date:** [August 14, 2020, 11:37am UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240/30 "2020-08-14T11:37:50Z")

</div>

That's what I thought. Your widget checks wether your HazeOver is **running** or not, wether the script **de/activates** it (checks if it is frontmost).

Try this script:

```
return application (path to frontmost application as text)

```

and set as Regex value HazeOver.

---

<div class="post-metadata">

**Author:** ![Andreas\_Hegenberg](https://community.folivora.ai/user_avatar/community.folivora.ai/andreas_hegenberg/32/39221_2.png) [@Andreas\_Hegenberg](https://community.folivora.ai/u/Andreas_Hegenberg)\
**Post date:** [August 14, 2020, 11:43am UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240/31 "2020-08-14T11:43:52Z")

</div>

That sounds like the solution 🙂

By the way, the original script he posted should work for finding whether an app is running or not. It's using a new but not yet documented call **is\_app\_running** which should be much more performant than the standard Apple Script way. It's not yet documented because I need to do some more testing with it.

---

<div class="post-metadata">

**Author:** ![Caliguvara](https://community.folivora.ai/user_avatar/community.folivora.ai/caliguvara/32/42570_2.png) [@Caliguvara](https://community.folivora.ai/u/Caliguvara)\
**Post date:** [August 14, 2020, 11:48am UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240/32 "2020-08-14T11:48:23Z")

</div>

Ohhhhhh 🤩

---

<div class="post-metadata">

**Author:** ![Future\_Face](https://community.folivora.ai/user_avatar/community.folivora.ai/future_face/32/13410_2.png) [@Future\_Face](https://community.folivora.ai/u/Future_Face)\
**Post date:** [August 14, 2020, 9:29pm UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240/33 "2020-08-14T21:29:10Z")

</div>

![Screenshot of BetterTouchTool (15-08-20, 9-27-06 AM)](https://community.folivora.ai/uploads/default/original/2X/2/27ed4438aa4c637b6b71f95a6e41d72c3f3c6d04.png)  
thanks,  
doesn't work. when HazeOver is activated, it doesnt come to the front (but idk if that affects the coding)

---

<div class="post-metadata">

**Author:** ![Caliguvara](https://community.folivora.ai/user_avatar/community.folivora.ai/caliguvara/32/42570_2.png) [@Caliguvara](https://community.folivora.ai/u/Caliguvara)\
**Post date:** [August 14, 2020, 10:31pm UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240/34 "2020-08-14T22:31:34Z")

</div>

What does ⌃⌥⌘H do?

> [@Future\_Face](#):
>
> when HazeOver is activated, it doesnt come to the front

And I don't understand what you mean here ☹ an app is activated when it's frontmost.

---

<div class="post-metadata">

**Author:** ![Future\_Face](https://community.folivora.ai/user_avatar/community.folivora.ai/future_face/32/13410_2.png) [@Future\_Face](https://community.folivora.ai/u/Future_Face)\
**Post date:** [August 15, 2020, 12:01am UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240/35 "2020-08-15T00:01:22Z")

</div>

maybe you should download HazeOver and try the free trial to test it yourself.  
HazeOver is an icon in the menu bar, that when clicked, this shows:  
 ![Screenshot of Safari (15-08-20, 11-59-45 AM)](https://community.folivora.ai/uploads/default/original/2X/a/ac526c90f1367edd835c0744e7e67e9dadce02b6.png)

So when I press ⌃⌥⌘H, it doesn't quit the app, it simply deactivates what the app is doing: dimming background apps. I keep HazeOver open all the time, but when I Command-Tab, it doesn't appear there like a normal app.

---

<div class="post-metadata">

**Author:** ![Caliguvara](https://community.folivora.ai/user_avatar/community.folivora.ai/caliguvara/32/42570_2.png) [@Caliguvara](https://community.folivora.ai/u/Caliguvara)\
**Post date:** [August 15, 2020, 3:59pm UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240/36 "2020-08-15T15:59:47Z")

</div>

Once you say everything…  
The widget it not suitable at all for what you are looking to achieve. To make some confusion clear, HazeOver will always be

- Running
- Never be active (I guess - unless a preference window or something is open)

HazeOver will always be there, you can compare it to your Web browser: whereas the Browser might display a webpage or not, HazeOver might dim the other apps or not.

Three ways that I can think about to get what you want:

1. Check if there is a process in the Activity Monitor that appears only when HazeOver dims the windows. You would have to check if this Process exists to toggle the widget dependently.
2. Use Apple Script to access the right Menu Bar items and search for the existence of the menu. "Turn HazeOver On/Off". Bugger, I have no clue at all how to access these "Menu Bar Apps" (if someone knows, I'd be into it)
3. If you only use the button to toggle HazeOver, you might work with a persistent variable inside BTT that would be changed as an associated action of the button/the keyboard command. The script would have to search for the variable. But you will have to figure this out on your own, my final exam does not allow me rn to try to discover new stuff here. This might help though: [https://docs.bettertouchtool.net/docs/1101\_scripting\_btt.html](https://docs.bettertouchtool.net/docs/1101_scripting_btt.html)

---

<div class="post-metadata">

**Author:** ![Future\_Face](https://community.folivora.ai/user_avatar/community.folivora.ai/future_face/32/13410_2.png) [@Future\_Face](https://community.folivora.ai/u/Future_Face)\
**Post date:** [August 15, 2020, 9:30pm UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240/37 "2020-08-15T21:30:24Z")

</div>

ahh, thank you and sorry for not being clear.  
@Andreas_Hegenberg, why can't there just be a more simple alt. icon option?

---

<div class="post-metadata">

**Author:** ![Andreas\_Hegenberg](https://community.folivora.ai/user_avatar/community.folivora.ai/andreas_hegenberg/32/39221_2.png) [@Andreas\_Hegenberg](https://community.folivora.ai/u/Andreas_Hegenberg)\
**Post date:** [August 16, 2020, 11:29am UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240/38 "2020-08-16T11:29:56Z")

</div>

Isn’t the alternate icon option already very easy? How would you make this easier?

---

<div class="post-metadata">

**Author:** ![Caliguvara](https://community.folivora.ai/user_avatar/community.folivora.ai/caliguvara/32/42570_2.png) [@Caliguvara](https://community.folivora.ai/u/Caliguvara)\
**Post date:** [August 16, 2020, 12:47pm UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240/39 "2020-08-16T12:47:46Z")

</div>

Had a look at your App. According to the documentation, HazeOver has full Apple Script support. You should start to read there, using the Dictionary in Script Editor to find the command you need to get the information you need returned.

> **[HazeOver Help and Productivity Tips](https://hazeover.com/help.html)**
>
> HazeOver Quick Start Guide. Productivity Tips and Tricks

> ## Automate with AppleScript
> 
> HazeOver can be fully controlled using AppleScript. You can toggle it, change dimming intensity, tint, animation duration, secondary display mode and multiple windows preference. Here’s how to try it out:
> 
> - Launch “AppleScript Editor” application;
> - Select “File” \> “New” menu;
> - Paste this text into the script window:
> 
> `tell application "HazeOver" to set intensity to 70`
> 
> - Select “Script” \> “Run” menu
> 
> HazeOver should instantly change dimming intensity. To find out all supported properties you need to add HazeOver app to AppleScript Editor library:
> 
> - Locate “HazeOver” application in your “Applications” folder;
> - Drag-n-Drop “HazeOver” app on the “AppleScript Editor” Dock icon.
> 
> Available scripting properties can be found in “HazeOver Suite” \> “application” section.

Now you have the tools to build what you want.

---

<div class="post-metadata">

**Author:** ![Future\_Face](https://community.folivora.ai/user_avatar/community.folivora.ai/future_face/32/13410_2.png) [@Future\_Face](https://community.folivora.ai/u/Future_Face)\
**Post date:** [August 16, 2020, 9:12pm UTC](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240/40 "2020-08-16T21:12:36Z")

</div>

couldn't you make it available for non-applescript buttons and make it able to change when wanted?

[Previous page](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240.md?page=1)

[Next page](https://community.folivora.ai/t/apple-script-help-check-if-an-app-is-running-hazeover/18240.md?page=3)
