Sign in to follow this  
Followers 0
Diana (Cda)

Rotating systray icon?

17 posts in this topic

I now know and use the syntax to replace an AI icon with one of our own choice:

#NoTrayIcon     ; AutoIt's icon doesn't show in systray
TraySetIcon(@ScriptDir & "\Fldr- WAVs.ico")     ; icon here just an example name

Is there any way to make a rotating systray icon, however? Some apps I have use moving systray icons and was wondering, just out of curiousity, if it was possible to emulate that.

Thx. muttley

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You would have to create each of the frames of the spinning ICO - then export each as a different ICO file, then have a loop in your code that cycles through them.

In short, ICO files cannot be animated, at least as far as I know...

EDIT: actually, thats not true - Ive used animated ICO files as favicons on websites, but Im not sure if they were GIF or ICO files. Let me look this up...

Edited by m0nk3yI3unz

Monkeh.

Share this post


Link to post
Share on other sites

You would have to create each of the frames of the spinning ICO - then export each as a different ICO file, then have a loop in your code that cycles through them.

In short, ICO files cannot be animated, at least as far as I know...

EDIT: actually, thats not true - Ive used animated ICO files as favicons on websites, but Im not sure if they were GIF or ICO files. Let me look this up...

Wait for it... Wait for it... Next (so you'll write the code) you'll get "Can you show me an example?" ... muttley

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

lawl SmOke_N

Anyways, I remembered that the animated favicons are GIFs that I use - so what i said earlier still applies.


Monkeh.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

straight from - GUESS WHAT !?! THE help file

so you only need to figure out where to load the icon(s) from (a possible solution could be ICL files )

of course a SINGLE icon file cannot be animated, but you can use a resource with 1..x icons (all as a part of the animation show)

#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
        $num = -Random(0,100,1); negative to use ordinal numbering
        ToolTip("#icon=" & $num)
        TraySetIcon("Shell32.dll",$num)
        $start = TimerInit()
    EndIF
WEnd

Exit
Edited by nobbe

Share this post


Link to post
Share on other sites

Thanks nobbe - I started to look it up but decided to check first.


Monkeh.

Share this post


Link to post
Share on other sites

#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
        $num = -Random(0,100,1); negative to use ordinal numbering
        ToolTip("#icon=" & $num)
        TraySetIcon("Shell32.dll",$num)
        $start = TimerInit()
    EndIF
WEnd

Exit
but it only comes up when the icons are turned off in the systray, etc. Kind of really defeats the purpose <g>.

The moving icons really work though. That part is great.

Thx. muttley

Share this post


Link to post
Share on other sites

Stupid n00b question, though ... where does one put one's code? I tried putting a simple message box in and amongst the above in various, seemingly logical spots

i would program regularly as you do usually , then put the icon things into an adlib() function , start and stop as you want to change icons

Share this post


Link to post
Share on other sites

i would program regularly as you do usually , then put the icon things into an adlib() function , start and stop as you want to change icons

Arrgggh, I'm not having much luck with this. The help file is still like so much Chinese to me <sigh>. I searched the forums and I just don't find anything that helps me wrap my brain around this one. Do you by any chance have a working example? Adlib is another new concept for me to learn. <sigh>

Thanks. muttley

Share this post


Link to post
Share on other sites

Arrgggh, I'm not having much luck with this. The help file is still like so much Chinese to me <sigh>. I searched the forums and I just don't find anything that helps me wrap my brain around this one. Do you by any chance have a working example? Adlib is another new concept for me to learn. <sigh>

Thanks. muttley

http://www.autoitscript.com/forum/index.ph...st&p=546139

Very very sad... you were shown examples. What more do you want people to do for you, take their time (unpaid mind you), write them into standard UDFs so they simply fit into your grand scheme of things?

I'd suggest you start putting an effort into things, after 4 years (I don't care how long of a break you took), you should by now at least be able to write something without someone doing the work for you.

In addition, if you need future help from this forum, and their ever giving hands, I'd suggest you start posting you code, all attempts made by you. Not just... "It doesn't work <sigh>" ... That's B.S.

It's like this in all the language forums you post in. Pure laziness.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

http://www.autoitscript.com/forum/index.ph...st&p=546139

Very very sad... you were shown examples. What more do you want people to do for you, take their time (unpaid mind you), write them into standard UDFs so they simply fit into your grand scheme of things?

I'd suggest you start putting an effort into things, after 4 years (I don't care how long of a break you took), you should by now at least be able to write something without someone doing the work for you.

In addition, if you need future help from this forum, and their ever giving hands, I'd suggest you start posting you code, all attempts made by you. Not just... "It doesn't work <sigh>" ... That's B.S.

It's like this in all the language forums you post in. Pure laziness.

You know, I have to respond to this for one very good reason. If you only KNEW the hours I spend trying to get things on my own, you wouldn't say that. You can't begin to imagine that an otherwise intelligent person like myself can be SO STUPID when it comes to code. Yes. I am. I try and try and it doesn't come easy. So much so that, in perfectly stupid female fashion, I'm here typing this crying, stupid idiot that I am. What I am is stubborn and I persevere. I'm a 46 year old woman that came to computers late in life. I never had any contact with any geeks or anyone that could help me and yet, I'm managed to build by virtue of sheer determination to what I have become today. There is no other effort in my life that has cost me so much trouble and aggravation on abasing myself in a humiliating way. It's a good thing I don't have much of an ego in terms of my not letting these things get me down. I don't know all of you in this forum, obviously, but you're all way smarter than I am when it comes to scripting. I know this. And I try my best. But I just can't seem to do any better than what I do. You'll have to take my word for it that I've come a long way and I wish I knew what is eluding me. Once someone kindly helps out and I know what I'm supposed to do, I can do a lot with the code I do have and every bit of code I go on to recycle and re-use ad infinitum! But I can't seem to figure things out on my own yet very well. In last few weeks, I've made some headway in understanding parts of the help file that were eluding me but I'm still far from anything complex all on my own.

So, Smoke, all I can say to you is to pls ignore my posts. You've helped me out in the past; I recognize your moniker. But I really don't need in my life any more negativity. I really appreciate any and all help everyone has provided on the forum and you can't know how grateful I am. I have no real financial resources beyond the normal costs of living so I know that this education is priceless. And such is today's workforce that every edge we have is an advantage. AutoIt has provided me with an edge and has helped overcome a ton of limitations. I do contract work and am assigned to different places and I now carry around my own personal set of apps to do things because of the wide variety of apps and procedures out there. In all places I am required to hit the ground running yet I am hardly ever given the tools to do this. So I again give a heartfelt thanks to everyone in the forum. I literally have been able to better keep pace with the changes in the workplace thanks to AI. This is not an idle statement I make; it's the truth. Automation allows me to be able to better concentrate on tasks I have to perform rather than what tools I will have or I won't have.

So thanks. Even in the world today there is a lack of tolerance and understanding even though we are more vocal about being equal, etc., but "stupidity" is still something that gets kicked at. Well, so I'm not the brightest bulb in this forum when it comes to scripting. I do a whole bunch of other things extremely well. If there was a way I could learn on my own better, I would. But I don't know what else to do.

Anyway, have a better day all.

Share this post


Link to post
Share on other sites

If you want to change your icon in the system tray, you just call TraySetIcon. If you want to animate it, you call it in a looping fashion. There are literally hundreds of ways to do this.

One suggestion, Adlib, is a function that is called during the regular execution of your script. You just call AdlibEnable.

Show us what you have tried, and we might be able to fix it.

Share this post


Link to post
Share on other sites

You know, I have to respond to this for one very good reason. If you only KNEW the hours I spend trying to get things on my own, you wouldn't say that. You can't begin to imagine that an otherwise intelligent person like myself can be SO STUPID when it comes to code. Yes. I am. I try and try and it doesn't come easy. So much so that, in perfectly stupid female fashion, I'm here typing this crying, stupid idiot that I am. What I am is stubborn and I persevere. I'm a 46 year old woman that came to computers late in life. I never had any contact with any geeks or anyone that could help me and yet, I'm managed to build by virtue of sheer determination to what I have become today. There is no other effort in my life that has cost me so much trouble and aggravation on abasing myself in a humiliating way. It's a good thing I don't have much of an ego in terms of my not letting these things get me down. I don't know all of you in this forum, obviously, but you're all way smarter than I am when it comes to scripting. I know this. And I try my best. But I just can't seem to do any better than what I do. You'll have to take my word for it that I've come a long way and I wish I knew what is eluding me. Once someone kindly helps out and I know what I'm supposed to do, I can do a lot with the code I do have and every bit of code I go on to recycle and re-use ad infinitum! But I can't seem to figure things out on my own yet very well. In last few weeks, I've made some headway in understanding parts of the help file that were eluding me but I'm still far from anything complex all on my own.

So, Smoke, all I can say to you is to pls ignore my posts. You've helped me out in the past; I recognize your moniker. But I really don't need in my life any more negativity. I really appreciate any and all help everyone has provided on the forum and you can't know how grateful I am. I have no real financial resources beyond the normal costs of living so I know that this education is priceless. And such is today's workforce that every edge we have is an advantage. AutoIt has provided me with an edge and has helped overcome a ton of limitations. I do contract work and am assigned to different places and I now carry around my own personal set of apps to do things because of the wide variety of apps and procedures out there. In all places I am required to hit the ground running yet I am hardly ever given the tools to do this. So I again give a heartfelt thanks to everyone in the forum. I literally have been able to better keep pace with the changes in the workplace thanks to AI. This is not an idle statement I make; it's the truth. Automation allows me to be able to better concentrate on tasks I have to perform rather than what tools I will have or I won't have.

So thanks. Even in the world today there is a lack of tolerance and understanding even though we are more vocal about being equal, etc., but "stupidity" is still something that gets kicked at. Well, so I'm not the brightest bulb in this forum when it comes to scripting. I do a whole bunch of other things extremely well. If there was a way I could learn on my own better, I would. But I don't know what else to do.

Anyway, have a better day all.

The underlined is what I think bothers me the most about your posts (I had figured as much).

I can understand trying to get ahead, I can understand tragedy in ones life and the set backs it may incur. I can not however understand someone that repeatedly asks the same questions (albeit different situations) over and over for years without grasping at least the simplest of procedures.

Diana (CDA)... whatever that means... I enjoy this forum and those that participate. Those that have an extreme amount of knowledge, and even those that have none. Watching how people grow with their code, and then contribute back to the forum which made them grow so. But it makes me bitter at times, when I see those that take advantage of the forums eagerness to lend a hand for their own benefit (malicious or not) without ever giving back, or the courtesy of even showing what you've tried or haven't tried code wise.

I did not attack your intelligence, I have no idea what you have done or tried to understand, I can only go off of the numerous posts that you make, and the same question you ask repeatedly without EVER showing an effort of your own... "Could you provide an example please". That in itself tells the tale enough for me.

So for the love of God (whomever that may be for you), if you are going to use this forum and the knowledge base it contains, at least put forth some effort (I'm not taking your word that you did anything without seeing it), and I'll leave your posts alone.

P.S.

I don't answer your questions you have for your benefit... I answer them for others that may end up viewing your thread that have a similar question.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

P.S.

I don't answer your questions you have for your benefit... I answer them for others that may end up viewing your thread that have a similar question.

And that's exactly how I found this page, doing a search for how to set a timer on the tooltip that pops up when you hover over the system tray icon. This didn't provide me with the answer I needed, but I would agree with your sentiment, it's often to help those of us doing searches.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Well, a lot of time has passed. I've looked over so many adlib scripts it's not funny, yet I still am missing something so I'm no closer to a working solution. I guess I haven't seen the right adlib example to understand what's missing and my lack of knowledge is not helping. I animated icons in a loop and I seem to have managed this approach better, it seems. But the problem there is that only the icon animation works in the script. Nothing else happens. I'm hoping that it is something easy enough to fix.

Here's the script below. The reason a rotating icon would be great is that while the back up process is going on, it shows that something is happening, esp. since I used a clock face in which I then drew an hour hand in 4 different positions, so the "animation" looks like a sweeping hand around the clock:

;
; AutoIt
;
#include <_PartitionLetters.au3>     ; this replaces drive letters
#include<_WEReplacement.au3>     ; references a Windows Explorer replacement program
#NoTrayIcon     ; AutoIt's icon doesn't show in systray
AutoItSetOption("WinTitleMatchMode", 2)     ; this allows partial window titles to be valid!


While 1
    TraySetIcon(@ScriptDir & "\test rotating icon1.ico")
    Sleep(1000)
    TraySetIcon(@ScriptDir & "\test rotating icon2.ico")
    Sleep(1000)
    TraySetIcon(@ScriptDir & "\test rotating icon3.ico")
    Sleep(1000)
    TraySetIcon(@ScriptDir & "\test rotating icon4.ico")
    Sleep(1000)
WEnd


;----- Short day of the week, i.e., Monday = Mn instead of Mon -------------------------------------------------------------
#Include <Date.au3>
$ShortDayMyFormat = StringMid("Sn,Mn,Tu,Wd,Th,Fr,Sa", StringInStr("SunMonTueWedThuFriSat", _DateDayOfWeek(@WDAY,1) ), 2)
;---------------------------------------------------------------------------------------------------------------------------

$destinationFolder = $Work_USB_DriveLtr & "\BACKUPS"


If FileExists(@UserProfileDir & "\Favorites\01.rar") Then FileCopy(@UserProfileDir & "\Favorites\01.rar", $destinationFolder & "\*.rar")
Sleep(60000)
Beep(1000,75)

Exit     ; finished
Of course, when I put the working part of the script before the loop, that part then does get done but the icons appear after and then go without end <sigh>.

Thanks in advance for any help with this one.

Edited by Diana (Cda)

Share this post


Link to post
Share on other sites

In all scripts, this loop

While 1
Wend

is what I call "main loop" and the meaning is that whatever is within that loop gets executed every time the script has nothing else to do - that's why your icon rotates over and over.

If you want the animation to take place only when your script is doing something you will have to put that "something" in a function.

While that function is executed you have to use "AdLibEnable" to call your rotating function - (what AdLib will do is to call your function at specified intervals when Your main script is busy doing something else.

I have prepared a small example for you which starts a counter and it changes an icon (from shell32.dll ... you can use instead your icons there)

Have a look at my script, it has everything you might need, all you have to do is to understand my script and apply the same to yours.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 181, 83, 193, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$label = GUICtrlCreateLabel("0", 16, 24, 42, 17, BitOR($SS_CENTER,$SS_SUNKEN))
$Button1 = GUICtrlCreateButton("Start", 16, 56, 65, 17, 0)
GUICtrlSetOnEvent(-1, "Button1Click")
$Icon1 = GUICtrlCreateIcon("shell32.dll", 10, 112, 16)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $CurrentIcon = "Icon1" ;this holds the current icon, used to decide the order the icons will change

While 1
    Sleep(100)
WEnd

Func Button1Click()
    AdlibEnable("ChangeIcon", 500)  ;start AdLib
    For $i=1 To 100                 ;this is just an example
        GUICtrlSetData($label, $i)
        Sleep(50)
    Next
    AdlibDisable()                  ;stop AdLib so it won't change the icons anymore
EndFunc
Func ChangeIcon()
    Switch $CurrentIcon
        Case "Icon1"
            GUICtrlSetImage($Icon1, "shell32.dll", 11)
            $CurrentIcon = "Icon2"
        Case "Icon2"
            GUICtrlSetImage($Icon1, "shell32.dll", 10)
            $CurrentIcon = "Icon1"
    EndSwitch
EndFunc

Func Form1Close()
    Exit
EndFunc

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Diana (cda),

You have not created an adlib function in your script you need to create the function at the end of you script and not in the main code.

Also when you run the function you do not want to have the followinf process.... change icon, wait, change icon, wait, change icon, wait as this will execute everytime you run the adlib script.

What you need to do is get the adlib script going and then change the icon once each time it is executed, every 250ms by default.

So try this:

;
; AutoIt
;
#include <_PartitionLetters.au3>    ; this replaces drive letters
#include<_WEReplacement.au3>    ; references a Windows Explorer replacement program
#NoTrayIcon ; AutoIt's icon doesn't show in systray
AutoItSetOption("WinTitleMatchMode", 2) ; this allows partial window titles to be valid!

Dim $ico = 0


;----- Short day of the week, i.e., Monday = Mn instead of Mon -------------------------------------------------------------
#Include <Date.au3>
$ShortDayMyFormat = StringMid("Sn,Mn,Tu,Wd,Th,Fr,Sa", StringInStr("SunMonTueWedThuFriSat", _DateDayOfWeek(@WDAY,1) ), 2)
;---------------------------------------------------------------------------------------------------------------------------

$destinationFolder = $Work_USB_DriveLtr & "\BACKUPS"

AdlibEnable("icoadlib")

If FileExists(@UserProfileDir & "\Favorites\01.rar") Then FileCopy(@UserProfileDir & "\Favorites\01.rar", $destinationFolder & "\*.rar")
Sleep(60000)
Beep(1000,75)
AdlibDisable
Exit    ; finished



Func icoadlib()   

If $ico = 4 Then $ico = 0
$ico = $ico + 1
    TraySetIcon(@ScriptDir & "\test rotating icon" & $ico & ".ico")
WEnd
EndFunc

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