Sign in to follow this  
Followers 0
Andy16

Context Menu Of Tray Icon

7 posts in this topic

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

Share this post


Link to post
Share on other sites



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

In 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.

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

you need to use tray events not guievents i.e.

#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.

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by SmOke_N

[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

#6 ·  Posted (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 by Uten

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 :mellow: Edited by SmOke_N

[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

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