Jump to content

Recommended Posts

Hey everyone,


I have what is likely a pretty dumb question, but I have been searching for hours and I just can't find the answer to this.  I have code for a tray menu all made, and I have a program that I would like to put it in.  The issue is, the code to my tray menu has a While 1 loop in it, and it just goes to that and sits there without running any of the other code.


All tray menu icon examples I've found have just been the code for the menu itself, never actually implemented into a program.  Do you create a function that's called when you right click the icon or something?  How the heck do I make this work???  I'm sure it's blindingly simple, maybe I'm just not finding the right words to search for solutions.....


Thanks, pulling out my hair on this one!!

Link to post
Share on other sites

In case anyone needs to see it, here is the code for the tray icon menu:

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant.
#Include <Constants.au3>


global $PrintPolice        = TrayCreateItem("Print Server")
global $CreditConstable    = TrayCreateItem("Credit Server")
global $PMSPatrol           = TrayCreateItem("PMS Server")
global $exititem       = TrayCreateItem("Exit")

Global $checked = TrayItemSetState($PrintPolice,$TRAY_UNCHECKED)
Global $checked1 = TrayItemSetState($CreditConstable,$TRAY_UNCHECKED)
Global $checked2 = TrayItemSetState($PMSPatrol,$TRAY_UNCHECKED)


While 1
    global $msg = TrayGetMsg()
        Case $msg = 0
        Case $msg = $PrintPolice
            if $checked =  1 Then
               ;SplashTextOn("", "Print Server is checked")
               $checked = 4
               Local $iPid = Run("C:\DDWIN\BACKUP\DataDeputy\Monitoring\PrintPolice.exe")
               ;SplashTextOn("", "Print Server is unchecked")
               $checked = 1
         Case $msg = $CreditConstable
            if $checked1 =  1 Then
               ;SplashTextOn("", "Credit Server is checked")
               $checked1 = 4
               Local $iPid1 = Run("C:\DDWIN\BACKUP\DataDeputy\Monitoring\CreditConstable.exe")
               ;SplashTextOn("", "Credit Server is unchecked")
               $checked1 = 1
         Case $msg = $PMSPatrol
            if $checked2 =  1 Then
               ;SplashTextOn("", "PMS Server is checked")
               $checked2 = 4
               Local $iPid2 = Run("C:\DDWIN\BACKUP\DataDeputy\Monitoring\PMSPatrol.exe")
               ;SplashTextOn("", "PMS Server is unchecked")
               $checked2 = 1
        Case $msg = $exititem

I want this to be able to exist in a program independent of the other code, and only be invoked when the user right clicks to go to the menu itself.  The only way I can think of to do this is to create a function like I mentioned earlier, but there MUST be a simpler way to do this...plus, nothing has been mentioned in the literal DOZENS of posts I've seen on how to create the menus themselves.  I feel like I'm missing something super easy here.

Link to post
Share on other sites
28 minutes ago, maloysius said:

Do you create a function that's called when you right click the icon or something?

That's almost all the purpose of a function!

You could split all the functions in other executables too, but all depends on what you are trying to do :)

Edited by FrancescoDiMuro

Click here to see my signature:




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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...