Jump to content

SetTrayIcon always success


MikeP
 Share

Recommended Posts

Hi, I'll try describing my problem as precisely as possible to make sure you understand. At the start of my script I'm using #NoTrayIcon then setting up my own with SetTrayIcon(".\ico\*****.ico") what I would like to do is hiding it with TraySetState(2) if a stupid user of my application is going to the ico directory to rename the .ico file.

So I tried this :

$trayIco = TraySetIcon(".\ico\******.ico")
MsgBox(0, "", $trayIco)
If $trayIco = 0 Then
    TraySetState(2)
Else
    TraySetState()
EndIf

The problem is, wether the script is compiled or not, If i'm changing the ico file name so that the script will fail, the Msgbox always popup with 1 .. which means TraySetIcon was successful...

Any ideas?

Link to comment
Share on other sites

Mayb this?

Global $check = False

$IconPath = "c:\Temp\autorun1.ico"

$trayIco = TraySetIcon($IconPath)

While 1
    If (FileExists($IconPath) = 0) And ($check = True) Then
        $check = False
        TraySetState(2)
    ElseIf (FileExists($IconPath) = 1) And ($check = False) Then
        $check = True
        TraySetState()
    EndIf
    Sleep(50)
WEnd
Edited by rasim
Link to comment
Share on other sites

Nice way-around.. there's a little mistake in the initialization $check must be True , this script is not the 100% perfect solution though. For a few milliseconds the icon of the .exe file still appear in the tray.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...