abdulrahmanok

Waiting And error after specific times ( Solved )

15 posts in this topic

#1 ·  Posted (edited)

Hi all ,

This is my try

Example()

Func Example()
  
 
 $a  = WinWaitActive("[CLASS:Notepad]", "", 10)

$var=0
While 1 
    
If $a = True then

ConsoleWrite("OK")
ExitLoop
Else

$var=+1
Sleep(2000)

endif

If $var=2 then

Msgbox(0,"","Waited 4 Sec ! Your Pc Is to slow")
EndIf
WEnd

I Hope You understood what i want...

Solved By @water

#include <MsgBoxConstants.au3>

Local $iWaitTime = TimerInit()                       ; Initiate the timer
$hNotepad = WinWaitActive("[CLASS:Notepad]", "", 20) ; Wait for a maximum of 20 seconds
If $hNotepad = 0 Then
    MsgBox($MB_ICONERROR, "Error", "Notepad is not active!")
Else
    MsgBox($MB_ICONINFORMATION, "Error", "Notepad is active!" & @CRLF & "It took " & Round(TimerDiff($iWaitTime)/1000, 2) & " seconds to process.")
EndIf
Edited by abdulrahmanok

Share this post


Link to post
Share on other sites



And your question is?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

What i want is :

wait for notepad

if notepad not open then wait 2000 and check again if notepad avalible 

after waiting for 4 or 6 seconds then close program or notify me .

Share this post


Link to post
Share on other sites

Move this line:

$a  = WinWaitActive("[CLASS:Notepad]", "", 10)

at top of loop will check until found. But i can't see any line where notepad is started.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

WinWaitactive in your script already waits for 10 seconds.
I would use something like this. It waits for a maximum of 6 seconds and then displays an error message if Notepad has not been active.

#include <MsgBoxConstants.au3>

$hNotepad = WinWaitActive("[CLASS:Notepad]", "", 6)
If $hNotepad = 0 Then
    MsgBox($MB_ICONERROR, "Error", "Notepad is not active!")
Else
    MsgBox($MB_ICONINFORMATION, "Error", "Notepad is active!")
EndIf

 

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Its already on top !  and I want only check for notepad because I will use this code with a lot other ways.

Edited by abdulrahmanok

Share this post


Link to post
Share on other sites

Why do you want to check for the window yourself?
WinWaitActive already provides a way to wait until the window appears or until the time limit has expired (as I posted in #5 above).
 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

@water

WinwaitActive is just example and you code will just wait for one time only ..

this is why I need code :

IF WinWait("Student Employment Time Attendance - Internet Explorer","") Then ;;;;;;;;;;;;
 $oLinks = _IETagNameGetCollection($oIE, "input")
For $oLink In $oLinks
    If String($oLink.type) = "submit" And String($oLink.value) = " Next" Then
          _IEAction($oLink, "click")
          ExitLoop
    EndIf
Next

I want add

else :

sleep (2000) 

and check for WinWait Again

Share this post


Link to post
Share on other sites

You need to give more information.
How often do you want to check for the Window to appear (2 times, 10 times ...)? What would you do if the window doesn't appear by then? Exit the script?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Check Until Found , And msgbox If  window doesn't Appear

Edited by abdulrahmanok

Share this post


Link to post
Share on other sites

#11 ·  Posted

As you want to check the processing time you could use something like this:

#include <MsgBoxConstants.au3>

Local $iWaitTime = TimerInit()                       ; Initiate the timer
$hNotepad = WinWaitActive("[CLASS:Notepad]", "", 20) ; Wait for a maximum of 20 seconds
If $hNotepad = 0 Then
    MsgBox($MB_ICONERROR, "Error", "Notepad is not active!")
Else
    MsgBox($MB_ICONINFORMATION, "Error", "Notepad is active!" & @CRLF & "It took " & Round(TimerDiff($iWaitTime)/1000, 2) & " seconds to process.")
EndIf

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#12 ·  Posted

Ty will Try this and inform you ...

Share this post


Link to post
Share on other sites

#13 ·  Posted

32 minutes ago, abdulrahmanok said:

Its already on top !

It's outside loop, i mean inside at first line after while.

Share this post


Link to post
Share on other sites

#14 ·  Posted

@water  Ty Very much Worked exactly like what I want o:)

@AutoBert Tried to put it inside while but nothing ... 

 

Share this post


Link to post
Share on other sites

#15 ·  Posted

:)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
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