 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
UncleScrooge
Joined: 14 Apr 2009 Posts: 75 Location: Italy
|
Posted: Sun Nov 22, 2009 7:36 pm Post subject: Test Icon Resources |
|
|
Hi all from a newbie (almost).
As I got tired to see what was the effect of the icon resources contained in the shell32.dll on my GUIs I wrote this piece of code.
It shows the related numId of each icon as well as the icon itself.
Double clicking on any icon gives the possibility either to see the effect of the Icon in the tray or that as a new icon in the GUI. The latter task is attained destroying the GUI and rebuilding as I haven't find any other way to change my GUI's Icon
| Code: |
#SingleInstance Ignore
; get icon filepath
; assigning to the var _IconFile different values the
; script can act on different icon resources
; here I use shell32.dll
If ( A_OSType = "WIN32_WINDOWS" )
_IconFile = %A_WinDir%\system\shell32.dll
Else
_IconFile = %A_WinDir%\system32\shell32.dll
;adjust for screen height
If (A_ScreenHeight = 600)
_MaxColItems := 12
Else If (A_ScreenHeight = 768)
_MaxColItems := 14
Else If ((A_ScreenHeight = 864) Or (A_ScreenHeight = 900))
_MaxColItems := 16
Else If (A_ScreenHeight = 960)
_MaxColItems := 10
Else If (A_ScreenHeight = 1024)
_MaxColItems := 20
Else If (A_ScreenHeight = 1050)
_MaxColItems := 22
Else
_MaxColItems := 14
_Icon := 1 ; start from icon n 1
InputBox, _IconsNum, %_IconFile%, Enter the Number of icons contained in the resource file`n(Must be an Integer):,,,140,,,,,238
If (ErrorLevel Or _IconsNum = 0)
ExitApp
If _IconsNum Is Not Integer
ExitApp
;build GUI
Gosub BuildGUI
;wait for Ldoubleclick
OnMessage(0x203, "WM_LBUTTONDBLCLK")
Return
WM_LBUTTONDBLCLK(){
global _Icon
global _IconFile
_Icon := ""
MouseGetPos, , , , WotsIt
ChangeIcon(WotsIt)
MsgBox, 8227, Choose action, Icon # %_Icon%`nResource file: %_IconFile%`n==========================================`nDo you want to change just the tray icon or re-build the whole Gui?`n(Yes to change the tray`, No to rebuild the Gui`, Cancel to do nothing)
IfMsgBox Yes
{
Menu, Tray, Icon, %_IconFile%, %_Icon%
}
Else IfMsgBox No
{
Gui, Destroy
Gosub BuildGUI
}
Return
}
ChangeIcon(WotsIt)
{
global _Icon
Loop
{
_Icon := SubStr(WotsIt, StrLen(WotsIt), 1) . _Icon
WotsIt := SubStr(WotsIt, 1, StrLen(WotsIt) - 1)
If !InStr("0123456789",SubStr(WotsIt, StrLen(WotsIt), 1))
Break
}
If InStr("13579",SubStr(_Icon, StrLen(_Icon), 1)) ;if it's odd....
_Icon := Floor((_Icon + 1) / 2)
Else
_Icon := Floor(_Icon / 2)
Return
}
BuildGUI:
{
Ypos := 5
Xoffset := 5
Menu, Tray, Icon, %_IconFile%, %_Icon%
Loop
{
If (A_Index > _IconsNum)
Break
If (Mod(A_Index, _MaxColItems) = 1 And A_Index > _MaxColItems)
{
Xoffset := Xoffset + 60
Ypos := 5
}
Gui, Add, Text, x%Xoffset% y%Ypos%, %A_Index%
Gui, Add, Pic, xp+20 yp Icon%A_Index%, %_IconFile%
Ypos := Ypos + 40
}
Gui, Show, +AutoSize, %_IconFile% Icons
Return
}
GuiClose:
ExitApp
|
by setting here a different path+filename one can explore and test the effect of any open Icon resource.
Just change the top lines after the #SingleInstance directive:
| Code: |
If ( A_OSType = "WIN32_WINDOWS" )
_IconFile = %A_WinDir%\system\shell32.dll
Else
_IconFile = %A_WinDir%\system32\shell32.dll
|
like this:
| Code: |
_IconFile = somedir\somepath\somefile.dll ;or .EXE or whatever
|
_______________________________________________________________________________________
Edit:
- forgot to set the adjustment to screen size in the BuildGui loop. Now it's OK
- Changed MsgBox string. Now displays choosed Icon # and current resource file
_________________ Intel Centrino @ 2.8GHz
4 GB RAM
WIN XP SP3 |
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 942 Location: Germany - Deutschland
|
|
| Back to top |
|
 |
UncleScrooge
Joined: 14 Apr 2009 Posts: 75 Location: Italy
|
|
| Back to top |
|
 |
UncleScrooge
Joined: 14 Apr 2009 Posts: 75 Location: Italy
|
Posted: Mon Nov 23, 2009 11:43 am Post subject: |
|
|
unfortunately though the icon extractor shows the Icon GroupID and not Icon num, lines like this will give unexptected results if _Icon is the red number shown in the right list view of IconEx 1.0 underneath each icon:
| Code: |
Menu, Tray, Icon, %_IconFile%, %_Icon%
|
SKAN's icon extractor is in fact an... extractor, while I was trying to use icons belonging to other resources (especially system's ones) without the trouble of creating an ICO file, that is referring to the resoucefile/iconNum as above.
one way is to modify line 133 (it's in the LVI: proc) of the original SKAN's script like this:
| Code: |
LV_Add("Icon" . A_Index, A_LoopField . "`n" . A_Index)
|
to maintain the capability of saving a single icon right clicking on it I've changed lines 144, 156, 160 and 215 in the SKAN's script:
| Code: |
;from this (the original SKAN's):
LV_GetText( IconGroup, RowNo,1 )
;to this:
LV_GetText( IconGroup, RowNo,1 ), IconGroup := Substr(IconGroup, 1, Instr(IconGroup, "/") -1)
|
Im trying to include a testing routine in the SKAN's script to show the appearance of any given icon in a GUI and in the try, which was my original scope. _________________ Intel Centrino @ 2.8GHz
4 GB RAM
WIN XP SP3 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|