Jump to content
Sign in to follow this  
AnarchOi

Do something if window not detected after 30 seconds

Recommended Posts

AnarchOi

Hello,

i have problem with this small part of a code:

Sleep(10000)

Send("{ALTDOWN}d{ALTUP}")

Sleep(2000)

Send("{CTRLDOWN}a{CTRLUP}http://www.mysite.com{ENTER}")

WinWait("MyWebSiteName - Mozilla Firefox","")

If Not WinActive("MyWebSiteName - Mozilla Firefox","") Then WinActivate("MyWebSiteName - Mozilla Firefox","")

WinWaitActive("MyWebSiteName - Mozilla Firefox","")

Sleep(30000)

basically, when launched in firefox, it will wait 10 seconds, then type "www.mysite.com" in the address bar, then it will wait until the name of the website is displayed in Firefox's title bar (logically, this happen when we successfully reach the website). If the title matches, then it will wait 30 seconds and do something. If "MyWebSiteName" can't be found in firefox's title, then the script stays stuck here, and waits eternally for the term to appear in the title bar.

My problem is that i have a very crappy internet, and it disconects a lot of time. When i get disconnected, i usually have to refresh the page or type the address again.

So what i would like to do is:

30 seconds after the address has been typed in firefox's url bar, if "MyWebSiteName" still hasn't been found in firefox's title, i want it to type again the URL (repeat line #2 to #4)

If the the website title has not been found in firefox's title 30 seconds after it has been typed in the url bar, it means my connexion has been disconnected. That's why i have to try again to access the website.

I hope you understand!

thanks for the help

Share this post


Link to post
Share on other sites
Andreik

Here is a model:

Sleep(30000)
ShellExecute(@ProgramFilesDir & "\Mozilla Firefox\firefox www.yoursite.com")
Sleep(2000)
$TIME = TimerInit()
While 1
    If WinExists("YourWebSiteName - Mozilla Firefox") Then
;~      DO WHAT YOU WANT
    EndIf
    If TimerDiff($TIME) > 30000 Then
;~      DO SOMETHING
    EndIf
    Sleep(20)
WEnd
Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites
AnarchOi

Here is a model:

Sleep(30000)
ShellExecute(@ProgramFilesDir & "\Mozilla Firefox\firefox www.yoursite.com")
Sleep(2000)
While 1
    If WinExists("Title of your site") Then
;~      DO WHAT YOU WANT
    EndIf
    Sleep(20)
WEnd
thanks, but what i'd like to do is:

if "title of your site" isn't detected 30 seconds after executing firefox, then execute firefox again

edit: oops, i just saw your edit, i will try that

Edited by AnarchOi

Share this post


Link to post
Share on other sites
ProgAndy

You could to it with WinWait, too:

While 1 ; loop infinite
; do soething
Switch WinWait("title","text", 30) ; wait 30 secs
   Case 1 ; success, win exists
      ExitLoop ; exit while loop on success
   Case 0 ; timeout, win does not exist
      ; do what you want (nothing, go to start of loop)
EndSwitch
WEnd
; here you are after win exists
Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

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
Sign in to follow this  

×