Dialog icons

My problem rests in the standard additions dictionary:

[with icon number or string] : the resource name or ID of the icon to display.

I’ve seen a system icon before (The blue faced finder icon or the padlock) but how do I get them?

try:

tell application "Finder"
	activate
	display dialog "hello" with icon 1
end tell
tell application "iTunes"
	activate
	display dialog "hello" with icon 1
end tell

it always shows the icon of the application it was called from …

Thankyou, but how do I get a padlock icon? (I saw it in an administrator permission needed dialog)

You’re trying to use an icon from another app?

hello,

Hi,

You have to be more specific. There are a lot of padlock icons.

gl,

one thing is you can try to check the system icons until you find it.

gl,

any padlock icon. It really dosen’t matter. I’va also noticed that this don’t seem to work.:


set player_type to (choose from list types with prompt "What type of person are you?" cancel button name "")
	display dialog "Welcome to Hassumi, " & player_name & "." with icon "Gentfamdisc:Users:Tim:Desktop:Hassumi:Data:Gems:Water Gem.icns"

try: … with icon alias “Gentfamdisc:Users:Tim:Desktop:Hassumi:Data:Gems:Water Gem.icns”

it works for example with ‘display dialog’ - I am not sure about ‘choose from list’ - does it show an icon at all?

what does “file dose not contain an icon” mean?

I’m afraid that display dialog is the only command from Standard Additions’ User Interaction Suite that has a with icon parameter.

You could probably borrow a padlock icon with something like this:

set icn to path to resource "Security.icns" in bundle file ((path to "csrv" as Unicode text) & "SecurityAgent.app")
display dialog "I'm all locked up..." with icon icn

As far as the padlock goes, thats exactly what I wanted. Thanks!

appart from that, I’m making a dialog game called “Hassumi” but can’t get the .icns to work.


set wicons to alias "Gentfamdisc:Users:Tim:Desktop:Hassumi:Data:Gems:Water Gem.icns"
set wiconr to alias "Gentfamdisc:Users:Tim:Desktop:Hassumi:Data:Power Stones:Deep Water.icns"
display dialog "Welcome to the land of Hassumi." & return & "In this land you will find out about the 5 gems of power." buttons {"OK"} with icon alias wiconr
set button to the button returned of (display dialog "Please, stranger, What will you do?" buttons {"Load Game", "New Game"} default button {"New Game"})
if button is "New Game" then
	set player_name to the text returned of (display dialog "Please tell us your name:" default answer "" buttons {"Thats me!"})
	list folder "Gentfamdisc:Users:Tim:Desktop:Hassumi:Data:Power Types"
	set types to the result
	set player_type to (choose from list types with prompt "What type of person are you?" cancel button name "")
	display dialog "Welcome to Hassumi, " & player_name & "." with icon "Gentfamdisc:Users:Tim:Desktop:Hassumi:Data:Power Stones:Deep Water.icns"
end if

Hi again, Fistoprince.

Looks to me like you haven’t specified the icons quite correctly. At the start of your script, the values of the variables wicons and wiconr are set to aliases:

set wicons to alias "Gentfamdisc:Users:Tim:Desktop:Hassumi:Data:Gems:Water Gem.icns" set wiconr to alias "Gentfamdisc:Users:Tim:Desktop:Hassumi:Data:Power Stones:Deep Water.icns"
A little later, the icon represented by the variable wiconr (which is already an alias) is again specified as an alias:

display dialog "Welcome to the land of Hassumi." & return & "In this land you will find out about the 5 gems of power." buttons {"OK"} with icon alias wiconr

This causes some confusion and results in an error number -1700 [errAECoercionFail]:

Removing the alias specifier should fix the problem:

display dialog "Welcome to the land of Hassumi." & return & "In this land you will find out about the 5 gems of power." buttons {"OK"} with icon wiconr

Later in the script, we have:

display dialog "Welcome to Hassumi, " & player_name & "." with icon "Gentfamdisc:Users:Tim:Desktop:Hassumi:Data:Power Stones:Deep Water.icns"

This time, the icon reference is a tad under-specified - since it’s just a string (when the display dialog command expects either an alias or file reference to the ‘.icns’ file). This results in a different kind of failure: error number -192 [resNotFound]:

The fix here is, of course, to add an alias specifier - or to use one of the variables (wicons or wiconr) defined earlier. :slight_smile:

It says "file does not contain an icon. Can it open up an image file of an icon that has been renamed .icns? Thats what I did.

No, I’m afraid that won’t work, Fistoprince - you need a genuine icon file. For more information on how to go about making one, check out the discussion on script icons.

Oh #@â—Š§ (Excuse my french).