A couple of things that I need help with

Hi all,
as the title implies, I need help to solve these two problems.

The first one is : I found this post (http://www.macscripter.net/viewtopic.php?id=10452) explaining how to hide the icon in the dock during the execution of the application, but requires that the script is saved as an Application Bundle, while my goal is to make the script as a stay-open application : is possible to hide the icon in this case?
I tried to insert this line at the beginning of the script but without success.

tell application "System Events" to set visible of first process whose name is "myApp" to false

The second is : if I write this code


set theFile to "test.txt"
set thePath to "/Users/Shared/myScripts/"
set theSearch to POSIX file (thePath & theFile)
set theData to paragraphs of (read file theSearch)

I get the content of the file, but with this other code I receive error -1700


set theFile to "test.txt"
tell application "Finder" to set thePath to POSIX path of ((container of (path to me)) as alias)
set theSearch to POSIX file (thePath & theFile)
set theData to paragraphs of (read file theSearch)

I can not understand where I’m wrong, so any help is welcome.

Hi,

the result of “save as application bundle” and “save as stay-open application” is actually the same,
a Cocoa application bundle

in an AppleScriptObjC environment you can get the container of the bundle with

set theContainer to current application's NSBundle's mainBundle()'s bundlePath()'s stringByDeletingLastPathComponent()

the standard string path format for the read/write command of Standard Additions is HFS.
the as text coercion in the second line coerces Finder file specifier to HFS path


set theFile to "test.txt"
tell application "Finder" to set thePath to container of (path to me) as text
set theSearch to thePath & theFile
set theData to paragraphs of (read file theSearch)

but since Mountain Lion a POSIX path is also accepted


set theFile to "test.txt"
tell application "Finder" to set thePath to container of (path to me) as text
set theSearch to (POSIX path of thePath) & theFile
set theData to paragraphs of (read file theSearch)

Hi Alessio,

When you ‘set visible’ it only hides the process and not in the dock. I think you need to set the bundle’s info.plist’s uielement thing. I forget what the exact name was.

Edited: I found the note.

If there is something else that makes it not show in the dock, you can always change it to 0.

gl,
kel

Hi Stefan and kel1,
thank you for helping.

After making the change indicated by Stefan, I entered the idle handler in the script and saved it as a stay-open application, then I followed the instructions provided by kel1 and it works like a charm. Fantastic! Wonderful!! Great!!! :smiley:

IMPORTANT : do not use the default TextEdit program to edit the plist file, but use Text Wrangler. <<

Stefan, I do not understand this part, can you explain me please?

You’re posting in the AppleScriptObjC and Xcode section of MacScripter,
so it could be you’re talking about an AppleScriptObjC application created in Xcode

oops … sorry!!!
I believed I had posted in AppleScript | Mac OS X section…

Can I move the discussion in the right section?

Only Mods and Admins can

Thank you, Stefan.

Can a Mod or Admin move this discussion to AppleScript Mac OS X section, please?

Note that in Xcode you can open and modify plist. And, It’s easier.

gl,
kel