Extracting File icons

I wrote a simple AS to printout folder’s file lists. I want to add the file’s icons. Is there any way to extract those system wide icons from the GUI using anything?

Model: powerbook
Browser: Safari 534.57.2
Operating System: Mac OS X (10.6)

Here is a draft script :


#[SCRIPT]

on run
	choose file
	my main({result})
end run


on open (sel)
	my main(sel)
end open

on main(theSel)
	(*
Fill the clipboard with a fake string *)
	set tt to "All The Things You Could Be By Now If Sigmund Freud's Wife Was Your Mother, © Charles Mingus"
	set the clipboard to tt
	
	tell application "Finder"
		activate
		copy theSel's item 1 to s
		open information window of (s as alias)
		tell application "System Events" to tell application process "Finder"
			tell window 1
				keystroke tab # select icon button
				keystroke ("cw") using command down # (copy or paste) + close window
			end tell # window 1
		end tell # application System Events .
	end tell # Finder
	(*
Loop waiting the achievement of the Copy task. *)
	tell current application
		repeat 10 times
			try
				the clipboard as «class PNGf»
				exit repeat
			on error
				delay 0.1
			end try
		end repeat
		(*
Here the clipboard contain six resources :
«class icns», «class 8BPS», «class BMP », «class TPIC»,	«class PNGf», «class jp2 »
*)
		# If you want to save in a file, you may isolate a single resource with such code :
		set the clipboard to (the clipboard as «class PNGf»)
	end tell
	# here insert code defining the target document where you want to paste.
	# in this bare sample, a blank TextEdit document is supposed to be open
	
	set theApp to "TextEdit"
	# now, paste 
	
	tell application theApp to activate
	tell application "System Events" to tell process theApp
		keystroke "v" using command down
	end tell # application System Events .
	
end main

#[/SCRIPT]

Yvan KOENIG (VALLAURIS, France) jeudi 28 février 2013 12:19:35