Class Library: Browser
Version 1.0
Description
Provides functionality to interact with web browsers.
Download
Browser.zip
Requirements
FunctionsBrowser_constant(BrowserName)Returns the static Browser class object (used in the other functions).
ParametersBrowserName is one of the following (case-insensitive):
"InternetExplorer" or "IE" - for Internet Explorer
"Firefox" - for
Firefox (or its
portable version)
"Opera" - for
Opera"Opera@USB" for
Opera@USB (a portable Opera)
"GoogleChrome" for
Google Chrome (or its
portable version)
Browser_openURLs(BrowserObject, UrlList, UseCurrent = false, OpenURLsIn = "new tabs"):
Opens the list of URLs in the specified browser.
ParametersUrlList - List of URLs to open (one on each line)
For multiple URLs, you can store the URLs into a variable via a
continuation section (see example below).
UseCurrent - whether to use the current tab / window or to open a new tab / window before opening the URLs.
OpenURLsIn - one of these (case-insensitive):
- "Separate window" - opens the specified URLs each in a new tab (but in a new window)
- "New tabs" - opens each URL in a new tab
- "New windows" - opens each URL in a new window
Browser_exists(BrowserObject):
Wrapper function for
WinExist which uses the Title RegEx value of the BrowserObject for the WinTitle.
Notes: Sets the
TitleMatchMode to RegEx (required), and restores the previous setting (via A_TitleMatchMode).
Browser_isActive(BrowserObject):
Wrapper function for
WinActive which uses the Title RegEx value of the BrowserObject for the WinTitle.
Notes: Sets the
TitleMatchMode to RegEx (required), and restores the previous setting (via A_TitleMatchMode).
ExampleCode:
;"InternetExplorer" or "IE" - for Internet Explorer
;"Firefox" - for Firefox (or its portable version)
;"Opera" - for Opera
;"Opera@USB" - for Opera@USB
;"GoogleChrome" - for Google Chrome (or its portable version)
;change the browser to the one you use
UsedBrowser := Browser_constant("firefox")
;Browser_openURLs automatically trims leading and trailing spaces and tabs
;(LTrim is used to save memory)
UrlList =
(LTrim
http://www.yahoo.com/
http://www.google.com/
)
if !Browser_exists(UsedBrowser)
MsgBox, 0x1010, Browser is not open, % "Please open " . Browser_getName(UsedBrowser)
. " so that the specified URLs can be opened."
;Opens the URLs in a separate window (ignores UseCurrent)
Browser_openURLs(UsedBrowser, UrlList, 0, "separate window")
Things to come- Add ability to open URLs in the default browser. Does anyone know how to get the path to the default browser?
- Currently, Browser_openURLs waits for 1 second when opening a new window (for opening in "separate window" and "new windows"). Is there a way to detect when the new window is open?
Download Browser
_________________
As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the
Class Library. Check out
my scripts.