billthecreator Posted August 9, 2007 Share Posted August 9, 2007 i have a memory status gui that informs the user the memory status, DUH, but, when i have the refresh rate on high or medium i cant exit, nor do anything,. here is the scripts, see if you can help, maybe fix my problemexpandcollapse popup#region --- Memory Status Created By: Global Const $MIM_APPLYTOSUBMENUS = 0x80000000 Global Const $MIM_BACKGROUND = 0x00000002 TraySetIcon("Shell32.dll", 12) #NoTrayIcon #include <GuiConstants.au3> $open = TrayCreateItem("View Memory Status") $exit = TrayCreateItem("Exit") TraySetState() TraySetClick(16) Opt("TrayMenuMode",1) GuiCreate("Memory Status", 377, 280,@DesktopWidth-386,5,"") ;File Menu $filemenu = GUICtrlCreateMenu ("&File") $Refresh = GUICtrlCreateMenu ("&Refresh", $filemenu) $bars = GUICtrlCreateMenuItem ("Progress Bars",$Refresh) $LabelsR = GUICtrlCreateMenuItem ("Labels",$Refresh) $allR = GUICtrlCreateMenuItem ("All",$Refresh) GUICtrlCreateMenuItem ("",$filemenu) $miniM = GUICtrlCreateMenuItem ("&Minimize",$filemenu) $ExitM = GUICtrlCreateMenuItem ("&Exit",$filemenu) ;Option Menu $Option = GUICtrlCreateMenu ("&Options") $topmost = GUICtrlCreateMenuItem ("&Always On Top",$Option) GUICtrlSetState (-1,$gui_Checked) ;View Menu $View = GUICtrlCreateMenu ("&View") $Update = GUICtrlCreateMenu ("&Update Speed",$View) $UpdateHigh = GUICtrlCreateMenuItem ("High",$Update,1,1) GUICtrlSetState (-1,$GUI_CHECKED) $UpdateMed = GUICtrlCreateMenuItem ("Medium",$Update,2,1) $UpdateLow = GUICtrlCreateMenuItem ("Low",$Update,3,1) ;Gui $Group_1 = GuiCtrlCreateGroup ("Phyical Memory (MB)", 20, 80, 160, 62) $Label_2 = GuiCtrlCreateLabel ("Total", 30, 100, 70, 20) $Label_3 = GuiCtrlCreateLabel ("Available", 30, 120, 60, 20) $Input_2 = GuiCtrlCreateLabel ("", 100, 100, 40, 20,$SS_RIGHT ) $Input_3 = GuiCtrlCreateLabel ("", 100, 120, 40, 20,$SS_RIGHT ) $Progress_11 = GUICtrlCreateProgress (150,98,10,37,$PBS_VERTICAL) $Group_6 = GuiCtrlCreateGroup ("Pagefile Memory (MB)", 20, 160, 160, 62) $Label_7 = GuiCtrlCreateLabel ("Total", 30, 180, 70, 20) $Label_8 = GuiCtrlCreateLabel ("Available", 30, 200, 70, 20) $Input_4 = GuiCtrlCreateLabel ("", 100, 180, 40, 20,$SS_RIGHT ) $Input_5 = GuiCtrlCreateLabel ("", 100, 200, 40, 20,$SS_RIGHT ) $Progress_13 = GUICtrlCreateProgress (150,178,10,37,$PBS_VERTICAL) $Group_11 = GuiCtrlCreateGroup ("Memory Load", 20, 20, 340, 50) $Progress_12 = GuiCtrlCreateProgress (30, 40, 290, 20) $Label_13 = GuiCtrlCreateLabel ("100%", 320, 44, 30, 20,$SS_RIGHT ) $Group_14 = GuiCtrlCreateGroup ("Virtual Memory (MB)", 190, 80, 170, 62) $Label_15 = GuiCtrlCreateLabel ("Total", 200, 100, 70, 20) $Label_16 = GuiCtrlCreateLabel ("Available", 200, 120, 80, 20) $Group_17 = GuiCtrlCreateGroup ("Controls", 190, 160, 170, 62) $Close = GuiCtrlCreateButton ("Close", 200, 180, 70, 30) $Mini = GuiCtrlCreateButton ("Minimize", 280, 180, 70, 30) $Input_6 = GuiCtrlCreateLabel ("", 280, 100, 40, 20,$SS_RIGHT ) $Input_7 = GuiCtrlCreateLabel ("", 280, 120, 40, 20,$SS_RIGHT ) $Progress_14 = GUICtrlCreateProgress (330,98,10,37,$PBS_VERTICAL) $contextmenu = GUICtrlCreateContextMenu ($Progress_12) $refreshsmenu = GUICtrlCreateMenu ("Refresh", $contextmenu) $one = GUICtrlCreateMenuItem ("Progress Bars",$refreshsmenu) $Labels = GUICtrlCreateMenuItem ("Labels",$refreshsmenu) $all = GUICtrlCreateMenuItem ("All",$refreshsmenu) GuiSetState() SetMenuColor(0, 0xEEBB99) ; BGR color value, '0' means the tray context menu handle itself SetMenuColor($open, 0x66BB99); BGR color value While 1 $pos = MouseGetPos() $mem = MemGetStats() $msg = GuiGetMsg() $msgT = TrayGetMsg() $physicalPer = (100*(($mem[2])/$mem[1])) $pagePer = (100*(($mem[4])/$mem[3])) $virtualPer = (100*(($mem[6])/$mem[5])) $memorystatus = ("Memory Load - "&$mem[0]&"%"& @CRLF &"Available Physical - "& _ Round($mem[2]/1000,0)&" MB"& @CRLF &"Availble Pagefile - "& _ Round($mem[4]/1000,0)&" MB"& @CRLF &"Availble Virtual - "& _ Round($mem[6]/1000,0)&" MB") if $msg = $Close or $msgT = $exit or $msg = $ExitM Then Exit EndIf If $msg = $topmost Then If BitAnd(GUICtrlRead($topmost),$GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($topmost,$GUI_UNCHECKED) WinSetOnTop("Memory Status","",0) Else GUICtrlSetState($topmost,$GUI_CHECKED) WinSetOnTop("Memory Status","",1) EndIf EndIf if $msg = $Mini or $msg = $miniM Then GUISetState(@SW_HIDE) $opennow = TrayTip("Memory", $memorystatus, 1,1) EndIf if $msgT = $open Then GUISetState(@SW_SHOW) EndIf if $msg = $one or $msg = $bars Then GUICtrlSetData($Progress_12,"0%") GUICtrlSetData($Progress_11,"0%") GUICtrlSetData($Progress_13,"0%") GUICtrlSetData($Progress_14,"0%") GUICtrlSetData($Group_11,"Refreshing in [2] seconds...") sleep(2000) GUICtrlSetData($Group_11,"Memory Load") EndIf if $msg = $Labels or $msg = $LabelsR Then GUICtrlSetData($Group_6,"Pagefile Memory (MB) "&"0%") GUICtrlSetData($Group_14,"Virtual Memory (MB) "&"0%") GUICtrlSetData($Label_13,"0%") GUICtrlSetData($Input_2,"0") GUICtrlSetData($Input_3,"0") GUICtrlSetData($Input_4,"0") GUICtrlSetData($Input_5,"0") GUICtrlSetData($Input_6,"0") GUICtrlSetData($Input_7,"0") GUICtrlSetData($Group_11,"Refreshing in [2] seconds...") sleep(2000) GUICtrlSetData($Group_11,"Memory Load") EndIf if $msg = $allR or $msg = $all Then GUICtrlSetData($Group_6,"Pagefile Memory (MB) "&"0%") GUICtrlSetData($Group_14,"Virtual Memory (MB) "&"0%") GUICtrlSetData($Label_13,"0%") GUICtrlSetData($Progress_12,"0%") GUICtrlSetData($Progress_11,"0%") GUICtrlSetData($Progress_13,"0%") GUICtrlSetData($Progress_14,"0%") GUICtrlSetData($Input_2,"0") GUICtrlSetData($Input_3,"0") GUICtrlSetData($Input_4,"0") GUICtrlSetData($Input_5,"0") GUICtrlSetData($Input_6,"0") GUICtrlSetData($Input_7,"0") GUICtrlSetData($Group_11,"Refreshing in [4] seconds...") sleep(4000) GUICtrlSetData($Group_11,"Memory Load") EndIf if BitAnd(GUICtrlRead($UpdateHigh),$GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetData($Group_6,"Pagefile Memory (MB) "&Round($pagePer,1)&"%") GUICtrlSetData($Group_14,"Virtual Memory (MB) "&Round($virtualPer,1)&"%") GUICtrlSetData($Label_13,$mem[0]&"%") GUICtrlSetData($Progress_12,$mem[0]&"%") GUICtrlSetData($Progress_11,$physicalPer) GUICtrlSetData($Progress_13,$pagePer) GUICtrlSetData($Progress_14,$virtualPer) GUICtrlSetData($Input_2,Round($mem[1]/1000,0)) GUICtrlSetData($Input_3,Round($mem[2]/1000,0)) GUICtrlSetData($Input_4,Round($mem[3]/1000,0)) GUICtrlSetData($Input_5,Round($mem[4]/1000,0)) GUICtrlSetData($Input_6,Round($mem[5]/1000,0)) GUICtrlSetData($Input_7,Round($mem[6]/1000,0)) sleep(500) EndIf if BitAnd(GUICtrlRead($UpdateMed),$GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetData($Group_6,"Pagefile Memory (MB) "&Round($pagePer,1)&"%") GUICtrlSetData($Group_14,"Virtual Memory (MB) "&Round($virtualPer,1)&"%") GUICtrlSetData($Label_13,$mem[0]&"%") GUICtrlSetData($Progress_12,$mem[0]&"%") GUICtrlSetData($Progress_11,$physicalPer) GUICtrlSetData($Progress_13,$pagePer) GUICtrlSetData($Progress_14,$virtualPer) GUICtrlSetData($Input_2,Round($mem[1]/1000,0)) GUICtrlSetData($Input_3,Round($mem[2]/1000,0)) GUICtrlSetData($Input_4,Round($mem[3]/1000,0)) GUICtrlSetData($Input_5,Round($mem[4]/1000,0)) GUICtrlSetData($Input_6,Round($mem[5]/1000,0)) GUICtrlSetData($Input_7,Round($mem[6]/1000,0)) sleep(2000) EndIf TraySetToolTip($memorystatus) WEnd Func SetMenuColor($nMenuID, $nColor) ; Minimum OS are Windows98 and 2000 If @OSVersion = "WIN_95" Or @OSVersion = "WIN_NT4" Then Return $hMenu = TrayItemGetHandle($nMenuID) ; Get the internal menu handle $hBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $nColor) $hBrush = $hBrush[0] Local $stMenuInfo = DllStructCreate("dword;dword;dword;uint;dword;dword;ptr") DllStructSetData($stMenuInfo, 1, DllStructGetSize($stMenuInfo)) DllStructSetData($stMenuInfo, 2, BitOr($MIM_APPLYTOSUBMENUS, $MIM_BACKGROUND)) DllStructSetData($stMenuInfo, 5, $hBrush) DllCall("user32.dll", "int", "SetMenuInfo", "hwnd", $hMenu, "ptr", DllStructGetPtr($stMenuInfo)) EndFunc #endregion --- Memory Status [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap Link to comment Share on other sites More sharing options...
Valuater Posted August 9, 2007 Share Posted August 9, 2007 (edited) it is large sleeps that mess-up GUIGetMsg() another approach.... expandcollapse popup#region --- Memory Status Created By: Global Const $MIM_APPLYTOSUBMENUS = 0x80000000 Global Const $MIM_BACKGROUND = 0x00000002 Global $Begin = TimerInit() TraySetIcon("Shell32.dll", 12) #NoTrayIcon #include <GuiConstants.au3> $open = TrayCreateItem("View Memory Status") $exit = TrayCreateItem("Exit") TraySetState() TraySetClick(16) Opt("TrayMenuMode",1) GuiCreate("Memory Status", 377, 280,@DesktopWidth-386,5,"") ;File Menu $filemenu = GUICtrlCreateMenu ("&File") $Refresh = GUICtrlCreateMenu ("&Refresh", $filemenu) $bars = GUICtrlCreateMenuItem ("Progress Bars",$Refresh) $LabelsR = GUICtrlCreateMenuItem ("Labels",$Refresh) $allR = GUICtrlCreateMenuItem ("All",$Refresh) GUICtrlCreateMenuItem ("",$filemenu) $miniM = GUICtrlCreateMenuItem ("&Minimize",$filemenu) $ExitM = GUICtrlCreateMenuItem ("&Exit",$filemenu) ;Option Menu $Option = GUICtrlCreateMenu ("&Options") $topmost = GUICtrlCreateMenuItem ("&Always On Top",$Option) GUICtrlSetState (-1,$gui_Checked) ;View Menu $View = GUICtrlCreateMenu ("&View") $Update = GUICtrlCreateMenu ("&Update Speed",$View) $UpdateHigh = GUICtrlCreateMenuItem ("High",$Update,1,1) GUICtrlSetState (-1,$GUI_CHECKED) $UpdateMed = GUICtrlCreateMenuItem ("Medium",$Update,2,1) $UpdateLow = GUICtrlCreateMenuItem ("Low",$Update,3,1) ;Gui $Group_1 = GuiCtrlCreateGroup ("Phyical Memory (MB)", 20, 80, 160, 62) $Label_2 = GuiCtrlCreateLabel ("Total", 30, 100, 70, 20) $Label_3 = GuiCtrlCreateLabel ("Available", 30, 120, 60, 20) $Input_2 = GuiCtrlCreateLabel ("", 100, 100, 40, 20,$SS_RIGHT ) $Input_3 = GuiCtrlCreateLabel ("", 100, 120, 40, 20,$SS_RIGHT ) $Progress_11 = GUICtrlCreateProgress (150,98,10,37,$PBS_VERTICAL) $Group_6 = GuiCtrlCreateGroup ("Pagefile Memory (MB)", 20, 160, 160, 62) $Label_7 = GuiCtrlCreateLabel ("Total", 30, 180, 70, 20) $Label_8 = GuiCtrlCreateLabel ("Available", 30, 200, 70, 20) $Input_4 = GuiCtrlCreateLabel ("", 100, 180, 40, 20,$SS_RIGHT ) $Input_5 = GuiCtrlCreateLabel ("", 100, 200, 40, 20,$SS_RIGHT ) $Progress_13 = GUICtrlCreateProgress (150,178,10,37,$PBS_VERTICAL) $Group_11 = GuiCtrlCreateGroup ("Memory Load", 20, 20, 340, 50) $Progress_12 = GuiCtrlCreateProgress (30, 40, 290, 20) $Label_13 = GuiCtrlCreateLabel ("100%", 320, 44, 30, 20,$SS_RIGHT ) $Group_14 = GuiCtrlCreateGroup ("Virtual Memory (MB)", 190, 80, 170, 62) $Label_15 = GuiCtrlCreateLabel ("Total", 200, 100, 70, 20) $Label_16 = GuiCtrlCreateLabel ("Available", 200, 120, 80, 20) $Group_17 = GuiCtrlCreateGroup ("Controls", 190, 160, 170, 62) $Close = GuiCtrlCreateButton ("Close", 200, 180, 70, 30) $Mini = GuiCtrlCreateButton ("Minimize", 280, 180, 70, 30) $Input_6 = GuiCtrlCreateLabel ("", 280, 100, 40, 20,$SS_RIGHT ) $Input_7 = GuiCtrlCreateLabel ("", 280, 120, 40, 20,$SS_RIGHT ) $Progress_14 = GUICtrlCreateProgress (330,98,10,37,$PBS_VERTICAL) $contextmenu = GUICtrlCreateContextMenu ($Progress_12) $refreshsmenu = GUICtrlCreateMenu ("Refresh", $contextmenu) $one = GUICtrlCreateMenuItem ("Progress Bars",$refreshsmenu) $Labels = GUICtrlCreateMenuItem ("Labels",$refreshsmenu) $all = GUICtrlCreateMenuItem ("All",$refreshsmenu) GuiSetState() SetMenuColor(0, 0xEEBB99) ; BGR color value, '0' means the tray context menu handle itself SetMenuColor($open, 0x66BB99); BGR color value While 1 $pos = MouseGetPos() $mem = MemGetStats() $msg = GuiGetMsg() $msgT = TrayGetMsg() $physicalPer = (100*(($mem[2])/$mem[1])) $pagePer = (100*(($mem[4])/$mem[3])) $virtualPer = (100*(($mem[6])/$mem[5])) $memorystatus = ("Memory Load - "&$mem[0]&"%"& @CRLF &"Available Physical - "& _ Round($mem[2]/1000,0)&" MB"& @CRLF &"Availble Pagefile - "& _ Round($mem[4]/1000,0)&" MB"& @CRLF &"Availble Virtual - "& _ Round($mem[6]/1000,0)&" MB") if $msg = $Close or $msgT = $exit or $msg = $ExitM Then Exit EndIf If $msg = $topmost Then If BitAnd(GUICtrlRead($topmost),$GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($topmost,$GUI_UNCHECKED) WinSetOnTop("Memory Status","",0) Else GUICtrlSetState($topmost,$GUI_CHECKED) WinSetOnTop("Memory Status","",1) EndIf EndIf if $msg = $Mini or $msg = $miniM Then GUISetState(@SW_HIDE) $opennow = TrayTip("Memory", $memorystatus, 1,1) EndIf if $msgT = $open Then GUISetState(@SW_SHOW) EndIf if $msg = $one or $msg = $bars Then GUICtrlSetData($Progress_12,"0%") GUICtrlSetData($Progress_11,"0%") GUICtrlSetData($Progress_13,"0%") GUICtrlSetData($Progress_14,"0%") GUICtrlSetData($Group_11,"Refreshing in [2] seconds...") sleep(2000) GUICtrlSetData($Group_11,"Memory Load") EndIf if $msg = $Labels or $msg = $LabelsR Then GUICtrlSetData($Group_6,"Pagefile Memory (MB) "&"0%") GUICtrlSetData($Group_14,"Virtual Memory (MB) "&"0%") GUICtrlSetData($Label_13,"0%") GUICtrlSetData($Input_2,"0") GUICtrlSetData($Input_3,"0") GUICtrlSetData($Input_4,"0") GUICtrlSetData($Input_5,"0") GUICtrlSetData($Input_6,"0") GUICtrlSetData($Input_7,"0") GUICtrlSetData($Group_11,"Refreshing in [2] seconds...") sleep(2000) GUICtrlSetData($Group_11,"Memory Load") EndIf if $msg = $allR or $msg = $all Then GUICtrlSetData($Group_6,"Pagefile Memory (MB) "&"0%") GUICtrlSetData($Group_14,"Virtual Memory (MB) "&"0%") GUICtrlSetData($Label_13,"0%") GUICtrlSetData($Progress_12,"0%") GUICtrlSetData($Progress_11,"0%") GUICtrlSetData($Progress_13,"0%") GUICtrlSetData($Progress_14,"0%") GUICtrlSetData($Input_2,"0") GUICtrlSetData($Input_3,"0") GUICtrlSetData($Input_4,"0") GUICtrlSetData($Input_5,"0") GUICtrlSetData($Input_6,"0") GUICtrlSetData($Input_7,"0") GUICtrlSetData($Group_11,"Refreshing in [4] seconds...") sleep(4000) GUICtrlSetData($Group_11,"Memory Load") EndIf $Dif = TimerDiff($Begin) if BitAnd(GUICtrlRead($UpdateHigh),$GUI_CHECKED) = $GUI_CHECKED Then If $Dif > 500 Then UpDater() EndIf if BitAnd(GUICtrlRead($UpdateMed),$GUI_CHECKED) = $GUI_CHECKED Then If $Dif > 2000 Then UpDater() EndIf if BitAnd(GUICtrlRead($UpdateMed),$GUI_CHECKED) = $GUI_CHECKED Then If $Dif > 10000 Then UpDater() EndIf TraySetToolTip($memorystatus) WEnd Func UpDater() GUICtrlSetData($Group_6,"Pagefile Memory (MB) "&Round($pagePer,1)&"%") GUICtrlSetData($Group_14,"Virtual Memory (MB) "&Round($virtualPer,1)&"%") GUICtrlSetData($Label_13,$mem[0]&"%") GUICtrlSetData($Progress_12,$mem[0]&"%") GUICtrlSetData($Progress_11,$physicalPer) GUICtrlSetData($Progress_13,$pagePer) GUICtrlSetData($Progress_14,$virtualPer) GUICtrlSetData($Input_2,Round($mem[1]/1000,0)) GUICtrlSetData($Input_3,Round($mem[2]/1000,0)) GUICtrlSetData($Input_4,Round($mem[3]/1000,0)) GUICtrlSetData($Input_5,Round($mem[4]/1000,0)) GUICtrlSetData($Input_6,Round($mem[5]/1000,0)) GUICtrlSetData($Input_7,Round($mem[6]/1000,0)) $Begin = TimerInit() EndFunc Func SetMenuColor($nMenuID, $nColor) ; Minimum OS are Windows98 and 2000 If @OSVersion = "WIN_95" Or @OSVersion = "WIN_NT4" Then Return $hMenu = TrayItemGetHandle($nMenuID) ; Get the internal menu handle $hBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $nColor) $hBrush = $hBrush[0] Local $stMenuInfo = DllStructCreate("dword;dword;dword;uint;dword;dword;ptr") DllStructSetData($stMenuInfo, 1, DllStructGetSize($stMenuInfo)) DllStructSetData($stMenuInfo, 2, BitOr($MIM_APPLYTOSUBMENUS, $MIM_BACKGROUND)) DllStructSetData($stMenuInfo, 5, $hBrush) DllCall("user32.dll", "int", "SetMenuInfo", "hwnd", $hMenu, "ptr", DllStructGetPtr($stMenuInfo)) EndFunc #endregion --- Memory Status there are other sleeps you may wish to re-consider...??? 8) Edited August 9, 2007 by Valuater 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