jfcby Posted July 28, 2010 Share Posted July 28, 2010 (edited) When I click yes it displays the correct message box but when I click no it displays the yes message box instead of the no message box. How can I get the no to display the correct message box? expandcollapse popup#include <IE.au3> #include <Constants.au3> #NoTrayIcon Opt("TrayMenuMode",1) HotKeySet("{ESC}", "_Exit") Global $itmYes, $itmNo, $citmY, $citmN $Test1 = TrayCreateMenu("Test1") $itmYes = TrayCreateItem("Yes", $Test1) $itmNo = TrayCreateItem("No", $Test1) TrayCreateItem("") $itmExit = TrayCreateItem("Exit") TraySetState() While 1 $tMsg = TrayGetMsg() Switch $tMsg Case 0 ContinueLoop Case $itmYes, $itmNo _TrayCheck1() Case $itmExit _Exit() EndSwitch WEnd Func _TrayCheck1() $citmY = TrayItemGetText($itmYes) $citmN = TrayItemGetText($itmNo) If $citmY = "Yes" Then MsgBox(0, "Debug:", "$citmY: Create Desktop Shortcut = " & $citmY) ElseIf $citmN = "No" Then MsgBox(0, "Debug:", "$citmN: Create Desktop Shortcut = " & $citmN) EndIf EndFunc ;==>_TrayCheck1 Func _Exit() GUIDelete() Exit EndFunc ;_Exit Thank you for your help, jfcby Edited July 29, 2010 by jfcby Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB **** Link to comment Share on other sites More sharing options...
jaberwacky Posted July 28, 2010 Share Posted July 28, 2010 (edited) expandcollapse popup#include <IE.au3> #include <Constants.au3> #NoTrayIcon Opt("TrayMenuMode", 1) HotKeySet("{ESC}", "_Exit") Global $citmY, $citmN Global $Test1 = TrayCreateMenu("Test1") Global $itmYes = TrayCreateItem("Yes", $Test1) Global $itmNo = TrayCreateItem("No", $Test1) TrayCreateItem("") Global $itmExit = TrayCreateItem("Exit") TraySetState() Global $tMsg While 1 $tMsg = TrayGetMsg() Switch $tMsg Case $itmYes, $itmNo _TrayCheck1($tMsg) Case $itmExit _Exit() EndSwitch WEnd Func _Exit() GUIDelete() Exit EndFunc ;==>_Exit Func _TrayCheck1(Const $item) Switch TrayItemGetText($item) Case "Yes" $citmY = "Yes" MsgBox(0, "Debug:", "$citmY: Create Desktop Shortcut = " & $citmY) Case "No" $citmN = "No" MsgBox(0, "Debug:", "$citmN: Create Desktop Shortcut = " & $citmN) EndSwitch EndFunc ;==>_TrayCheck1 Edited July 29, 2010 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Torx Posted July 28, 2010 Share Posted July 28, 2010 Your first "if" comparison is always true and thus the "else" gets ignored all the time. Quick and dirty fix is to pass the tMsg to the function: expandcollapse popup#include <IE.au3> #include <Constants.au3> #NoTrayIcon Opt("TrayMenuMode",1) HotKeySet("{ESC}", "_Exit") Global $itmYes, $itmNo, $citmY, $citmN $Test1 = TrayCreateMenu("Test1") $itmYes = TrayCreateItem("Yes", $Test1) $itmNo = TrayCreateItem("No", $Test1) TrayCreateItem("") $itmExit = TrayCreateItem("Exit") TraySetState() While 1 $tMsg = TrayGetMsg() Switch $tMsg Case 0 ContinueLoop Case $itmYes, $itmNo _TrayCheck1($tMsg) Case $itmExit _Exit() EndSwitch WEnd Func _TrayCheck1($tMsg) If $tMsg = $itmYes Then MsgBox(0, "Debug:", "$citmY: Create Desktop Shortcut = Yes") ElseIf $tMsg = $itmNo Then MsgBox(0, "Debug:", "$citmN: Create Desktop Shortcut = No") EndIf EndFunc ;==>_TrayCheck1 Func _Exit() GUIDelete() Exit EndFunc ;_Exit However, I would prefer to make use of the already existing Switch-Case: expandcollapse popup#include <IE.au3> #include <Constants.au3> #NoTrayIcon Opt("TrayMenuMode",1) HotKeySet("{ESC}", "_Exit") Global $itmYes, $itmNo, $citmY, $citmN $Test1 = TrayCreateMenu("Test1") $itmYes = TrayCreateItem("Yes", $Test1) $itmNo = TrayCreateItem("No", $Test1) TrayCreateItem("") $itmExit = TrayCreateItem("Exit") TraySetState() While 1 $tMsg = TrayGetMsg() Switch $tMsg Case 0 ContinueLoop Case $itmYes _TrayCheck1Yes() Case $itmNo _TrayCheck1No() Case $itmExit _Exit() EndSwitch WEnd Func _TrayCheck1Yes() MsgBox(0, "Debug:", "Create Desktop Shortcut = Yes") EndFunc Func _TrayCheck1No() MsgBox(0, "Debug:", "Create Desktop Shortcut = No") EndFunc Func _Exit() GUIDelete() Exit EndFunc Or another way to do it: expandcollapse popup#include <IE.au3> #include <Constants.au3> #NoTrayIcon Opt("TrayMenuMode",1) HotKeySet("{ESC}", "_Exit") Global $itmYes, $itmNo, $citmY, $citmN $Test1 = TrayCreateMenu("Test1") $itmYes = TrayCreateItem("Yes", $Test1) $itmNo = TrayCreateItem("No", $Test1) TrayCreateItem("") $itmExit = TrayCreateItem("Exit") TraySetState() While 1 $tMsg = TrayGetMsg() Switch $tMsg Case 0 ContinueLoop Case $itmYes _TrayCheck1("Yes") Case $itmNo _TrayCheck1("No") Case $itmExit _Exit() EndSwitch WEnd Func _TrayCheck1($param) MsgBox(0, "Debug:", "Create Desktop Shortcut = " & $param) EndFunc Func _Exit() GUIDelete() Exit EndFunc Ping Utility Link to comment Share on other sites More sharing options...
jaberwacky Posted July 29, 2010 Share Posted July 29, 2010 (edited) Quick and dirty fix is to pass the tMsg to the function:How is my example quick and dirty so that I may accept reproof. Edited July 29, 2010 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
jfcby Posted July 29, 2010 Author Share Posted July 29, 2010 jaberwocky6669 and Torx thank you for your help. The examples each of you provided were excatly what I was looking for and solved my problem. jfcby Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB **** Link to comment Share on other sites More sharing options...
Torx Posted July 30, 2010 Share Posted July 30, 2010 @jaberwocky6669 I was not referring to your post, your solution is good. Ping Utility 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