FinalVersion Posted February 18, 2010 Posted February 18, 2010 expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <SendMessage.au3> #include <Date.au3> Global Const $SC_DRAGMOVE = 0xF012 Local $iHours, $iMins, $iSecs $frmMain = GUICreate("System :: Uptime", 290, 58, 192, 124, BitOR($WS_POPUP,$WS_BORDER), $WS_EX_TOPMOST) GUISetBkColor(0x000000) $lblDays = GUICtrlCreateLabel("00", 8, 8, 40, 41) GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) $lblHours = GUICtrlCreateLabel("00", 64, 8, 40, 41) GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) $lblMinutes = GUICtrlCreateLabel("00", 120, 8, 40, 41) GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) $lblSeconds = GUICtrlCreateLabel("00", 176, 8, 40, 41) GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) $lblSep1 = GUICtrlCreateLabel(":", 48, 8, 13, 41) GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) $lblSep2 = GUICtrlCreateLabel(":", 104, 8, 13, 41) GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) $lblSep3 = GUICtrlCreateLabel(":", 160, 8, 13, 41) GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) $btnHide = GUICtrlCreateButton("Hide", 224, 10, 51, 33, BitOR($BS_FLAT,$WS_GROUP)) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_PRIMARYDOWN _SendMessage($frmMain, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) Case $GUI_EVENT_CLOSE Exit EndSwitch $GTC = DllCall("kernel32.dll", "long", "GetTickCount") $TSB = $GTC[0] _TicksToTime($TSB, $iHours, $iMins, $iSecs) $iDays = Int($iHours / 24) $iHours = $iHours - ($iDays * 24) GUICtrlSetData($lblDays, $iDays) GUICtrlSetData($lblHours, $iHours) GUICtrlSetData($lblMinutes, $iMins) GUICtrlSetData($lblSeconds, $iSecs) WEnd It only flickers for a couple of seconds when I start it, but it's annoying. And now I've broken the Hide function, I'm thinking when you hit the hide button, it stops updating the labels and hides, but when you unhide it, it continues updating. [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center]
Moderators Melba23 Posted February 18, 2010 Moderators Posted February 18, 2010 FinalVersion,1. To stop the flickering, only update the labels when needed - you need variables to track the current values and then wait for changes, as shown below. I also added some formatting to give 2-digit values at all times. 2. You were not looking for the "Hide" button in your GUIGetMsg loop - hardly surprising that it was not working! By the way, the Case $GUI_EVENT_CLOSE is unnecessary as you have no way of sending the message from a $WS_POPUP window - there is no [X].expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <SendMessage.au3> #include <Date.au3> Global Const $SC_DRAGMOVE = 0xF012 Local $iHours, $iMins, $iSecs $frmMain = GUICreate("System :: Uptime", 290, 58, 192, 124, BitOR($WS_POPUP,$WS_BORDER), $WS_EX_TOPMOST) GUISetBkColor(0x000000) $lblDays = GUICtrlCreateLabel("00", 8, 8, 40, 41) GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) $lblHours = GUICtrlCreateLabel("00", 64, 8, 40, 41) GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) $lblMinutes = GUICtrlCreateLabel("00", 120, 8, 40, 41) GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) $lblSeconds = GUICtrlCreateLabel("00", 176, 8, 40, 41) GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) $lblSep1 = GUICtrlCreateLabel(":", 48, 8, 13, 41) GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) $lblSep2 = GUICtrlCreateLabel(":", 104, 8, 13, 41) GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) $lblSep3 = GUICtrlCreateLabel(":", 160, 8, 13, 41) GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) $btnHide = GUICtrlCreateButton("Hide", 224, 10, 51, 33, $BS_FLAT) GUISetState(@SW_SHOW) $iCurrSecs = 0 $iCurrMins = 0 $iCurrHrs = 0 $iCurrDays = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_PRIMARYDOWN _SendMessage($frmMain, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) Case $GUI_EVENT_CLOSE Exit Case $btnHide GUISetState(@SW_HIDE) EndSwitch $GTC = DllCall("kernel32.dll", "long", "GetTickCount") $TSB = $GTC[0] _TicksToTime($TSB, $iHours, $iMins, $iSecs) $iDays = Int($iHours / 24) $iHours = $iHours - ($iDays * 24) If $iSecs <> $iCurrSecs Then If $iDays <> $iCurrDays Then GUICtrlSetData($lblDays, StringFormat("%02i", $iDays)) $iCurrDays = $iDays EndIf If $iCurrHrs <> $iHours Then GUICtrlSetData($lblHours, StringFormat("%02i", $iHours)) $iCurrHrs = $iHours EndIf If $iCurrMins <> $iMins Then GUICtrlSetData($lblMinutes, StringFormat("%02i", $iMins)) $iCurrMins = $iMins EndIf GUICtrlSetData($lblSeconds, StringFormat("%02i", $iSecs)) $iCurrSecs = $iSecs EndIf WEndM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
FinalVersion Posted February 18, 2010 Author Posted February 18, 2010 Thanks, oh and you just proved how last I'm with "2"; [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center]
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