zxcvbnm Posted March 21, 2011 Share Posted March 21, 2011 Hi, I created a timer, locate on the upper right of the monitor. A user can move it, but moving it is hidden under the frame of the monitor and almost disappears. It's possible to force the application to reamin fully visible on the monitor? Here the code: expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=..\on.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <Timers.au3> ; Set a HotKey to exit ;HotKeySet("{ESC}", "On_Exit") Global $iMin = 5, $iSec = 3, $iFlash = 0, $neg = 0 Global Const $DW = @DesktopWidth Global Const $DH = @DesktopHeight $Form1 = GUICreate("Count Down", 250, 70, $DW-280, 125, BitOR($WS_DLGFRAME, $WS_POPUP), $WS_EX_TOPMOST) GUISetBkColor(0x66FF00) $Label = GUICtrlCreateLabel(StringFormat("%02d:%02d", $iMin, $iSec), 24, 02, 200, 70, -1, $GUI_WS_EX_PARENTDRAG) ;$Label = GUICtrlCreateLabel("", 24, 02, 200, 70, -1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetFont(-1, 40, 800, 0, "verdana") ; At the top of your script add this line ;OnAutoItExitRegister("_Kill_Timers") GUISetState(@SW_SHOW) ;GUISetOnEvent($GUI_EVENT_CLOSE, "On_Exit") ; Set up the intercept of the WM_CLOSE message GUIRegisterMsg($WM_CLOSE, "WM_CLOSE") AutoItSetOption ( "TrayIconHide" ,1 ) ; Start a timer for the countdown $iTimerProgress = _Timer_SetTimer($Form1, 1000, "_CountDown") ; Call once a sec ; Set a placeholder for the Flash timer $iFlash_Timer = 9999 ; Loop until you get to the correct value Do Sleep(10) Until $iMin = (-59) And $iSec = 59 ; Kill the Progress Timer _Timer_KillTimer($Form1, $iTimerProgress) ; Keep the scipt alive While 1 Sleep(10) Wend ; And then add this function somewhere in the script ;Func _Kill_Timers() ; _Timer_KillAllTimers($Form1) ;EndFunc ; When you exit, kill the Flash timer ;Func On_Exit() ; _Timer_KillAllTimers($Form1) ; MsgBox(0, "Success", "On closure intercepted the 'Close'") ; Exit ;EndFunc ; this runs when the message is intercepted Func WM_CLOSE() _Timer_KillAllTimers($Form1) ;MsgBox(0, "Success", "The handler has intercepted the 'Close' call from the other script") Exit EndFunc Func _CountDown($a, $b, $c, $d) ; You must have 4 parameters here, even though they do nothing! ; We call it once a sec, so just reduce by 1 sec each time If $iMin > 0 Then $iSec -= 1 If $iSec < 0 Then $iSec = 59 $iMin -= 1 EndIf GUICtrlSetData($Label, StringFormat("%02d:%02d", $iMin, $iSec)) ElseIf $iMin = 0 And $neg = 0 Then $iSec -= 1 If $iSec = 0 Then $neg = 1 EndIf GUICtrlSetData($Label, StringFormat("%02d:%02d", $iMin, $iSec)) ElseIf $iMin = 0 And $neg = 1 Then $iSec += 1 GUICtrlSetData($Label, StringFormat("-" & "%02d:%02d", $iMin, $iSec)) If $iSec > 59 Then $iSec = 0 $iMin -= 1 GUICtrlSetData($Label, StringFormat("%03d:%02d", $iMin, $iSec)) EndIf ElseIf $iMin < 0 And $neg = 1 Then $iSec += 1 If $iSec > 59 Then $iSec = 0 $iMin -= 1 EndIf GUICtrlSetData($Label, StringFormat("%03d:%02d", $iMin, $iSec)) EndIf If $iMin = 2 And $iSec = 30 Then GUISetBkColor(0xFFFF00) EndIf If $iMin = 1 And $iSec = 0 Then GUISetBkColor(0xFF0000) EndIf If $iMin = 0 And $iSec = 0 Then $iFlash_Timer = _Timer_SetTimer($Form1, 500, "_Flash") ; Start a second timer to flash EndIf EndFunc ;==>_CountDown Func _Flash($a, $b, $c, $d) ; You must have 4 parameters here, even though they do nothing! $iFlash = Not $iFlash If $iFlash Then GUICtrlSetColor($Label, 0xFF0000) Return EndIf GUICtrlSetColor($Label, 0x000000) EndFunc ;==>_Flash Thanks Z Link to comment Share on other sites More sharing options...
Andreik Posted March 21, 2011 Share Posted March 21, 2011 Register WM_MOVE message and call a function like that: GUIRegisterMsg($WM_MOVE,"WM_MOVE") Func WM_MOVE($hWnd, $Msg, $wParam, $lParam) $POS = WinGetPos($hWnd) If $POS[0] < 0 Then $POS[0] = 0 If $POS[0]+$POS[2] > @DesktopWidth Then $POS[0] = @DesktopWidth - $POS[2] If $POS[1] < 0 Then $POS[1] = 0 If $POS[1]+$POS[3] > @DesktopHeight Then $POS[1] = @DesktopHeight - $POS[3] WinMove($hWnd,"",$POS[0],$POS[1]) EndFunc When the words fail... music speaks. 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