AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Crazy Scripting : IconEx v1.0 - Icon Explorer/Extractor
Goto page Previous  1, 2
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Laszlo



Joined: 14 Feb 2005
Posts: 3943
Location: Pittsburgh

PostPosted: Wed May 14, 2008 6:00 pm    Post subject: Reply with quote

Nice improvements!

Do you know why the Vista shell32.dll icon numbers are so weird? After Icon #338 the next one is #512, followed by #1001..1011, then #8240, and #16710..16783.
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5581

PostPosted: Wed May 14, 2008 10:39 pm    Post subject: Reply with quote

Laszlo wrote:
Do you know why the Vista shell32.dll icon numbers are so weird? After Icon #338 the next one is #512, followed by #1001..1011, then #8240, and #16710..16783.


It is ditto in XP!
Those are Ordinal numbers, almost similar to A_Index

The numbers between 338 and 512 would probably been used by other types of resources in the same DLL

For example :

For a project: I collect my different type of resources like Bitmaps, Jpeg and Icons and place them in folder and loop them.
A_LoopFileName would give me them in the order they were added.
I would ascertain the data type by the file extension, and pass A_Index+100 as Ordinal number

like.. .
ICO will be added as RT_GROUP_ICON
BMP will be added as RT_BITMAP
JPG will be added as RT_RCDATA

When I open the resource file with ResHacker,
it shows me the resources arranged according to data type,
and my A_Index+100 numbers gets jumbled across various data types

In XP - shell32.dll, the last ordinal for Group Icon is 16721.
As you say, for Vista it is 16783, they have been added later.


Smile
Back to top
View user's profile Send private message
heresy



Joined: 11 Mar 2008
Posts: 225

PostPosted: Wed May 14, 2008 11:06 pm    Post subject: Reply with quote

hey SKAN nice improvements
it seems it's reasonable to be called v1.0
i have no more suggestion. close to perfect now Smile
i love it Thanks!

PS. also thanks for informing sean's neat function
sometimes treasures are in Ask for Help that we missing usually
_________________
Consider a Donation to AutoHotkey & let's support Wiki & Join IRC
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5581

PostPosted: Wed May 14, 2008 11:17 pm    Post subject: Reply with quote

Thanks heresy. Smile

heresy wrote:
i have no more suggestion. close to perfect now Smile


I find that with some DLLs, IconEx acts strange.. though nothing is wrong with my code. I have learn more to handle these exceptions.

Please do report any glitches in the GUI interface.. I have applied lots of hellish workarounds.

Smile
Back to top
View user's profile Send private message
heresy



Joined: 11 Mar 2008
Posts: 225

PostPosted: Wed May 14, 2008 11:40 pm    Post subject: Reply with quote

i think there's a little mistake.
FileSelectFolder dialog doesn't submit the selected path

and it's not that important but i just curious that why it doesn't support ICL (icon library)?
_________________
Consider a Donation to AutoHotkey & let's support Wiki & Join IRC
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5581

PostPosted: Wed May 14, 2008 11:58 pm    Post subject: Reply with quote

heresy wrote:
i think there's a little mistake.
FileSelectFolder dialog doesn't submit the selected path


Corrected!

Line #320 : ControlSetText,,%tFolder%, ahk_id %hSHAC%
should have been
ControlSetText,,%nFolder%, ahk_id %hSHAC%

Thanks for reporting it.

heresy wrote:
and it's not that important but i just curious that why it doesn't support ICL (icon library)?


ICL file is not a PE file .. it is a 16bit NE file, means all the goody API functions available in >= W2K will not work with it.

You do not need ICL unless you use Windows 98 SE
DLL is the way to go and I am already working on script that will create a Resource-only-DLL when provided with a folder full of the extracted ICONS.

Smile
Back to top
View user's profile Send private message
heresy



Joined: 11 Mar 2008
Posts: 225

PostPosted: Thu May 15, 2008 12:28 am    Post subject: Reply with quote

SKAN wrote:
DLL is the way to go and I am already working on script that will create a Resource-only-DLL

i really expect this Smile
thank you SKAN for all your devotions
_________________
Consider a Donation to AutoHotkey & let's support Wiki & Join IRC
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5581

PostPosted: Thu May 15, 2008 3:19 pm    Post subject: Reply with quote

How to include an Icon in your script ?

The following template script demonstrates the loading of an icon included in the script itself and sets the
    Tray Icon
    Titlebar Icon
    Alt-Tab menu Icon

Code:
#NoTrayIcon
IconDataHex =
( join
2800000010000000200000000100040000000000C000000000000000000000000000000000000000C6080800CE
101000CE181800D6212100D6292900E13F3F00E7525200EF5A5A00EF636300F76B6B00F7737300FF7B7B00FFC6
C600FFCEC600FFDEDE00FFFFFF00CCCCCCCCCCCCCCCCC00000000000000CC11111111111111CC22222CFFE2222
2CC33333CFFE33333CC44444CFFE44444CC55555CFFE55555CC55555CFFE55555CC55555CFFE55555CC66666CF
FE66666CC77777777777777CC88888CFFC88888CC99999CFFC99999CCAAAAAAAAAAAAAACCBBBBBBBBBBBBBBCCC
CCCCCCCCCCCCCC0000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000
)
VarSetCapacity( IconData,( nSize:=StrLen(IconDataHex)//2) )
Loop %nSize% ; MCode by Laszlo Hars: http://www.autohotkey.com/forum/viewtopic.php?t=21172
  NumPut( "0x" . SubStr(IconDataHex,2*A_Index-1,2), IconData, A_Index-1, "Char" )
IconDataHex := ""            ; contents needed no more
hICon := DllCall( "CreateIconFromResourceEx", UInt,&IconData
                , UInt,0, Int,1, UInt,196608, Int,16, Int,16, UInt,0 )
             
; Thanks Chris : http://www.autohotkey.com/forum/viewtopic.php?p=69461#69461       
Gui +LastFound               ; Set our GUI as LastFound window ( affects next two lines )
SendMessage, ( WM_SETICON:=0x80 ), 0, hIcon  ; Set the Titlebar Icon
SendMessage, ( WM_SETICON:=0x80 ), 1, hIcon  ; Set the Alt-Tab icon

; Creating NOTIFYICONDATA : http://msdn.microsoft.com/en-us/library/aa930660.aspx
; Thanks Lexikos : http://www.autohotkey.com/forum/viewtopic.php?p=162175#162175
PID := DllCall("GetCurrentProcessId"), VarSetCapacity( NID,444,0 ), NumPut( 444,NID )
DetectHiddenWindows, On
NumPut( WinExist( A_ScriptFullPath " ahk_class AutoHotkey ahk_pid " PID),NID,4 )
DetectHiddenWindows, Off
NumPut( 1028,NID,8 ), NumPut( 2,NID,12 ), NumPut( hIcon,NID,20 )
Menu, Tray, Icon                                           ;   Shows the default Tray icon
DllCall( "shell32\Shell_NotifyIcon", UInt,0x1, UInt,&NID ) ; and we immediately modify it.
Gui, Show, w640 h480               
Return

GuiClose:
 ExitApp


About the hex data:
With IconEx, extract any interesting 16x16-4bit icon
Convert binary to hex
Chop of the the first 44 hex characters ( 22 bytes )
Replace the hex data in template with it.

If you are less bothered about the extra 22 bytes an icon carries,
use the whole of the hex data and add an offset of 22 to &IconData as follows:

Code:
hICon := DllCall( "CreateIconFromResourceEx", UInt,&IconData+22
                , UInt,0, Int,1, UInt,196608, Int,16, Int,16, UInt,0 )


About Alt-Tab icon
Alt-Tab menu requires a 32x32 sized icon. so you may have repeat the procedure to load create and load it. The icon used in the template was created by me .. and I have designed it in such a way that it does not show artifacts when resized to 32x32.

If somebody wants .. I can write a IcoToHex converter script!

On a related note,
My script posted in the following topic demonstrates Animation of Tray Icon :


I converted four 16x16x4b icons to hex, chopped off the first 44 chars, made them into a single string, and refer the individual Icondata with an offset of 296.

Smile

Edit:NumPut( hIcon,NID,20 ) was missing in the code, now added. Sorry ofr the inconvenience


Last edited by SKAN on Thu May 15, 2008 10:07 pm; edited 1 time in total
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 3943
Location: Pittsburgh

PostPosted: Thu May 15, 2008 4:13 pm    Post subject: Reply with quote

The above script changes the Alt-TAB icon, the taskbar icon and the title bar icon to "i", but leaves the tray icon blank. Is it a Vista problem?
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5581

PostPosted: Thu May 15, 2008 4:54 pm    Post subject: Reply with quote

Laszlo wrote:
Is it a Vista problem?


Not a problem really.. I think Vista requires a minimum of 256 colors for a tray icon whereas I have used a 16 color icon - to contain script size.

I will try in Vista and post again.

Smile

Edit: Seems to be a different problem.. I tried 4bit, 8bit and 32bit .. nothing works Sad
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 3943
Location: Pittsburgh

PostPosted: Thu May 15, 2008 5:06 pm    Post subject: Reply with quote

Maybe an appropriate call to Shell_NotifyIcon with NIM_SETVERSION (0x00000004) helps?
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5581

PostPosted: Thu May 15, 2008 10:16 pm    Post subject: Reply with quote

NumPut( hIcon,NID,20 ) was missing in the code, now added. Sorry for the inconvenience.

I posted tested code from PSPad and it was a matter of ^a ^c and ^v .
I would understand if I had missed the starting or ending line, but this, I keep guessing. Sad

Also I tested my other HDD indicator, and it works fine in Vista.

Smile
Back to top
View user's profile Send private message
heresy



Joined: 11 Mar 2008
Posts: 225

PostPosted: Thu May 15, 2008 11:27 pm    Post subject: Reply with quote

Thanks SKAN for kindly answer as always

i don't get it perfectly yet
but i know that you're the person who can explain complicated things as easy as possible.
if i can't understand yours, i shall not understand anything else.
so i'll deal with it until i can get it mine Smile
THANK YOU SO MUCH!

it aren't goes to your great Tips & Tricks collection?
_________________
Consider a Donation to AutoHotkey & let's support Wiki & Join IRC
Back to top
View user's profile Send private message
jfty.009260



Joined: 18 Mar 2008
Posts: 7

PostPosted: Fri May 16, 2008 5:55 am    Post subject: Reply with quote

Crazy scripting indeed...brilliant.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group