Jump to content

Prevent web browser from closing


Recommended Posts

I cobbled this script from the "WinExists" example in the AutoIt help file. It works fine except if I dismiss the "Window exists" msgbox or leave that "Window exists" command in line 10 out of my script altogether, the browser window closes. I want to perform several file and directory commands and run a program after I manually close the browser normally, without having to dismiss the small Autoit message box.

$SetupDir= "D:\Chrome\data"
$webfile = "file:///C:/Bin/0HOME.HTM"
Chrome()
Func Chrome()
        ; Run Chrome
ShellExecute("D:\Chrome\chromium-portable.exe", $webfile)
        ; Wait 3 seconds for Chrome.
WinWait("[CLASS:Chrome_WidgetWin_1]", "", 3)
        ; Test if Chrome opens and display the results.
        If WinExists("[CLASS:Chrome_WidgetWin_1]") Then
                 MsgBox($MB_SYSTEMMODAL, "", "Chrome exists")
        Else
                Sleep(300); to lower CPU usage less
FileDelete($SetupDir & "\Default\Preferences")
        EndIf
EndFunc
Exit

 

Edited by copyleft
Link to post
Share on other sites
  • copyleft changed the title to Prevent web browser from closing

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...