Need script to force quit and then restart the Stream Deck app (or process)

Several times a week, the Stream Deck app hangs and Elgato has not found a solution. I have not found a way to repeat the problem “on demand,” which makes it very difficult to troubleshoot. When Stream Deck hang, I have to go into the activity monitor and force quit the process,“Stream Deck.”

In desperation, I’m trying to create a quick way to do this with a script I can run from Keyboard Maestro. (AppleScript, shell script… (whatever people with more skills than I have think is best)

I’m not a skilled scripter, and I’ve tried a number of things I’ve found this website and others. (Including chat GPT!) In every case, Keyboard Maestro has given an error.

Stream Deck is launched by starting an application, and its icon then appears in the menu bar. The Stream Deck application does not appear in the application switcher. The Activity Monitor lists “Stream Deck” in the process column. I think all of the examples I found are for quitting and restarting applications, not processes.

Thanks for any help you can offer.

It depends on which application you run when you run a script.

As a well-known story, a subprocess for Stream Deck’s “Keynote” operation is executed under the name “Keynote”, and if you specify “Keynote” in GUI Scripting (a method of manipulating menus etc. via System Events) from AppleScript, It is not the real Keynote, but the subprocess responds.

Ita big problem if you say, “What worked fine until yesterday stopped working today.” If you can detect that it is a zombie process with the “ps” command from Terminal, it will be possible to periodically process (check + restart) a runaway process in the background (as well as with the do shell script command).

AppleScript:

tell application "System Events" to set pidNumber to the unix id of process "Stream Deck"
do shell script "kill -9 " & pidNumber

Thanks. That did it!