Wednesday, July 24, 2019

#1 2008-11-24 08:39:18 pm

Detry322
Member
Registered: 2008-11-21
Posts: 12

Icons in "display dialog"....

I know of all the default icons you can do with display dialog such as....

Applescript:

display dialog "" with icon 0

will return a stop sign with an exclimation point,

Applescript:

display dialog "" with icon 1

will return a applescript icon, and

Applescript:

display dialog "" with icon 2

will return a warning sign, but i was wondering if you can make custom icons instead of those default ones
any help will be much appriciated

Offline

 

#2 2008-11-25 05:00:35 am

pidge1
Member
From:: Leeds-England-UK
Registered: 2005-08-06
Posts: 627

Re: Icons in "display dialog"....

Hi

I'm not sure about your question but check out this script by Kai Edwards

Applescript:

{{path to "csrv" as Unicode text, {"Finder.app", {{"Which do you prefer?", "generalpref.icns"}, {"What do you want to find?", "find.icns"}, {"For your information…", "info.icns"}, {"Make a new folder?", "new_folder.icns"}, {"Is that a smart folder?", "SmartFolder.icns"}}}, {"Jar Launcher.app", {{"Fancy a cuppa?", "JarLauncher.icns"}}}, {"Crash Reporter.app", {{"Watch out!", "CrashReporter.icns"}}}, {"Help Viewer.app", {{"Help!", "HelpViewer.icns"}}}, {"BOMArchiveHelper.app", {{"Zip me up...", "bah.icns"}}}, {"Certificate Assistant.app", {{"That you, Jeeves?", "Certificate Assistant.icns"}}}, {"Classic Startup.app", {{"Remember me?", "Classic.icns"}}}, {"Conflict Resolver.app", {{"Round we go!", "Sync Services Icon.icns"}}}, {"Dock.app", {{"Just like to say...", "dockling.icns"}, {"...what a great show!", "Dock.icns"}, {"Widget, anyone?", "widget.icns"}}}, {"MirrorAgent.app", {{"I foresee a bright future...", "iDiskGenericIcon.icns"}}}, {"Network Diagnostics.app", {{"...just needs a little work...", "Network Diagnostics.icns"}}}, {"Software Update.app", {{"...and it'll be just fine.", "Software Update.icns"}}}}, {path to "apps" as Unicode text, {"Dashboard.app", {{"Weather looks good.", "Dashboard.icns"}}}, {"Calculator.app", {{"Just trying to figure out...", "Calculator.icns"}}}, {"Chess.app", {{"...my next move.", "chess.icns"}}}, {"Image Capture.app", {{"Smile!", "ImageCapture.icns"}}}, {"Preview.app", {{"Great shot!", "preview.icns"}}}, {"iCal.app", {{"What's the date?", "App.icns"}}}, {"Dictionary.app", {{"What did you say?", "Dictionary.icns"}}}, {"Utilities:Keychain Access.app", {{"Looks just like you.", "vCard.icns"}, {"Anyone seen my keys?", "Keychain.icns"}}}, {"Utilities:Audio MIDI Setup.app", {{"Ah - there they are!", "AudioMIDISetup.icns"}}}, {"Utilities:Terminal.app", {{"Anything good on TV?", "icon.icns"}}}, {"Utilities:Activity Monitor.app", {{"Yeah - this bit's gripping.", "ActivityMonitor.icns"}}}, {"Utilities:Migration Assistant.app", {{"No overtaking.", "MigrateAsst.icns"}}}, {"iMovie.app", {{"That's a wrap.", "app.icns"}, {"G'night, folks.", "iMovie.icns"}}}}}

repeat with x in result
   set a to x's item 1
   repeat with y in rest of x
       set b to y's item 1
       repeat with z in y's item 2
           try
               display dialog z's item 1 with icon a & b & ¬
                   ":Contents:Resources:" & z's item 2 as alias giving up after 2
           on error number n
               if n is -128 then error number n
           end try
       end repeat
   end repeat
end repeat

heres the link to the thread:
http://bbs.macscripter.net/viewtopic.php?id=16489


pidge

Offline

 

#3 2008-11-25 12:00:21 pm

pandrake
Member
From:: California
Registered: 2005-10-21
Posts: 90
Website

Re: Icons in "display dialog"....

Neat!


Posted by Panrake a.k.a. Tongo a.k.a. Captain Kirk

Offline

 

#4 2008-11-25 01:21:53 pm

mtorrance
Member
From:: Tulsa, OK
Registered: 2005-08-05
Posts: 125

Re: Icons in "display dialog"....

Hey There,

Another option when using the resources folder in a app bundle.

Applescript:


display dialog "" with icon path to resource "iconName.icns" in bundle (path to me)

The basic icons can also be called by name

Applescript:


display dialog "" with icon applet

Applescript:


display dialog "" with icon stop

Applescript:


display dialog "" with icon caution

Cheers,
Mark

Offline

 

#5 2010-05-22 09:11:12 pm

tekbreak
Member
Registered: 2008-11-30
Posts: 1

Re: Icons in "display dialog"....

Useful script! It's not mine, i don't remember where I found it

Applescript:


to show_icons over k for t
   set p to (path to "csrv")'s POSIX path & "CoreTypes.bundle/Contents/Resources/"
   set l to list folder POSIX file p without invisibles
   set e to count l
   set q to true
   set b to "+"
   set m to 1
   repeat
       set f to l's item m
       set i to POSIX file (p & f)
       set s to ((size of (info for i)) + 500) div 1000
       if f ends with ".icns" and s > k then
           set d to f's text 1 thru -6 & return & s & " KB" & return & i
           if not gave up of (display dialog d buttons {"Cancel", "Pause"} default button 2 with icon i giving up after t) then ¬
               set b to button returned of (display dialog d buttons {"Cancel", "-", "+"} default button b with icon i)
           if q then set q to false
       end if
       set m to m + (b & 1)
       if m > e then
           if q then return beep
           set m to 1
       else if m < 1 then
           set m to e
       end if
   end repeat
end show_icons

show_icons over 10 for 1 (* over size (KB), for time (seconds) *)


Filed under: icon, resource

Offline

 

#6 2012-06-18 12:03:15 pm

Skillet
Member
Registered: 2010-01-11
Posts: 133

Re: Icons in "display dialog"....

mtorrance wrote:

The basic icons can also be called by name

Applescript:


display dialog "" with icon applet

Cheers,
Mark


Is this suppose to reference the icon of the script?  It is not working for me if it is.  I am able to reference a bundled script but it doesn't run directly with my script launcher unfortunately.

It sees "applet" as a variable


macOS 10.13.4

Offline

 

#7 2012-06-18 01:39:38 pm

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 559

Re: Icons in "display dialog"....

Yes, that icon applet is a slipup. The correct text equivalent is icon note. It's the icon of the current app, i.e. the applet icon when that's what's running. When the applet has a custom icon it will be that custom icon.

Offline

 

#8 2012-06-22 06:54:49 pm

Skillet
Member
Registered: 2010-01-11
Posts: 133

Re: Icons in "display dialog"....

Wonderful thanks for that information, that is very helpful.

Is there a way to have it reference to itself as a script (i.e. the scripts icon without being a script bundle)?

As you know this always references to whatever application executes it, so if the script is run by QuickSilver you see QuickSilvers icon in the dialog, or Launchbars, QuicKeys etc.  Or if run in AppleScript you get AppleScripts icon since that is what ran the script.

Applescript:

display dialog "" with icon note


macOS 10.13.4

Offline

 

#9 2012-06-23 08:36:16 am

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 559

Re: Icons in "display dialog"....

Skillet wrote:

...the scripts icon without being a script bundle...


Tom's code shows how. EasyFind finds two applet icons:

/System/Library/CoreServices/Menu Extras/Script Menu.menu/Contents/Resources/Applet.icns
/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/Resources
/applet.icns


The .scpt document icon is an Editor resource:

/Applications/Utilities/AppleScript Editor.app/Contents/Resources/SEScriptDocument.icns


Edit: hmm. That second applet.icns path got truncated.

Last edited by alastor933 (2012-06-23 08:38:30 am)

Offline

 

#10 2012-06-26 11:01:24 am

Skillet
Member
Registered: 2010-01-11
Posts: 133

Re: Icons in "display dialog"....

Thank you for the replies, I feel like I am getting closer.  Sorry I wasn't more clear, if I "Get Info" on a file and copy and paste an icon image to a script if I zip and email that script to someone the script icon goes with it to the other Mac.

So if another person runs the script from a script launcher like QuickSilver, LaunchBar, QuicKeys etc how do you have it show the icon you attached with the script (not script bundle).  I can't find the path to the icon even when I show invisibles on my mac.  The only time I see an Icon anything is when I attach an Icon to a folder and then it "Icon" shows up as an invisible file in the folder you attach the icon to.

I hope that makes more sense what I am trying to do.  I might have to use invisibles or something to do this.  When I save the script as an application and use "with icon note" it displays the icon that was copy and pasted to the app as desired even though it is not in a resource folder.  I am trying to get this behavior to happen when attached to a script but run by another app.

I have spent the last three hours working on this but my google skill must stink.  The closest thing I could find related to where the icon is stored is here but doesn't really talk about when copy and pasted http://interestinglythere.com/articles/systemicons/

I am thinking something like this

Applescript:

set myPath to path to me

display dialog "open_image" with title "My Test Call" with icon note of myPath buttons {"Done"} cancel button "Done"

Thank you for the useful info I will be putting that to good use in the future.


macOS 10.13.4

Offline

 

#11 2012-06-26 01:53:39 pm

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 559

Re: Icons in "display dialog"....

Skillet wrote:

...when I attach an Icon to a folder and then it "Icon" shows up as an invisible file in the folder you attach the icon to.


You'll find an icon pasted onto a bundle in the same relative position, i.e. next to the Contents folder.
Some observations:
- it is visible when you select 'show package contents' in Finder
- it is NOT visible when you drill down into that package using Folderglance
- it is NOT visible when you open the package with Folderglance
- it's kind is "Finder document"
- mdls cannot find it:

machinenameunknown:~ $ mdls '/Users/thijs/Desktop/find separator.app/Icon
> '
mdls: could not find /Users/thijs/Desktop/find separator.app/Icon
.


Hypothesis: Finder is using some legacy stuff when you paste an icon in a Get info window.
I believe the 'modern way' is to put an .icns file into the bundle's Resources folder, although that seems not to work with a .scptd bundle.

Skillet wrote:

So if another person runs the script from a script launcher like QuickSilver, LaunchBar, QuicKeys etc how do you have it show the icon


[guesswork] Finder is the only app that knows about that pasted icon. When some other app wants to display the script's icon, it must ask Finder for an icon - and what it's asking for is the icon for this filetype, not the icon of the actual file, so you'll see a generic icon, not the one you pasted. [/guesswork] tongue

Last edited by alastor933 (2012-06-26 02:06:49 pm)

Offline

 

#12 2012-06-26 02:20:32 pm

Skillet
Member
Registered: 2010-01-11
Posts: 133

Re: Icons in "display dialog"....

I was able to open it but it still referenced to a icon file in the apps Resources file "tongue.icns".  It helped to see how you used the "path to me".  I saved the script you made as a script and changed the icon, I want to reference the icon that is part of the script but there is no package to reference (which makes sense if it isn't a bundle or an app).

I ran into an issue with script bundles working properly with some third party apps that run them.

So in the case of this link I would like to have the tomato with the clock show in the dialog box when the script runs but still keep the script the extension .scpt

http://reference.Studioprime.com/forums … e.scpt.zip

Thanks very much for you persistence, I hope I am not frustrating you at all, each post has helped.

Last edited by Skillet (2012-06-26 02:25:18 pm)


macOS 10.13.4

Offline

 

#13 2012-06-28 08:56:46 pm

Skillet
Member
Registered: 2010-01-11
Posts: 133

Re: Icons in "display dialog"....

Good stuff thanks Tom.  I thought about doing something like that too, thanks for all the time and help, much appreciated!

Not to take a left turn, but did you make the icon file through copy and past in Icon Composer?


macOS 10.13.4

Offline

 

#14 2012-06-29 10:00:54 am

Skillet
Member
Registered: 2010-01-11
Posts: 133

Re: Icons in "display dialog"....

That is great, thanks for the info, this will save me several extra steps I have been going through.  Glad I asked.


macOS 10.13.4

Offline

 

#15 2016-03-20 05:23:49 pm

collin
Member
Registered: 2015-10-29
Posts: 2

Re: Icons in "display dialog"....

It's a lot easier just to specify an image like this:

Applescript:

display dialog "Hello" buttons {"Cancel", "Continue"} with icon {"/Users/" & (do shell script "whoami") & "/path/to/picture.jpg"}

The

Applescript:

do shell script

part just makes it work, even if you send it to your friends, although I would then recommend downloading the image from the internet with curl and placing it in a folder. Sorry if it is a bit confusing


Filed under: applescript, dialog box

Offline

 

#16 2016-03-21 06:22:58 am

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 559

Re: Icons in "display dialog"....

I am confused. That code just doesn't look right - it has several syntax anomalies, and one actual error: the image should be an icon.
But, strangely, the code works when given an icon.

The anomalies:
- with icon should be with icon file, when you want to use your own icon
- path should be HFS, not POSIX
- the braces around the path string are a mystery; braces = list, right?

I think this is correct, and it also eliminates the costly do shell:

Applescript:

display dialog "Hello" buttons {"Cancel", "Continue"} with icon file ((path to home folder as text) & "path:to:icon.icns")

Last edited by alastor933 (2016-03-21 06:30:21 am)

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)