Open and Close app
Hi all,
Wondering if there is a way to setup the stream deck button so that once the application is open, i can then push the button again to close that window. This is my code to open the app:
sf.file.open({
path: "/Applications/Messages.app",
});
Thank you
- Chris Shaw @Chris_Shaw2020-12-03 20:25:52.176Z
This will open Messages if it's not open and quit Messages if it is open
if (!sf.ui.app('com.apple.iChat').mainWindow.exists) { sf.ui.app('com.apple.iChat').appEnsureIsRunningAndActive(); } else { sf.ui.app('com.apple.iChat').menuClick({ menuPath: ["Messages", "Quit Messages"], }); }
Chris Shaw @Chris_Shaw2020-12-03 20:55:44.307Z
this will open Messages if not open and if it is it will hide it.
if (!sf.ui.app('com.apple.iChat').mainWindow.exists) { sf.ui.app('com.apple.iChat').appEnsureIsRunningAndActive(); globalState.messagesIsOpen = true throw 0 } if (globalState.messagesIsOpen == true) { sf.ui.app('com.apple.iChat').menuClick({ menuPath: ["Messages", "Hide Messages"], }); globalState.messagesIsOpen = false throw 0 } sf.ui.app('com.apple.iChat').appActivateMainWindow(); globalState.messagesIsOpen = true;
- MIn reply toMike_Avenaim⬆:Mike Avenaim @Mike_Avenaim
Hi,
Thanks for this but it doesnt seem to open the MESSAGES app
- MIn reply toMike_Avenaim⬆:Mike Avenaim @Mike_Avenaim
Hold up... I got it to work with your code.. FOr some reason it wasnt working and now it is... lol
Thank you!
Chris Shaw @Chris_Shaw2020-12-03 20:58:06.649Z
It can be a bit confusing. Internally, in Mac OS, Messages is referred by it's old name iChat for backwards compatibility with older OS's
- MMike Avenaim @Mike_Avenaim
Awesome... Thank you. Im going to try and apply this code to some other apps too
- FIn reply toMike_Avenaim⬆:Freddie Spells @Freddie_Spells
Hi
I am trying to transfer this to any other app like f.e. open and close safari but I do not get the result I am aiming for.
I simply want to close the app when I push the button the second time on my Deck.
Maybe I just need another example from you with safari to get my head wrapped around this?
Thx!