Jump to content

WinWait . While Infinite Date


buzz44
 Share

Recommended Posts

hello ... my script waits until a window exist and writes the date to a file .. if the window does not exist it doesnt do anything....

WinWait("AutoIt Help")

FileWrite ("date.txt", @CRLF & @CRLF & "_=_=_=_=_=_" & "{" & @HOUR & ":" & @MIN & ":" & @SEC & " , " & @MDAY & "/" & @MON & "/" & @YEAR & "}" & "_=_=_=_=_=_" & @CRLF & @CRLF)


While 1
   If WinExists("AutoIt Help") = 0 Then
      Do
         Sleep(100)
      Until WinExists("AutoIt Help") = 1
  Else
     blah
  EndIf
WEnd

every time the window exists i want it to right the date to a file ... the first time it works ok cause it wait until the window exists then writes the date ... but every other time it will right the date an infinite amount of time .. in the eg above i removed the DATE bit from the while loop... if its in the while loop it just writes hte date and infinite amount of time and i end up with sumthing like

_=_=_=_=_=_{20:48:48 , 31/01/2005}_=_=_=_=_=_


_=_=_=_=_=_{20:48:49 , 31/01/2005}_=_=_=_=_=_


_=_=_=_=_=_{20:48:50 , 31/01/2005}_=_=_=_=_=_


_=_=_=_=_=_{20:48:51 , 31/01/2005}_=_=_=_=_=_


_=_=_=_=_=_{20:48:52 , 31/01/2005}_=_=_=_=_=_

any suggests?

problem again : .... is there anyway i can make it save the date each time the window exists?

thx

Edited by burrup

qq

Link to comment
Share on other sites

If it needs to keep running. You may need the filewrite in the loop?

WinWait("AutoIt Help")

FileWrite("date.txt", @CRLF & @CRLF & "_=_=_=_=_=_" & "{" & @HOUR & ":" & @MIN & ":" & @SEC & " , " & @MDAY & "/" & @MON & "/" & @YEAR & "}" & "_=_=_=_=_=_" & @CRLF & @CRLF)


While 1
    If Not WinExists("AutoIt Help") Then
        Sleep(100)
    Else
        FileWrite("date.txt", @CRLF & @CRLF & "_=_=_=_=_=_" & "{" & @HOUR & ":" & @MIN & ":" & @SEC & " , " & @MDAY & "/" & @MON & "/" & @YEAR & "}" & "_=_=_=_=_=_" & @CRLF & @CRLF)
        Do
            Sleep(100)
        Until Not WinExists("AutoIt Help")
    EndIf
WEnd
Link to comment
Share on other sites

Hi...

i dont understand your code completly.. but i think you could do something like this... (untested)

$winexist=0

While 1
  If (WinExists("AutoIt Help") = 1) AND ($winexist=0) Then              ;window exists
    ;write the date into file
     $winexist=1                                                  ;set marker
  Endif
  if (WinExists("AutoIt Help") = 0) Then                ;windows dosnt exist
    $winexist=0                                                  ;delete marker
  Endif
  sleep(100)                                                      ;sleep a bit
Wend

i hope i could help..

Edit: MHz was faster than me.. :-)

i think his version should be better then mine :-)

..mfg Domonoky

Edited by Domonoky
Link to comment
Share on other sites

Even replace the do until with winwaitclose.

WinWait("AutoIt Help")

FileWrite("date.txt", @CRLF & @CRLF & "_=_=_=_=_=_" & "{" & @HOUR & ":" & @MIN & ":" & @SEC & " , " & @MDAY & "/" & @MON & "/" & @YEAR & "}" & "_=_=_=_=_=_" & @CRLF & @CRLF)


While 1
    If Not WinExists("AutoIt Help") Then
        Sleep(100)
    Else
        FileWrite("date.txt", @CRLF & @CRLF & "_=_=_=_=_=_" & "{" & @HOUR & ":" & @MIN & ":" & @SEC & " , " & @MDAY & "/" & @MON & "/" & @YEAR & "}" & "_=_=_=_=_=_" & @CRLF & @CRLF)
        WinWaitClose("AutoIt Help")
    EndIf
WEnd

:lmao:

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...