ComObj bug

Report problems with documented functionality
malcev
Posts: 621
Joined: 12 Aug 2014, 12:37

ComObj bug

21 Apr 2020, 13:15

If We put mouse in front of start menu in Windows 10 and press f11 then the code will not exit.
Bug?

Code: Select all

f11::
DllCall("LoadLibrary","Str","oleacc","Ptr")
DllCall("oleacc\AccessibleObjectFromPoint", "Int64", x==""||y==""?0*DllCall("GetCursorPos","Int64*",pt)+pt:x&0xFFFFFFFF|y<<32, "Ptr*", pacc, "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild)
a := ComObject(9, pacc, 1)
msgbox
ExitApp
But this will work OK

Code: Select all

f11::
DllCall("LoadLibrary","Str","oleacc","Ptr")
DllCall("oleacc\AccessibleObjectFromPoint", "Int64", x==""||y==""?0*DllCall("GetCursorPos","Int64*",pt)+pt:x&0xFFFFFFFF|y<<32, "Ptr*", pacc, "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild)
ComObject(9, pacc, 1)
msgbox
ExitApp
This also OK:

Code: Select all

f11::
DllCall("LoadLibrary","Str","oleacc","Ptr")
DllCall("oleacc\AccessibleObjectFromPoint", "Int64", x==""||y==""?0*DllCall("GetCursorPos","Int64*",pt)+pt:x&0xFFFFFFFF|y<<32, "Ptr*", pacc, "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild)
a := ComObject(9, pacc, 1)
ExitApp
User avatar
nnnik
Posts: 4468
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: ComObj bug

22 Apr 2020, 01:43

Hard to say what you do when the code you provide is not really readable.
Recommends AHK Studio
User avatar
lmstearn
Posts: 332
Joined: 11 Aug 2016, 02:32
GitHub: lmstearn
Contact:

Re: ComObj bug

22 Apr 2020, 02:09

Interesting- couldn't repro here on 1909 (after cold restart). pacc is a double pointer.
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
serzh82saratov
Posts: 105
Joined: 01 Jul 2017, 03:04

Re: ComObj bug

22 Apr 2020, 03:18

This is a big problem, there are no guarantees that the script will work, and it is impossible to track it somehow.
malcev
Posts: 621
Joined: 12 Aug 2014, 12:37

Re: ComObj bug

22 Apr 2020, 04:48

Ok. I`ve rewritten Sean`s unreadable functions and made more tests.
This code did not exits on Windows 10 EnterPrise LTSC v1809.
But it works OK on Windows 10 v1909.

Code: Select all

f11::
DllCall("LoadLibrary","Str","oleacc","Ptr")
DllCall("GetCursorPos","Int64*",pt)
VarSetCapacity(varChild,8+2*A_PtrSize,0)
DllCall("oleacc\AccessibleObjectFromPoint", "Int64", pt, "Ptr*", pacc, "Ptr", &varChild)
a := ComObject(9, pacc, 1)
msgbox
ExitApp
Also I try to get Accessible object from window and the result is the same.
It did not exit on v1809, but if We comment Send {LWin} then it will work OK.

Code: Select all

Send {LWin}
sleep 1000

hwnd := DllCall("FindWindowEx", "ptr", 0, "ptr", 0, "str", "Windows.UI.Core.CoreWindow", "str", "Start")
DllCall("LoadLibrary","str","oleacc","ptr")
VarSetCapacity(IID_IAccessible, 16)
DllCall("ole32\CLSIDFromString", "wstr", "{618736e0-3c3d-11cf-810c-00aa00389b71}", "ptr", &IID_IAccessible)
DllCall("oleacc\AccessibleObjectFromWindow", "ptr", hwnd, "uint", OBJID_CLIENT := 0xFFFFFFFC, "ptr", &IID_IAccessible, "ptr*", pacc)
acc := ComObject(9, pacc, 1)
msgbox % acc.accName(0)
exitapp
Also found new bug:

Code: Select all

msgbox % DllCall("FindWindowEx", "ptr", 0, "ptr", 0, "str", "Windows.UI.Core.CoreWindow", "str", "Start")
DetectHiddenWindows, On
msgbox % WinExist("Start")
Interesting thing, that when the start menu is cloaked this code shows "start" in 1909 and shows nothing in 1809

Code: Select all

hwnd := DllCall("FindWindowEx", "ptr", 0, "ptr", 0, "str", "Windows.UI.Core.CoreWindow", "str", "Start")
DllCall("LoadLibrary","str","oleacc","ptr")
VarSetCapacity(IID_IAccessible, 16)
DllCall("ole32\CLSIDFromString", "wstr", "{618736e0-3c3d-11cf-810c-00aa00389b71}", "ptr", &IID_IAccessible)
DllCall("oleacc\AccessibleObjectFromWindow", "ptr", hwnd, "uint", OBJID_CLIENT := 0xFFFFFFFC, "ptr", &IID_IAccessible, "ptr*", pacc)
acc := ComObject(9, pacc, 1)
msgbox % acc.accName(0)
exitapp
just me
Posts: 7172
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: ComObj bug

22 Apr 2020, 08:09

The original code is working with Win 10 Pro 1903 64-bit and AHK 1.1.32.00 U64.
malcev
Posts: 621
Joined: 12 Aug 2014, 12:37

Re: ComObj bug

23 Apr 2020, 04:40

I am 99% sure that it is ComObject bug, because without using com it works OK.

Code: Select all

Send {LWin}
sleep 1000

hwnd := DllCall("FindWindowEx", "ptr", 0, "ptr", 0, "str", "Windows.UI.Core.CoreWindow", "str", "Start", "ptr")
DllCall("LoadLibrary","str","oleacc","ptr")
VarSetCapacity(IID_IAccessible, 16)
DllCall("ole32\CLSIDFromString", "wstr", "{618736e0-3c3d-11cf-810c-00aa00389b71}", "ptr", &IID_IAccessible)
DllCall("oleacc\AccessibleObjectFromWindow", "ptr", hwnd, "uint", OBJID_CLIENT := 0xFFFFFFFC, "ptr", &IID_IAccessible, "ptr*", pacc)
VarSetCapacity(variant, 8+A_PtrSize*2, 0)
NumPut(VT_I4 := 3, variant, 0, "ushort")
if (A_PtrSize = 4)
   DllCall(NumGet(NumGet(pacc+0)+10*A_PtrSize), "ptr", pacc, "int64", NumGet(variant, 0, "int64"), "int64", NumGet(variant, 8, "int64"), "ptr*", name)   ; get_accName
else
   DllCall(NumGet(NumGet(pacc+0)+10*A_PtrSize), "ptr", pacc, "ptr", &variant, "ptr*", name)   ; get_accName
msgbox % StrGet(name)
exitapp
malcev
Posts: 621
Joined: 12 Aug 2014, 12:37

Re: ComObj bug

23 Apr 2020, 19:56

Thanks to serzh82saratov it appears that it is not bug of Autohotkey.
If We run the next code on windows 10 LTSC v1809, then autohotkey hangs untill We open start menu.

Code: Select all

Send {LWin}
sleep 500

hwnd := DllCall("FindWindowEx", "ptr", 0, "ptr", 0, "str", "Windows.UI.Core.CoreWindow", "str", "Start", "ptr")
DllCall("LoadLibrary","str","oleacc","ptr")
VarSetCapacity(IID_IAccessible, 16)
DllCall("ole32\CLSIDFromString", "wstr", "{618736e0-3c3d-11cf-810c-00aa00389b71}", "ptr", &IID_IAccessible)
DllCall("oleacc\AccessibleObjectFromWindow", "ptr", hwnd, "uint", OBJID_CLIENT := 0xFFFFFFFC, "ptr", &IID_IAccessible, "ptr*", pacc)

Send {LWin}
Sleep 500

VarSetCapacity(variant, 8+A_PtrSize*2, 0)
NumPut(VT_I4 := 3, variant, 0, "ushort")
if (A_PtrSize = 4)
   DllCall(NumGet(NumGet(pacc+0)+10*A_PtrSize), "ptr", pacc, "int64", NumGet(variant, 0, "int64"), "int64", NumGet(variant, 8, "int64"), "ptr*", name)   ; get_accName
else
   DllCall(NumGet(NumGet(pacc+0)+10*A_PtrSize), "ptr", pacc, "ptr", &variant, "ptr*", name)   ; get_accName
; hangs here
msgbox % strget(name)
I tried to write this code on AutoIt - the result is the same.

Code: Select all

Send("{LWIN}")
Sleep(500)

$hwnd = DllCall("user32.dll", "HWND", "FindWindow", "str", "Windows.UI.Core.CoreWindow", "str", "Start")
$hOLEACC = DllOpen("oleacc.dll")
$IID_IAccessible = DllStructCreate("int;short;short;byte[8]")
DllCall("Ole32.dll", "int", "CLSIDFromString", "WSTR", '{618736e0-3c3d-11cf-810c-00aa00389b71}', "struct*", $IID_IAccessible)
$pacc = DllCall($hOLEACC, 'ptr', 'AccessibleObjectFromWindow', 'hwnd', $hWnd[0], 'dword', 0xFFFFFFFC, 'ptr', DllStructGetPtr($IID_IAccessible), 'ptr*', 0)
$acc = DllCall("kernel32.dll", "none", "RtlMoveMemory", "idispatch*", 0, "ptr*", $pacc[4], "dword", 4+(4*@AutoItX64))

Send("{LWIN}")
Sleep(500)

$name = $acc[1].accname(0)
msgbox("","",$name)
swagfag
Posts: 3920
Joined: 11 Jan 2017, 17:59

Re: ComObj bug

24 Apr 2020, 03:03

regarding the "new bug": https://stackoverflow.com/a/52488331
malcev
Posts: 621
Joined: 12 Aug 2014, 12:37

Re: ComObj bug

24 Apr 2020, 06:37

Thanks. I also found answer of lexikos:
https://www.autohotkey.com/boards/viewtopic.php?p=193302#p193302
I think it will be good to change EnumWindows function, or write remarks to WinExist and other commands in manual.
swagfag
Posts: 3920
Joined: 11 Jan 2017, 17:59

Re: ComObj bug

24 Apr 2020, 09:58

i agree

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 6 guests