Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sammy.d

macrumors regular
Original poster
Jun 18, 2010
109
0
Hi,
I have created a service in Automator which uses an 'Ask for Confirmation' prompt. The whole thing runs fine except when the confirmation prompt appears, it has the basic application icon in the dialog box (the blank documents with the pencil A of pencils/ruler on top). How can I change that icon to something of my own, or even the Automator robot icon?

(when running the service from within Automator, the little robot bloke appears in the prompt. the problem comes when running the service outside of automator)

Cheers.
 

kryten2

macrumors 65816
Mar 17, 2012
1,114
99
Belgium
Use Applescript display dialog

You can click to change the icon in the Ask for Confirmation action. I tried dropping an icns file onto the icon to change it but that didn't work. I'm still on Leopard perhaps it works on SL or Lion. If you want custom icons replace the Ask for Confirmation action with a run Applescript action.

From the AppleScript Language Guide :

with icon (text | integer)
The resource name or ID of the icon to display.
with icon (stop | note | caution)
The type of icon to show. You may specify one of the following constants:
stop (or 0): Shows a stop icon
note (or 1): Shows the application icon
caution (or 2): Shows a warning icon, badged with the application icon
with icon (alias | file)
An alias or file specifier that specifies a .icns file.

Code:
(*
Using dialog with title in Automator

The cause of the problem is that Automator imports the terminologies of ¬
Applescript Studio, which redefines redefines display dialog as part of the ¬
Panel Suite; that version doesn't have the with title parameter. You can ¬
check that by opening Automator using the Applescript editor. (Use ¬
File→Open Dictionary...) I agree that this is a stupid decision by Apple :(

You can circumvent this problem by using
*)
set myIcon to ("///Users/test/Downloads/powerb/PowerButton.icns") as POSIX file -- set custom icon if you like
using terms from application "Finder"
	display dialog "A simple dialog with a custom icon" buttons ¬
		{"Cancel", "Sleep", "Shut Down"} default button 3 ¬
		with title "Shut down or sleep Mac mini" with icon myIcon -- if using custom icon
end using terms from
(*
from inside Automator; this tells Applescript's compiler to make the display ¬
dialog command call the standard definition.
*)
 

Attachments

  • Picture 1.png
    Picture 1.png
    16.8 KB · Views: 362
  • Picture 2.png
    Picture 2.png
    17 KB · Views: 359
  • Picture 4.png
    Picture 4.png
    28.8 KB · Views: 425
Last edited:

sammy.d

macrumors regular
Original poster
Jun 18, 2010
109
0
I changed the "Ask for Confirmation' action to a 'Run Applescript' action like you said and now I get the icon working fine. Thanks for that.

Do you have any idea why it wasn't working before? I have attached the images below, the robot appears when the service is run from Automator but the generic icon appears when run from anywhere else...
 

Attachments

  • Screen Shot 2012-04-24 at 5.16.05 PM.png
    Screen Shot 2012-04-24 at 5.16.05 PM.png
    12.3 KB · Views: 1,367
  • Screen Shot 2012-04-24 at 5.16.26 PM.png
    Screen Shot 2012-04-24 at 5.16.26 PM.png
    10.9 KB · Views: 1,361
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.