Sign in to follow this  
Followers 0
footswitch

Help: resetting TraySetOnEvent() functions

4 posts in this topic

Hey there!

I've been trying to work with the new tray functions provided in the beta version, and the problem here seems to be the TraySetOnEvent() function.

When I associate a function to an event, i.e. mouse clicking, and after that I want to DEassociate that function, what can I do?

I tried several things, but none of them seemed to work.

A code is provided below. It creates the tray icon and some menu items, then it uses the TraySetOnEvent(), and then I'd like to return to the normal (initial) behaviour...

#NoTrayIcon
#include <Constants.au3>
TraySetIcon("Shell32.dll",78); changes the tray icon (n. 78 in shell32.dll)

AutoItSetOption("TrayAutoPause",0); deactivates autopause
AutoItSetOption("TrayMenuMode",1); deactivates default menu (pause e exit)
AutoItSetOption("TrayOnEventMode",1); enables tray on event functions
TrayReset(); sets normal tray behaviour

TrayCreateItem("one item",-1,-1,0); creates first menu item
;TrayItemSetOnEvent ( -1, "BackupAsk")
TrayCreateItem("")
TrayCreateItem ( "other item",-1,-1,0); creates second menu item
TrayItemSetOnEvent ( -1, "Quit")

Sleep(10000); 10 seconds with normal behaviour
TrayError(1); changes tray behaviour

Sleep(10000); 10 seconds with new behaviour
TrayReset(); resets tray behaviour

Sleep(10000); 10 seconds with HYBRID behaviour

Func TrayError($error)
    If $error Then
        TraySetState(4); starts blinking
        TraySetToolTip("there was an error")
        TraySetClick(0); disables access to the tray menu
        TraySetOnEvent($TRAY_EVENT_PRIMARYUP,"BackupError"); ---------- THIS ----------
        TraySetOnEvent($TRAY_EVENT_SECONDARYUP,"BackupError"); ---------- THIS ----------
    Else
        TrayReset();
    EndIf
EndFunc

Func BackupError()
    MsgBox(16,"Error","Error message")
    TrayReset()
EndFunc

Func TrayReset()
    TraySetState(8); stops blinking
    TraySetToolTip("normal behaviour")
; ---------- THIS ----------
; HERE I WANT DO DISABLE THE TraySetOnEvent() AND RESTORE THE TraySetClick()
    TraySetClick(8+1); access to the tray menu is provided with left or right click
; The menu is now displayed BUT the BackupError() function is still called!!!!!!!
; ---------- THIS ----------
EndFunc

Func Quit()
    Exit
EndFunc

Thanks a lot for your help!

Best regards,

footswitch


Share this post


Link to post
Share on other sites



Try adding a new function that doesn't do anything, and re-associate to that function in this one:

Func BackupError()

MsgBox(16,"Error","Error message")

TrayReset()

TraySetOnEvent($TRAY_EVENT_PRIMARYUP,"DeadRug") ; ----new

TraySetOnEvent($TRAY_EVENT_SECONDARYUP,"DeadRug"); ---new

EndFunc

Func DeadRug

;

EndFunc


Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites

Try adding a new function that doesn't do anything, and re-associate to that function in this one:

Func BackupError()

MsgBox(16,"Error","Error message")

TrayReset()

TraySetOnEvent($TRAY_EVENT_PRIMARYUP,"DeadRug") ; ----new

TraySetOnEvent($TRAY_EVENT_SECONDARYUP,"DeadRug"); ---new

EndFunc

Func DeadRug

;

EndFunc

that's a workaround, yes :D lol

what i was wondering was if that is the only "solution"... unless someone tells me that initially autoit associates these actions with null functions.

but thanks anyway. after all this serves my purpose :D

______________

footswitch


Share this post


Link to post
Share on other sites

That is probably the only solution. Those tray functions are somewhat new to the language. You could write to experts and complain that they should clean up their software, but they could get bored working on that little stuff. They are always working to give the language more basic functionality. What you could insist on is that something like this would work ( but it probably doesn't ) :

TraySetOnEvent($TRAY_EVENT_PRIMARYUP, ""); ----new
TraySetOnEvent($TRAY_EVENT_SECONDARYUP, ""); ---new

because you can stop SoundPlay($mySong) with SoundPlay("").


Das Häschen benutzt Radar

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