In the process of writing a longer script, I experimented with the following routine, and found it worked… saved as an application bundle.
Note that it tells System Events to set visible of process ‘applet’ to false… which does little more than tapping outside of the dialog would, and is rather CPU intensive, but I find it useful to have a visual cue or prompt, suggesting the script will actually ‘wait’ before the dialog must be dealt with… or the script continues.
Anticipating there might be conflicts with other running applets at some point, I changed the name of the script’s executable file and the Info.plist and changed the signature in the .plist and the PkgInfo file. I also changed the process name in the script (of course).
The result was that when the altered script app is run, the ‘Run this script…’ startup screen appears. Once past the startup, the script behaves as hoped/expected. I tried three times (carefully) to alter the package items properly… and thrice got the same result. Once (flailing at the problem), I also archived the app, threw away the original, logged out and back in, and… same result.
Anyone ever seen this before? I find it very strange that the script itself seems to have been altered (showing the startup screen when it’s been explicitly saved not to show) in the process of editing the external files.
Second question… might there be another way - via dialog button - to effectively wait the script indefinitely?
Thanks for any clues.
Peter B.
tell me to activate
display dialog "Do it now...?" buttons {"Cancel", "Wait", "OK"} default button 3
set button_pressed to button returned of result as text
if button_pressed is "Wait" then
tell application "System Events"
set visible of application process "applet" to false
repeat until visible of application process "applet" is true
end repeat
end tell
end if
-- resume script
tell me to activate
display dialog "Are you sure you're ready...?" buttons {"Cancel", "OK"} default button 2
-----
Nothing wrong with that… and I sort of feel like I’m floundering for a solution that needs no solution, but…
I found (here on a PPC machine) that saving my original script as an app - rather than an app bundle - allows me to change the process name (to the name of the app) without any problem, so my immediate ‘need’ is met.
I’m still curious why the main.scpt of an app bundle would revert to using the startup screen, but I guess I can live without knowing.
I suspect that when you do an edit the Resource of the script is getting changed some how??.
I have experimented in the past with this. (not your changes but changing the applet.rsrc)
I can not paste the Resource code here as it should be because it contains NULL characters.
I could past it here in ASCII but it would be a mile long.
So here is how to get yours from the file before you alter it
do shell script "cat /Users/UserName/Desktop/my.app/Contents/Resources/applet.rsrc"
Copy the result and paste it in to the script below. (where it says PASTE RESULT HERE.
set file_path to (path to desktop as Unicode text) & "my.app"
set rzr to "PASTE RESULT HERE" -- without startup screen- Resource
write rzr to alias (file_path & ":Contents:Resources:applet.rsrc" as Unicode text)
Do your changes, and then run the second script on the app
I have not done changes to file as you have but I think this should work
Thanks… tried it… no go… same result. Went one more step, saved a copy of the applet.rsrc file from the unaltered app package and replaced the altered app’s copy. No go.
Again, this is far from ‘mission critical’… only curiosity is killing (er… mildly distracting) this cat.
I have what I consider an acceptable workaround now.