Andy16 Posted April 3, 2006 Share Posted April 3, 2006 Hi out there, is there an easy way of referencing funciton calls via menu items in the context menu of the tray icon? (right click the icon normaly shows PAUSE and EXIT - I'd like to add something like "RUN TEST" there and reference a funcion in my script....) any help is welcome :"> regards Link to comment Share on other sites More sharing options...
GaryFrost Posted April 3, 2006 Share Posted April 3, 2006 Hi out there,is there an easy way of referencing funciton calls via menu items in the context menu of the tray icon?(right click the icon normaly shows PAUSE and EXIT - I'd like to add something like "RUN TEST" there and reference a funcion in my script....)any help is welcome :"> regardsIn the beta, Tray Functions SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Andy16 Posted April 3, 2006 Author Share Posted April 3, 2006 OK, upgraded to latest beta #include <GUIConstants.au3> AutoItSetOption ( "GUIOnEventMode", 1) Func runme() MsgBox(0, "Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE) EndFunc $item = TrayCreateItem("Options") GUICtrlSetOnEvent($item,"runme") do sleep(1000) until (2<1) menu is there - fine - but NOTHING happens selecting it. Must be a stupid one..... Andy Link to comment Share on other sites More sharing options...
GaryFrost Posted April 3, 2006 Share Posted April 3, 2006 you need to use tray events not guievents i.e. expandcollapse popup#include <Constants.au3> #NoTrayIcon Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) ; Default tray menu items (Script Paused/Exit) will not be shown. $item = TrayCreateItem("Options") TrayItemSetOnEvent($item,"runme") $exit = TrayCreateItem("Exit") TrayItemSetOnEvent(-1,"ExitEvent") TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE,"SpecialEvent") TraySetOnEvent($TRAY_EVENT_SECONDARYUP,"SpecialEvent") TraySetState() While 1 Sleep(10) ; Idle loop WEnd Exit Func runme() MsgBox(0, "Pressed", "ID=" & @TRAY_ID) EndFunc ; Functions Func SpecialEvent() Select Case @TRAY_ID = $TRAY_EVENT_PRIMARYDOUBLE Msgbox(64,"SpecialEvent-Info","Primary mouse button double clicked.") Case @TRAY_ID = $TRAY_EVENT_SECONDARYUP Msgbox(64,"SpecialEvent-Info","Secondary mouse button clicked.") EndSelect EndFunc Func ExitEvent() Exit EndFunc SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 3, 2006 Moderators Share Posted April 3, 2006 (edited) You don't have a GUI so Msgbox will fail:#include <constants.au3> Opt("TrayOnEventMode", 1) Opt('TrayAutoPause', 0) $item = TrayCreateItem("Options") TrayItemSetOnEvent($item, "runme") While 1 Sleep(1000) WEnd Func runme() MsgBox(0, 'Testing', 'Tested') EndFunc @Gary... The #NoTrayIcon is pretty funny there for that example Edited April 3, 2006 by SmOke_N 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. Link to comment Share on other sites More sharing options...
Uten Posted April 3, 2006 Share Posted April 3, 2006 (edited) You don't have a GUI so Msgbox will fail: To little coffe today@ SmOke_N?? Just add TraySetState() and the sample works perfectly. TrayItemSetOnEvent($item, "runme") TraySetState() errrh, or did I misunderstand a joke :"> Edited April 3, 2006 by Uten Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 3, 2006 Moderators Share Posted April 3, 2006 (edited) To little coffe today@ SmOke_N?? Just add TraySetState() and the sample works perfectly. TrayItemSetOnEvent($item, "runme") TraySetState() errrh, or did I misunderstand a joke :">MsgBox(0, "Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE)I was replying to him trying to get GUI id's/winhandles/ctrlhandles from something that didn't have a GUI... No joke Edited April 3, 2006 by SmOke_N 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. 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