abdulrahmanok Posted October 31, 2016 Share Posted October 31, 2016 (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 October 31, 2016 by abdulrahmanok Link to comment Share on other sites More sharing options...
water Posted October 31, 2016 Share Posted October 31, 2016 And your question is? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 31, 2016 Author Share Posted October 31, 2016 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 . Link to comment Share on other sites More sharing options...
AutoBert Posted October 31, 2016 Share Posted October 31, 2016 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. Link to comment Share on other sites More sharing options...
water Posted October 31, 2016 Share Posted October 31, 2016 (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 October 31, 2016 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 31, 2016 Author Share Posted October 31, 2016 (edited) Its already on top ! and I want only check for notepad because I will use this code with a lot other ways. Edited October 31, 2016 by abdulrahmanok Link to comment Share on other sites More sharing options...
water Posted October 31, 2016 Share Posted October 31, 2016 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 (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 31, 2016 Author Share Posted October 31, 2016 @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 Link to comment Share on other sites More sharing options...
water Posted October 31, 2016 Share Posted October 31, 2016 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 (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 31, 2016 Author Share Posted October 31, 2016 (edited) Check Until Found , And msgbox If window doesn't Appear Edited October 31, 2016 by abdulrahmanok Link to comment Share on other sites More sharing options...
water Posted October 31, 2016 Share Posted October 31, 2016 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 (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 31, 2016 Author Share Posted October 31, 2016 Ty will Try this and inform you ... Link to comment Share on other sites More sharing options...
AutoBert Posted October 31, 2016 Share Posted October 31, 2016 32 minutes ago, abdulrahmanok said: Its already on top ! It's outside loop, i mean inside at first line after while. Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 31, 2016 Author Share Posted October 31, 2016 @water Ty Very much Worked exactly like what I want @AutoBert Tried to put it inside while but nothing ... Link to comment Share on other sites More sharing options...
water Posted October 31, 2016 Share Posted October 31, 2016 My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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