Sign in to follow this  
Followers 0
Diana (Cda)

Q re icon dll, like Shell32.dll ...

5 posts in this topic

I don't remember where I got this script but got it after doing an extensive search months ago if not years ago on the forum:

#Include <Constants.au3>
#NoTrayIcon

Opt("TrayMenuMode",1)   ; Default tray menu items (Script Paused/Exit) will not be shown.

$exititem       = TrayCreateItem("Exit")

TraySetState()

$start = 0
While 1
    $msg = TrayGetMsg()
    If $msg = $exititem Then ExitLoop
    $diff = TimerDiff($start)
    If $diff > 1000 Then
        TraySetIcon("Shell32.dll",Random(0,100,1))
        $start = TimerInit()
    EndIF
WEnd

Exit

Lastly, though it didn't work for me, is there syntax to cycle through ICL icon libraries? The above didn't work on the 2 ICL files I tested it on, so wondering if there was another way for AI to display in systray.

Thx. :P

Share this post


Link to post
Share on other sites



From helpfile (TraySetIcon):

Passing a positive number will reference the string equivalent icon name.

Passing a negative number causes 1-based "index" behaviour. Some Dll can have icon extracted

just with negative numbers.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

From helpfile (TraySetIcon):

Thanks, I'll look at it again. The help file is difficult to decipher sometimes, and this is one of them. Thanks. Edited by Diana (Cda)

Share this post


Link to post
Share on other sites

Hi,

Do some debugging of the code to find your answers.

Add a check to to see that the file your exists..

Check and see if the file has icons, if so then how many icons..

If your calling Random(0, 100, 1), what happens if your file has less then 100 icons?

Random returns for example 99 and you file only has 98 icons then no icon is going to display.

Use index icon number (in other words a negative number) it seems to be more reliable then icon name.

#include <WinAPI.au3>
Opt("TrayMenuMode",1) 

Global $IconResource = @DesktopDir & "\Test.dll"
Global $HowManyIconsInIconResource = _WinAPI_ExtractIconEx($IconResource, -1, 0, 0, 0)

If Not FileExists($IconResource) Then
    MsgBox(0, "File Not Found!", "Couldn't find: " & @CRLF & $IconResource)
    Exit
ElseIf Not $HowManyIconsInIconResource Then
    MsgBox(0, "File Has No Icons!", "The file: " & @CRLF & $IconResource & @CRLF & "File Has No Icons.")
    Exit
EndIf

$exititem       = TrayCreateItem("Exit")

TraySetState()

$start = TimerInit()
While 1
    $msg = TrayGetMsg()
    If $msg = $exititem Then ExitLoop
    $diff = TimerDiff($start)
    If $diff > 1000 Then
        Local $Random = Random(1, $HowManyIconsInIconResource,1)
        Local $TSI = TraySetIcon($IconResource, "-" & $Random)
        ConsoleWrite("-> Tray Set Icon Return Value: " & $TSI & @LF & "The Icon Index Called: " & "-" & $Random & @LF)
        $start = TimerInit()
    EndIF
WEnd

Exit

Cheers

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

If your calling Random(0, 100, 1), what happens if your file has less then 100 icons?

Random returns for example 99 and you file only has 98 icons then no icon is going to display.

<sigh> Didn't know that. My test one has only 15 icons. Actually, by accident I left one of the test script instances running and I did see an icon flash at one point then waited. 3 icons passed in total during that 45 seconds or so. In between just saw the AutoIt default systray icon. That's why it didn't seem to work.

I've come across more in the archives about those negative index numbers. The situation isn't as complicated as all the above would seem to indicate, thankfully <g>. This will work, if I could understand how to apply to the syntax the term "negative number". I understand the concept, but as always, the practical application eludes me. What I've tried I'll list below. I don't usually because I've always felt a little uncomfortable showing the total degree that my ineptitude in scripting can sometimes reach <g>. But a recent meanie showed me that it probably would be better to show it now than face how awful it feels to be slapped down <g>. Can't win either way, anyway, it seems <g>. Don't laugh, though, guys! You all know the terminology and stuff. I never had any of this growing up and I'm learning but only now am I seeing any sort of real impact on what I'm doing and I'm starting to go a little faster. I think I've finally reached that sort of "critical mass" type of point I've been waiting for but never seemed to get any closer to all these months! <lol>.

Firstly, however, this works:

TraySetIcon(@ScriptDir & "\Test.dll",6)
So I ascertained for sure that the procedure to create the DLL (that is, renaming the ICL icon library I created this morning to DLL) is a way to create what seem to be valid icon DLLs and that AutoIt will be able to read them. Okay. That hurdle crossed.

I tried modifying this,

TraySetIcon("Shell32.dll",Random(0,100,1))
to these, but didn't get results as with your checker script:
TraySetIcon("Shell32.dll",Random(-0,100,1))  -- though this one didn't make sense, what the heck, tried it anyway
TraySetIcon("Shell32.dll",Random(0,-100,1))
TraySetIcon("Shell32.dll",Random(0,100,-1))
Plus I stuck a negative or < in other places, which I won't show. You guys are probably laughing yourselves silly as it is :o:P. Anyway, no go.

I mean, as is typical for us newbies with the help file and interpreting, just where in he--, I mean heck, is this "negative index number" supposed to go?

I understand about the icon names vs. the index names. Makes sense. There are no examples for using a "negative index number", though. Not that I've been able to find through very extensive searching, at any rate. If the negative number could be clarified in terms of that line of syntax above, that would in all likelihood then show the DLL being cycled through correctly with no breaks.

-----------------------------------------------

On an aside, now that I know how to create icon DLLs and that they work with Windows and AutoIt, that's going to simplify matters tremendously. I have an AutoIt icon folder that currently houses 483 icons (I use this folder and subfolders as source icons for the entire hdd, not just AI). The subfolders, in particular, could be made into individual icon DLL files by catgory. I'm guessing that I could still add on to those icon DLL files as long as I keep the naming of the icons inside sequential so that even if a sort is done on the packed icons, that the previous icons will retain their position always. Important once scripts are all done and icon positions referenced.

Hmmm, can see a few possibilities here. Thx. :P

Edited by Diana (Cda)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0