Jump to content
Sign in to follow this  
billshu

Re-Loading Chrome

Recommended Posts

billshu

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

Share this post


Link to post
Share on other sites
llewxam

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.

Share this post


Link to post
Share on other sites
billshu

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. 

Share this post


Link to post
Share on other sites
billshu

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

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  

  • Similar Content

    • rudi
      By rudi
      Hello,
      usually I do Win automations, so I have no skills at all to handle HTML forms :-/
      The script to catch and syntax check  the required information from Excel is done.
      Now I'd like to automate the upload using this form, too:
       
      http://flashcardsdeluxe.com/flashcards/Upload.aspx
      What browser is easiest to do so? (IE, Chrome, FF) The Values $DeckCode, $DeckName, $DeckDefinition shall go to their HTML form fields finally "click" the button "upload flashcards" <table width="70%" class="cssCenter" border="0"> <tr> <td style="width: 1%">Deck&nbsp;Code</td> <td style="width: 100%"><input name="ctlDeckCode" type="text" id="ctlDeckCode" style="width:50%;" /> (no spaces allowed)</td> <td></td> </tr> <tr> <td style="width: 1%">Deck&nbsp;Name</td> <td style="width: 100%"><input name="ctlDeckName" type="text" id="ctlDeckName" style="width:50%;" /> (optional)</td> <td style="width: 1%" align="right"><input type="submit" name="ctlUpload" value="Upload Flashcards" id="ctlUpload" /></td> </tr> <tr> <td valign="top" style="padding-top: 5px" >Flashcard&nbsp;Text</td> <td colspan="2"><textarea name="ctlFlashcardText" rows="2" cols="20" id="ctlFlashcardText" style="height:280px;width:100%;"></textarea></td> </tr> </table> If someone kindly could jump in showing how to address just one of the input fields and how to "click" the "upload flashcards" button, I should be able to do the rest myself.
      TIA, Rudi.

    • TheWizEd
      By TheWizEd
      It seems AutoIt for Chrome is no longer working.  It's not in Google Store so not able to enable.  I can download the crx and drag to chrome but I can't figure out any way to enable the extension.
    • zxc3
      By zxc3
      Are there any examples of a script for Сhrome that allows you to check whether the information in the browser window has changed with a certain periodicity and signal this for 32-bit Windows.
    • fenhanxue
      By fenhanxue
      Q 1:
      How to judge whether the Chrome has been installed. How to get the complete route of chrome if it is installed?

      Q 2:
      How to judge whether the Adobe Flash Player has been installed.
    • FMS
      By FMS
      Hello,
      I'm trying to wright a automated process to show some URL's in chrome browsers on multiple screens.
      I've 4 screens and want to show on each screen another instance of chrome whit its own URL.
      In mine search on the site i din't find any topic for this specific problem.
      The way I was trying is something like :
      ShellExecute("chrome.exe", "http://URL1 --start-maximized") so I'll not see the addressbar but it was not opend full screen .
      I've some questions about this way:
      -Is there a way to maximize it on a dedicated screen ?
      (like URL1 on screen 1 , URL2 on screen 2 etc...)
      -Shellexecute will add a tab on a existing browser and will not open another instance, is there a way to work around this?
      Is there somebody who had the same problem whit chrome?
      thanks in advanced.
      edit: I've checked the chrome UDF but it din't same to get the job done....
×