busysignal Posted March 19, 2006 Posted March 19, 2006 I am trying to write a Tray Menu script but I am running into a program that I cannot see. It seems that the $msg value is not getting a value other than zero. Can anyone shed some light on what I am missing. I am sure it is really simple.. See code below.. expandcollapse popup#include <Constants.au3> #NoTrayIcon ; << AutoIt Options >> ; Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 1) Opt("TrayIconHide", 0) ;Opt("TrayAutoPause", 0) ; << Hotkey Definitions >> ; HotKeySet("^!x", "_Exit") HotKeySet("^!h", "_Help") $Settings_tray = TrayCreateMenu("Settings") $HDDitem = TrayCreateItem("HDD Info", $Settings_tray) $Current_tray = TrayCreateItem("Current HotKeys (Ctrl+Alt+H)") TrayItemSetOnEvent($Current_tray, "_Help") $exit_tray = TrayCreateItem("Exit (Ctrl+Alt+X)") TrayItemSetOnEvent($exit_tray, "_Exit") TraySetState() While 1 Sleep(100) $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $HDDitem _HDDInfo() Case Else ;;; EndSelect WEnd Exit ;=================================================================================================== =================== ; Function Area ;=================================================================================================== =================== Func _HDDInfo(); Display HDDInfo Local $hdSizeC, $hdFreeSizeC, $hdSizeD, $hdFreeSizeD $hdSizeC = DriveSpaceTotal( "c:\") $hdFreeSizeC = DriveSpaceFree( "c:\") $hdSizeD = DriveSpaceTotal( "d:\") $hdFreeSizeD = DriveSpaceFree( "d:\") MsgBox(0, "HDD Info", _ "Hostname : " & @ComputerName & @CRLF _ & "Domain : " & @LogonDomain & @CRLF _ & "LogonServer : " & @LogonServer & @CRLF _ & "OS Type : " & @OSTYPE & @CRLF _ & "Version : " & @OSVersion & @CRLF _ & "ServicePack : " & @OSServicePack & @CRLF _ & "Drive C size : " & Round($hdSizeC) & " MB" & @CRLF _ & "Drive C free : " & Round($hdFreeSizeC) & " MB" & @CRLF _ & "Drive D size : " & Round($hdSizeD) & " MB" & @CRLF _ & "Drive D free : " & Round($hdFreeSizeD) & " MB" & @CRLF _ & "ScriptStarting User : " & @UserName) EndFunc ;==>_HDDInfo Func _Help();printing out the current set HotKeys Local $HKeys = "Ctrl+Alt+X for Exit" & @CRLF & _ "Ctrl+Alt+H for Help" MsgBox(64, "-= HELP =-", "Hotkey List:" & @CRLF & $HKeys) EndFunc ;==>_Help Func _Exit();Exit Script Exit EndFunc ;==>_Exit Any help would be greatly appreciated.. Cheers..
Moderators SmOke_N Posted March 19, 2006 Moderators Posted March 19, 2006 You can't use Opt("TrayOnEventMode", 1) with TrayGetMsg() too. One or the other.... You could just use the TrayOnEventMode() and set TrayItemSetOnEvent($HDDitem, "_HDDInfo") for $HDDitem = TrayCreateItem("HDD Info", $Settings_tray). 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.
cppman Posted March 19, 2006 Posted March 19, 2006 Here ya go: expandcollapse popup#include <Constants.au3> #NoTrayIcon ; << AutoIt Options >> ; Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 1) Opt("TrayIconHide", 0) ;Opt("TrayAutoPause", 0) ; << Hotkey Definitions >> ; HotKeySet("^!x", "_Exit") HotKeySet("^!h", "_Help") $Settings_tray = TrayCreateMenu("Settings") $HDDitem = TrayCreateItem("HDD Info", $Settings_tray) TrayItemSetOnEvent($HDDitem, "_HDDInfo") $Current_tray = TrayCreateItem("Current HotKeys (Ctrl+Alt+H)") TrayItemSetOnEvent($Current_tray, "_Help") $exit_tray = TrayCreateItem("Exit (Ctrl+Alt+X)") TrayItemSetOnEvent($exit_tray, "_Exit") TraySetState() While 1 WEnd Exit ;=================================================================================================== =================== ; Function Area ;=================================================================================================== =================== Func _HDDInfo(); Display HDDInfo Local $hdSizeC, $hdFreeSizeC, $hdSizeD, $hdFreeSizeD $hdSizeC = DriveSpaceTotal( "c:\") $hdFreeSizeC = DriveSpaceFree( "c:\") $hdSizeD = DriveSpaceTotal( "d:\") $hdFreeSizeD = DriveSpaceFree( "d:\") MsgBox(0, "HDD Info", _ "Hostname : " & @ComputerName & @CRLF _ & "Domain : " & @LogonDomain & @CRLF _ & "LogonServer : " & @LogonServer & @CRLF _ & "OS Type : " & @OSTYPE & @CRLF _ & "Version : " & @OSVersion & @CRLF _ & "ServicePack : " & @OSServicePack & @CRLF _ & "Drive C size : " & Round($hdSizeC) & " MB" & @CRLF _ & "Drive C free : " & Round($hdFreeSizeC) & " MB" & @CRLF _ & "Drive D size : " & Round($hdSizeD) & " MB" & @CRLF _ & "Drive D free : " & Round($hdFreeSizeD) & " MB" & @CRLF _ & "ScriptStarting User : " & @UserName) EndFunc ;==>_HDDInfo Func _Help();printing out the current set HotKeys Local $HKeys = "Ctrl+Alt+X for Exit" & @CRLF & _ "Ctrl+Alt+H for Help" MsgBox(64, "-= HELP =-", "Hotkey List:" & @CRLF & $HKeys) EndFunc ;==>_Help Func _Exit();Exit Script Exit EndFunc ;==>_Exit U had it set on TrayEventMode and were trying to get the message by doing msg=TrayGetMsg()... should work now. Miva OS Project
busysignal Posted March 19, 2006 Author Posted March 19, 2006 @ SmOke_N & CHRIS95219, thanks for your reply. Now I understand what the OPT is trying to do. It was not clear when I was reading the AutoIt Help description that there would be a conflict between the two approaches. Cheers..
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