maloysius Posted August 16, 2019 Share Posted August 16, 2019 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 comment Share on other sites More sharing options...
maloysius Posted August 16, 2019 Author Share Posted August 16, 2019 In case anyone needs to see it, here is the code for the tray icon menu: expandcollapse popup#NoTrayIcon #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant. #Include <Constants.au3> #NoTrayIcon Opt("TrayMenuMode",1) global $PrintPolice = TrayCreateItem("Print Server") global $CreditConstable = TrayCreateItem("Credit Server") global $PMSPatrol = TrayCreateItem("PMS Server") TrayCreateItem("") global $exititem = TrayCreateItem("Exit") Global $checked = TrayItemSetState($PrintPolice,$TRAY_UNCHECKED) Global $checked1 = TrayItemSetState($CreditConstable,$TRAY_UNCHECKED) Global $checked2 = TrayItemSetState($PMSPatrol,$TRAY_UNCHECKED) TraySetState() While 1 global $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $PrintPolice if $checked = 1 Then ;SplashTextOn("", "Print Server is checked") TrayItemSetState($PrintPolice,$TRAY_CHECKED) $checked = 4 Local $iPid = Run("C:\DDWIN\BACKUP\DataDeputy\Monitoring\PrintPolice.exe") Else ;SplashTextOn("", "Print Server is unchecked") TrayItemSetState($PrintPolice,$TRAY_UNCHECKED) $checked = 1 ProcessClose($iPid) EndIf Case $msg = $CreditConstable if $checked1 = 1 Then ;SplashTextOn("", "Credit Server is checked") TrayItemSetState($CreditConstable,$TRAY_CHECKED) $checked1 = 4 Local $iPid1 = Run("C:\DDWIN\BACKUP\DataDeputy\Monitoring\CreditConstable.exe") Else ;SplashTextOn("", "Credit Server is unchecked") TrayItemSetState($CreditConstable,$TRAY_UNCHECKED) $checked1 = 1 ProcessClose($iPid1) EndIf Case $msg = $PMSPatrol if $checked2 = 1 Then ;SplashTextOn("", "PMS Server is checked") TrayItemSetState($PMSPatrol,$TRAY_CHECKED) $checked2 = 4 Local $iPid2 = Run("C:\DDWIN\BACKUP\DataDeputy\Monitoring\PMSPatrol.exe") Else ;SplashTextOn("", "PMS Server is unchecked") TrayItemSetState($PMSPatrol,$TRAY_UNCHECKED) $checked2 = 1 ProcessClose($iPid2) EndIf Case $msg = $exititem ProcessClose("PrintPolice.exe") ProcessClose("CreditConstable.exe") ProcessClose("PMSPatrol.exe") Exit EndSelect WEnd 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 comment Share on other sites More sharing options...
FrancescoDiMuro Posted August 16, 2019 Share Posted August 16, 2019 (edited) 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 August 16, 2019 by FrancescoDiMuro maloysius 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette 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