AHK: ie com, block exit tabs

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
inseption86
Posts: 203
Joined: 19 Apr 2018, 00:24

AHK: ie com, block exit tabs

06 Nov 2018, 05:49

Hi guys, what could be wrong, why not work?

Code: Select all

#If IsHomeKey()
LButton:: ToolTip 
#If

IsHomeKey() { 
    MouseGetPos, , , WinId, ControlNN 
    if !InStr( ControlNN, "DirectUIHWND")
        return 0
    WinGet, Process, ProcessName, ahk_id %WinId%
    if Process != iexplore.exe 
        return 0
    return GetTextUnderMouse() = "create tabs (CTRL+T)" ? 1 : 0
} 

GetTextUnderMouse()  {
    Static h
    If !h
        h := DllCall("LoadLibrary","Str","oleacc","Ptr")
    If DllCall("oleacc\AccessibleObjectFromPoint"
                , "Int64", DllCall("GetCursorPos","Int64*",pt)+pt
                , "Ptr*", pacc, "Ptr", VarSetCapacity(varParent,8+2*A_PtrSize,0)*0+&varParent)=0
    Acc:=ComObjEnwrap(9,pacc,1), Parent:=NumGet(varParent,8,"UInt")
    try value := Acc.accValue(Parent)
    if value =
        try value := Acc.accName(Parent) 
    return value
}
but this work:

Code: Select all

#If IsHomeKey()
LButton:: ToolTip 
#If

IsHomeKey() { 
    MouseGetPos, , , WinId, ControlNN 
    if !InStr( ControlNN, "ToolbarWindow")
        return 0
    WinGet, Process, ProcessName, ahk_id %WinId%
    if Process != iexplore.exe 
        return 0
    return GetTextUnderMouse() = "Home" ? 1 : 0
} 

GetTextUnderMouse()  {
    Static h
    If !h
        h := DllCall("LoadLibrary","Str","oleacc","Ptr")
    If DllCall("oleacc\AccessibleObjectFromPoint"
                , "Int64", DllCall("GetCursorPos","Int64*",pt)+pt
                , "Ptr*", pacc, "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild)=0
    Acc:=ComObjEnwrap(9,pacc,1), child:=NumGet(varChild,8,"UInt")
    try value := Acc.accValue(child)
    if value =
        try value := Acc.accName(child) 
    return value
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Google [Bot], Rohwedder and 382 guests