Skip to content

Instantly share code, notes, and snippets.

@czeyka
Forked from jethrow/IEGet.ahk
Last active February 14, 2020 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save czeyka/8d6ca3518bc3f8a6c8b35673cfcd0ca3 to your computer and use it in GitHub Desktop.
Save czeyka/8d6ca3518bc3f8a6c8b35673cfcd0ca3 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