Jump to content

Put GUI to sleep


Recommended Posts

Sorry YOUR ORIGINAL SCRIPT DIDNT WORK.

PROBLEM SOLVED:

While 1

$CurrentTime = _NowTime(4)

Switch @WDAY

Case 1,2,3,4,5,6,7

;MsgBox(0,"CURRENT TIME",$CurrentTime,30)

;MsgBox(0,"START - END TIME",$StartTime&" "&$EndTime,30)

If Not BitOR($CurrentTime >= $StartTime AND $CurrentTime <= $EndTime, $CurrentTime >= $StartTime AND $CurrentTime <= $EndTime) Then

MSGBOX(0,"BOT IS SLEEPING","NEXT START: "&$StartTime,30)

GUISetState(@SW_HIDE)

EndIf

If BitOR($CurrentTime >= $StartTime AND $CurrentTime <= $EndTime, $CurrentTime >= $StartTime AND $CurrentTime <= $EndTime) Then

MSGBOX(0,"BOT IS RUNNING","NEXT SLEEP: "&$EndTime,30)

GUISetState(@SW_SHOW)

EndIf

Sleep(100)

EndSwitch

WEnd

Works PERFECT is a better solution

Link to comment
Share on other sites

#include <Date.au3>
#include <WinAPI.au3>
Local $Starttime = "14:40:30" ; IniRead("settings.ini", "SectionstartTime", "Starttime", "Start Time Note Set")
Local $Endtime = "14:41:00" ; IniRead("settings.ini", "SectionendTime", "Endtime", "End Time Note Set")
$maxseconds = _DateDiff('s', @YEAR & "/" & @MON & "/" & @MDAY & " " & $Starttime, @YEAR & "/" & @MON & "/" & @MDAY & " " & $Endtime)
ConsoleWrite($maxseconds & @CRLF)
$gui = GUICreate("")
GUISetState(@SW_SHOW)

While 1
 $cur = _DateDiff('s', @YEAR & "/" & @MON & "/" & @MDAY & " " & $Starttime, @YEAR & "/" & @MON & "/" & @MDAY & " " & _NowTime(5))
 If $cur >=0 and $cur < $maxseconds Then ; if in the range
  If Not BitAND(WinGetState($gui), 2) Then
   GUISetState(@SW_SHOW)
   WinSetOnTop($gui,"",1)
   MsgBox(0, "Running", "From " & $Starttime & " to: " & $Endtime,5)
  EndIf
  _WinAPI_FlashWindow($gui)
  Sleep (500)
 Else
  If BitAND(WinGetState($gui), 2) Then
   WinSetOnTop($gui,"",0)
   GUISetState(@SW_HIDE)
   MsgBox(0, "Pause", "HIDE, outsid of range " & $Starttime & " to: " & $Endtime,5)
  EndIf
 EndIf
 Sleep(100)
WEnd

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

jdelaney

I thought it was possible to avoid the use of _DateDiff and _NowTime by using a simple number comparison, and to replace the WinGetState visibility check by a boolean switch

this was what created the trouble ?

Link to comment
Share on other sites

#include <Date.au3>
#include <WinAPI.au3>
Local $Starttime = "14:40:30" ; IniRead("settings.ini", "SectionstartTime", "Starttime", "Start Time Note Set")
Local $Endtime = "14:41:00" ; IniRead("settings.ini", "SectionendTime", "Endtime", "End Time Note Set")
$maxseconds = _DateDiff('s', @YEAR & "/" & @MON & "/" & @MDAY & " " & $Starttime, @YEAR & "/" & @MON & "/" & @MDAY & " " & $Endtime)
ConsoleWrite($maxseconds & @CRLF)
$gui = GUICreate("")
GUISetState(@SW_SHOW)

While 1
$cur = _DateDiff('s', @YEAR & "/" & @MON & "/" & @MDAY & " " & $Starttime, @YEAR & "/" & @MON & "/" & @MDAY & " " & _NowTime(5))
If $cur >=0 and $cur < $maxseconds Then ; if in the range
If Not BitAND(WinGetState($gui), 2) Then
GUISetState(@SW_SHOW)
WinSetOnTop($gui,"",1)
MsgBox(0, "Running", "From " & $Starttime & " to: " & $Endtime,5)
EndIf
_WinAPI_FlashWindow($gui)
Sleep (500)
Else
If BitAND(WinGetState($gui), 2) Then
WinSetOnTop($gui,"",0)
GUISetState(@SW_HIDE)
MsgBox(0, "Pause", "HIDE, outsid of range " & $Starttime & " to: " & $Endtime,5)
EndIf
EndIf
Sleep(100)
WEnd

I understand your code but besides being longer whats the difference? Why $MaxSecond as _Datediff ??? You also use Notime !? :ermm: Edited by R4z0r
Link to comment
Share on other sites

The difference is in the way he does the comparison : If $cur >=0 and $cur < $maxseconds

$cur = DateDiff between "now" and $starttime (number of seconds between both)

$maxseconds = DateDiff between $starttime and $endtime (number of seconds in the range)

Link to comment
Share on other sites

Thank you very much for your test ... I began to have serious doubts :D

Sorry Mikell and thanks for your help. I have NO clue why it didn't work for me. But I would spend to much time debugging the error in MY script so I just made myself the code working. :thumbsup:

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...