Jump to content

Re-Loading Chrome


billshu
 Share

Recommended Posts

I am using this code to reload Chrome.  The problem is the sleep() after the WinKill().  On my desktop I had to set the sleep = 2000.  On my laptop I had to set the sleep to 15000.  It appears I need to wait until Chrome is all the way down before doing the RUN command. I tried to loop test if WinExists() = 0 then continue, but it continued immediately. Without the sleep() the run() never opens Chrome.

The value of $LocalString is C:Program Files (x86)GoogleChromeApplicationchrome.exe  --new-window  "http://www.mypage.com"

 

Is there any way to do this without setting the sleep() up.  I do not want to  send F5 to reload, I need a fresh instance.

Func LoadChrome($LocalPageAddress)
   PostLog("LoadChrome() ")
   If $LaunchWindow <> 0 Then
        PostLog("Killing Previous Browser ")
       WinKill($LaunchWindow)
       sleep(15000)
   EndIf
 
   PostLog("Loading Browser ")
   $LocalString = $RunBrowserPath & " " & $LocalPageAddress
   PostLog("Running=" & $LocalString)
   Run ($LocalString)
   $LaunchWindow = winwait("MyPage - Google Chrome","",60)
 
   IF $LaunchWindow = 0 Then
         PostLog("TimeOut on Load Browser")
        Return(0)
   EndIf
 
   WinMove($LaunchWindow, "", $RunBrowserOriginX, $RunBrowserOriginY, $RunBrowserWidth, $RunBrowserHeight)
   sleep(500)
   SetZoom()
 
   PostLog("Browser Loaded")
   Return(1)
EndFunc
Link to comment
Share on other sites

You could try this:

If $LaunchWindow <> 0 Then
        PostLog("Killing Previous Browser ")
    Do
        ProcessClose("chrome.exe")
    Until Not ProcessExists("chrome.exe")
   EndIf

I know that isn't using the $LaunchWindow handle, but it will work just the same, and will stay in the loop until chrome is dead (I use this myself on a daily basis as part of one of my automated tools).

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

You could try this:

If $LaunchWindow <> 0 Then
        PostLog("Killing Previous Browser ")
    Do
        ProcessClose("chrome.exe")
    Until Not ProcessExists("chrome.exe")
   EndIf

I know that isn't using the $LaunchWindow handle, but it will work just the same, and will stay in the loop until chrome is dead (I use this myself on a daily basis as part of one of my automated tools).

Ian

 

Thanks Ian,  That really looks good. I will give it a try when I am back at my computer. 

Link to comment
Share on other sites

why not only work with a newly started browser in the first place and kill the other chrome process with a function checked with adlibregister

 

Thanks junkew,

I am not really a programmer, just play one on the Internets.  I have no clue what adlibregister is, but I will look it up. 

Don't really understand the first part of your comment, but I think you solved my problem, LOAD the new browser, and

let the OLD one die in its own sweet time.

Thanks again

Link to comment
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
 Share

×
×
  • Create New...