Tuesday, May 11, 2021

#1 2021-04-04 10:15:40 am

NMG
Member
Registered: 2019-09-29
Posts: 54

Have the app open

I have created a script with the Script Editor. I have exported it: File > Export > File Format > Application. I have left it in the Applications folder. I have also drag the icon to the Dock.

It works well but it seems that is not acting like other applications: Safari, Pages... In the Dock, it has not the regular dot under the active applications. If I use the shortcut command tap to see the opened applications it is not there either.

Does it mean that it is not open? How to change that?

Offline

 

#2 2021-04-05 12:23:38 am

ldicroce
Member
Registered: 2017-11-25
Posts: 235

Re: Have the app open

It pretty much depends on the setting you choose when you exported it, the main script you have, and the function of this app you envision.

If you want your application to stay open you have to set "stay open" option (during the export step). But then you also need to include a "on idle / end idle" code, otherwise it will stay open but without doing anything.
The simplest code would be:

Applescript:

on idle
beep
return 3
end idle

With this, the application will stay open and "beeping" every 3 seconds.
L.

Offline

 

#3 2021-04-05 02:55:56 am

NMG
Member
Registered: 2019-09-29
Posts: 54

Re: Have the app open

Thank you.

I have copy-paste your idle code to a new Script Editor, clicked to the run button and nothing happens. I hear no beep. There must be something I do not understand?

Offline

 

#4 2021-04-05 06:03:35 am

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 1797

Re: Have the app open

NMG wrote:

Thank you.

I have copy-paste your idle code to a new Script Editor, clicked to the run button and nothing happens. I hear no beep. There must be something I do not understand?


It works only as stay-open application, and not as script. So, save it as stay-open application, then run it to test.

Script equivalent of stay-open application is infinite repeat loop, but it consumes more CPU resources:

Applescript:


repeat
   beep 5
   set theResult to display dialog "Quit Now?" giving up after 1
   if button returned of theResult is "OK" then return
end repeat

As we sad above, effective approach is using on idle wrapper and saving all as stay-open application:

Applescript:


on idle
   -- your original script goes here
   return 3
end idle

Last edited by KniazidisR (2021-04-05 06:36:41 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 14.1
Ram: 4 GB

Offline

 

#5 2021-04-05 08:11:46 am

NMG
Member
Registered: 2019-09-29
Posts: 54

Re: Have the app open

Ok. Now it works. Thank you

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)