Sign in to follow this  
Followers 0
billshu

Re-Loading Chrome

5 posts in this topic

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



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

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

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

  • Similar Content

    • dilligence
      By dilligence
      Hello everyone,
      I could use some help with the following: 
      I'm a speech recognition user and recently I've started to use AutoIt for additional scripting because sometimes it works faster. 
      I would like to create an AutoIt script that will open the Chrome link on my desktop which is a a symbolic link, so that the Chrome cache is on my Ram drive:
      "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disk-cache-dir="A:\Browser Cache"
      Next I want to send the website address, in this case: https://autochords.com/ (with SendKeys) to the address bar.
      Then another SendKeys to send Enter.
      I want to use this script when I'm working on my girlfriend's computer, where speech recognition isn't installed.
      I could use ShellExecute ("Chrome", "https://autochords.com/") but then it won't run via my ram drive.
      I am a Dragon NaturallySpeaking user. The program has a scripting language similar to VBA. In Dragon the command is as follows:
      HeardWord "open","chrome" ; HeardWord acts as if I literally said "open Chrome" this command opens any desktop shortcut no matter which window I'm working in.
      Wait 1500 
      SendKeys "https://autochords.com/"
      SendKeys "{Enter}"; these last three lines are similar to AutoIt language I think.....
      Any help would be appreciated.
      Rob

       
    • zuliasro
      By zuliasro
      Hi,
      Please help me I haven't a big experience with AutoIt and JS.
      I develop a macro in AutoIt which open a Chrome browser, navigate between websites clicking no some links, insert data to forms, etc...
      Now I can't click on an element:
      <a class="mr-link js-click-link" style="font-size:16px; line-height:21px;"><u>Click now</u></a> Please pointing me how it's possible. 
      Thank you
    • zuliasro
      By zuliasro
      Hi,
      Please help me I haven't a big experience with AutoIt and JS.
      I develop a macro in AutoIt which open a Chrome browser, navigate between websites clicking no some links, insert data to forms, etc...
      Now I can't click on an element:
       
      <a class="mr-link js-captcha-link" style="font-size:16px; line-height:21px;"><u>Введите код с картинки</u></a> Please pointing me how it's possible. 
      Thank you
    • billshu
      By billshu
      Is there any way to change chrome settings from Auto-it.  I would like to change back and forth, between "Allow Site to show POP-ups" and "Do not Allow Site to show POP-up"?
    • ZeroByDevide
      By ZeroByDevide
      I got some code from internet and i wanted to open a incongito browser and search my website but i cant seem to open google chrome in the incongito mode.
      whenever i click to run my code it opens a tab in normal google chrome.
      heres my code now:
       ShellExecute("chrome.exe", "http://www.erikzandstra.nl", "--incongito")