My question: Can I run multiple instances of this class? I would like to have many controllable windows open at the same time.
I tried this, but failed.
Code: Select all
#include <External\Chrome>
; Create an instance of the Chrome class using
; the folder ChromeProfile to store the user profile
FileCreateDir, ChromeProfile
ChromeInst := new Chrome("ChromeProfile")
FileCreateDir, ChromeProfile2
ChromeInst_1 := new Chrome("ChromeProfile2")
; Connect to the newly opened tab and navigate to another website
; Note: If your first action is to navigate away, it may be just as
; effective to provide the target URL when instantiating the Chrome class
PageInstance := ChromeInst.GetPage()
PageInstance.Call("Page.navigate", {"url": "https://autohotkey.com/"})
PageInstance.WaitForLoad()
PageInstance.Evaluate("alert('Hello World!');")
PageInstance_1 := ChromeInst_1.GetPage()
PageInstance_1.Call("Page.navigate", {"url": "https://google.com/"})
PageInstance_1.WaitForLoad()
PageInstance_1.Evaluate("alert('Hello World 2!');")
; Close the browser (note: this closes *all* pages/tabs)
PageInstance.Call("Browser.close")
PageInstance.Disconnect()
PageInstance_1.Call("Browser.close")
PageInstance_1.Disconnect()
ExitApp
return