Sulfuri Posted July 14, 2012 Share Posted July 14, 2012 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? Link to comment Share on other sites More sharing options...
water Posted July 14, 2012 Share Posted July 14, 2012 Can you post the whole script? Function WinExists and how you call it? 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...
Sulfuri Posted July 14, 2012 Author Share Posted July 14, 2012 (edited) expandcollapse popupWinActivate("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 July 14, 2012 by Sulfuri Link to comment Share on other sites More sharing options...
water Posted July 14, 2012 Share Posted July 14, 2012 $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 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...
Sulfuri Posted July 14, 2012 Author Share Posted July 14, 2012 (edited) looks like this now, allthough problem still persist while 1 $winexist = WinExists("Google - Google Chrome") If $winexist = 0 Then LaunchChrome() EndIf WEnd Edited July 14, 2012 by Sulfuri 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