Possessed Posted November 15, 2006 Share Posted November 15, 2006 Hello there i am new to autoit and i am having some problems with getting my traymenu to uncheck and stop the action. Then when checked again start back up and be checked. i have searched again the forums and found a problem almost the same but. I i dont want 2 items on the menu like... one for turning on and one for turning off all i want is ( Check turn on. Uncheck turn off.) Here is my code thank you. expandcollapse popup#include <Inet.au3> #Include <Constants.au3> #NoTrayIcon HotKeySet("{esc}","Exitme") $PublicIP = _GetIP() Opt("TrayMenuMode",1) ; Default tray menu items (Script Paused/Exit) will not be shown. $prefsitem = TrayCreateMenu("Preferences") $showpublicIP = TrayCreateItem("Show Public IP",$prefsitem) $aboutitem = TrayCreateItem("About") TrayCreateItem("") $exititem = TrayCreateItem("Exit") TraySetState() While 1 $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $prefsitem Case $msg = $aboutitem Msgbox(64, "about:", "HandyTool Version:1.0") Case $msg = $ShowPublicIP TrayItemSetState($ShowPublicIP,$TRAY_CHECKED) SplashTextOn("","Public IP is: "& $PublicIP,200,12,1060,0,1,"Lucida Console",9) Uncheckingshowip() Case $msg = $exititem exit 0 ExitLoop EndSelect WEnd Exit Func Uncheckingshowip() If BitAND(TrayItemGetState($ShowPublicIP), $TRAY_CHECKED)Then BitAND(TrayItemGetState($ShowPublicIP), $TRAY_UNCHECKED) ;ElseIf ;BitAND(TrayItemGetState($ShowPublicIP), $TRAY_CHECKED) = $TRAY_UNCHECKED Then ;BitAND(TrayItemGetState($ShowPublicIP), $TRAY_UNCHECKED ; SplashOff() EndIf EndFunc Func Exitme() exit 0 EndFunc Link to comment Share on other sites More sharing options...
xcal Posted November 15, 2006 Share Posted November 15, 2006 (edited) Try this: expandcollapse popup#include <Inet.au3> #Include <Constants.au3> #NoTrayIcon HotKeySet("{esc}", "Exitme") $PublicIP = _GetIP() Opt("TrayMenuMode", 3) ;CHANGED $prefsitem = TrayCreateMenu("Preferences") $showpublicip = TrayCreateItem("Show Public IP", $prefsitem) $aboutitem = TrayCreateItem("About") TrayCreateItem("") $exititem = TrayCreateItem("Exit") TraySetState() While 1 $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $prefsitem Case $msg = $aboutitem MsgBox(64, "about:", "HandyTool Version:1.0") Case $msg = $showpublicip If TrayItemGetState($showpublicip) = $TRAY_UNCHECKED + $TRAY_ENABLE Then ;ADDED/CHANGED the next few lines TrayItemSetState($showpublicip, $TRAY_CHECKED) SplashTextOn("", "Public IP is: " & $PublicIP, 200, 12, 1060, 0, 1, "Lucida Console", 9) Else TrayItemSetState($showpublicip, $TRAY_UNCHECKED) SplashOff() EndIf Case $msg = $exititem Exit 0 ExitLoop EndSelect WEnd Exit ;REMOVE - this function isn't necessary... or you could put the if/else/endif in it from the while/wend i suppose Func Uncheckingshowip() If BitAND(TrayItemGetState($showpublicip), $TRAY_CHECKED) Then BitAND(TrayItemGetState($showpublicip), $TRAY_UNCHECKED) ;ElseIf ;BitAND(TrayItemGetState($ShowPublicIP), $TRAY_CHECKED) = $TRAY_UNCHECKED Then ;BitAND(TrayItemGetState($ShowPublicIP), $TRAY_UNCHECKED ; SplashOff() EndIf EndFunc Func Exitme() Exit 0 EndFunc edit - added a couple notes Edited November 15, 2006 by xcal How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Possessed Posted November 15, 2006 Author Share Posted November 15, 2006 Your the best man/girl I stayed up all night trying to fix this. I guess I this have alot to learn still Thank you so much. I never new you could put if statments in side cases dont know why I thought that but i did haha. 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