Sign in to follow this  
Followers 0
Sulfuri

Constant check through out a script if a certain window is active

5 posts in this topic

As the title say, i want a script that runs a certain task in chrome but if chrome where to shut down before the script finished i want it to relaunch chrome and start from the beginning. so i tried something like this

i have a "winexists" function that check if the window exist and then

while 1
If $winexist = 0 Then
LaunchChrome()
EndIf
WEnd

But what happens is that if i were to shut down chrome it keeps going through the script and once it's finished it starts chrome again.

I want it to stop where it's at and relaunch chrome(if chrome where to be shut down that is) and start over again. anyone think they can help? :>

Share this post


Link to post
Share on other sites



Can you post the whole script? Function WinExists and how you call it?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

WinActivate("Google - Google Chrome")
$winexist = WinExists("Google - Google Chrome")
Global $winexist
HotKeySet("{F9}", "end")

click()

while 1
If $winexist = 0 Then
LaunchChrome()
EndIf
WEnd

func Click()
MouseClick("left",142,389,1)
MouseMove(502,691)
MouseDown("left")
MouseMove(503,691)
MouseUp("left")
MouseMove(1119,558)
MouseDown("left")
MouseMove(1120,557)
MouseUp("left")
MouseClick("left",1017,295,1)
MouseMove(691,760)
MouseDown("left")
MouseMove(683,764)
MouseUp("left")
MouseMove(206,410)
MouseDown("left")
MouseMove(203,404)
MouseUp("left")
MouseMove(1407,57)
MouseDown("left")
MouseMove(1408,57)
MouseUp("left")
MouseMove(767,820)
MouseDown("left")
MouseMove(762,812)
MouseUp("left")
Send("{ALTDOWN}{ALTUP}")
EndFunc

Func LaunchChrome()
ShellExecute("chrome.exe")
WinActivate("Ny Flik - Google Chrome")
MouseClick("left",190,50,1)
sleep(2000)
Send("www.google.se{ENTER}")


sleep(2000)
click()
EndFunc



Func end()
ToolTip('Closing...')
Sleep(500)
ToolTip("")
Exit
EndFunc

Edited by Sulfuri

Share this post


Link to post
Share on other sites

$winexist is only set at the start of the script. You'll have to do the window check in the While loop.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

looks like this now, allthough problem still persist :(

while 1
$winexist = WinExists("Google - Google Chrome")
If $winexist = 0 Then
LaunchChrome()
EndIf
WEnd
Edited by Sulfuri

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  
Followers 0