R4z0r Posted May 3, 2013 Author Posted May 3, 2013 I TRIED YOURS and it DIDNT WORK so I tried with other code. YOURS is NOT working
R4z0r Posted May 3, 2013 Author Posted May 3, 2013 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
jdelaney Posted May 3, 2013 Posted May 3, 2013 (edited) #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 May 3, 2013 by jdelaney R4z0r 1 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.
mikell Posted May 3, 2013 Posted May 3, 2013 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 ?
jdelaney Posted May 3, 2013 Posted May 3, 2013 your bool route will be less cpu intensive. I didn't look over your logic. 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.
mikell Posted May 3, 2013 Posted May 3, 2013 If I wrote something wrong I would like to know what... ^^
jdelaney Posted May 3, 2013 Posted May 3, 2013 works for me...though the elseif is not needed...just an else should be used. 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.
mikell Posted May 3, 2013 Posted May 3, 2013 Thank you very much for your test ... I began to have serious doubts
R4z0r Posted May 4, 2013 Author Posted May 4, 2013 (edited) #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 !? Edited May 4, 2013 by R4z0r
mikell Posted May 4, 2013 Posted May 4, 2013 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)
R4z0r Posted May 10, 2013 Author Posted May 10, 2013 (edited) I understand your code - but what is the advantage to my code? Is yours faster? CPU less used? Edited May 10, 2013 by R4z0r
R4z0r Posted May 10, 2013 Author Posted May 10, 2013 Thank you very much for your test ... I began to have serious doubts 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.
mikell Posted May 10, 2013 Posted May 10, 2013 No trouble And excuse me for my a bit rough comments... the most important is that you could get your script to workÂ
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