Skip to content

Instantly share code, notes, and snippets.

@jethrow
Last active February 14, 2020 09:30
Show Gist options
  • Save jethrow/2574167 to your computer and use it in GitHub Desktop.
Save jethrow/2574167 to your computer and use it in GitHub Desktop.
; AutoHotkey_L:
IEGet(name="") {
IfEqual, Name,, WinGetTitle, Name, ahk_class IEFrame ; Get active window if no parameter
Name := (Name="New Tab - Windows Internet Explorer")? "about:Tabs":RegExReplace(Name, " - (Windows|Microsoft) Internet Explorer")
for WB in ComObjCreate("Shell.Application").Windows
if WB.LocationName=Name and InStr(WB.FullName, "iexplore.exe")
return WB
}
; AHK Basic:
IEGet(name="") {
IfEqual, Name,, WinGetTitle, Name, ahk_class IEFrame ; Get active window if no parameter
Name := (Name="New Tab - Windows Internet Explorer") ? "about:Tabs":RegExReplace(Name, " - (Windows|Microsoft) Internet Explorer")
oShell := COM_CreateObject("Shell.Application") ; Contains reference to all explorer windows
Loop, % COM_Invoke(oShell, "Windows.Count") {
if pwb := COM_Invoke(oShell, "Windows", A_Index-1)
if COM_Invoke(pwb, "LocationName")=name and InStr(COM_Invoke(pwb, "FullName"), "iexplore.exe")
Break
COM_Release(pwb), pwb := ""
}
COM_Release(oShell)
return, pwb
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment