footswitch Posted June 24, 2006 Share Posted June 24, 2006 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... expandcollapse popup#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 Link to comment Share on other sites More sharing options...
Squirrely1 Posted June 27, 2006 Share Posted June 27, 2006 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 Link to comment Share on other sites More sharing options...
footswitch Posted June 27, 2006 Author Share Posted June 27, 2006 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"); ---newEndFuncFunc DeadRug ;EndFuncthat's a workaround, yes lolwhat 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 ______________footswitch Link to comment Share on other sites More sharing options...
Squirrely1 Posted June 29, 2006 Share Posted June 29, 2006 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now