#If and ComObjCreate return error 0x8001010D

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

#If and ComObjCreate return error 0x8001010D

04 May 2018, 12:03

Why If I press f10 I will get "Error: 0x8001010D - An outgoing call cannot be made since the application is dispatching an input-synchronous call", but if I press f11 all works OK.

Code: Select all

#If test()
f10::
#if

#If test1()
f11::
#if

test()
{
   ComObjCreate("InternetExplorer.Application")
}

test1()
{
   ComObjCreate("WinHTTP.WinHTTPRequest.5.1")
}
User avatar
gregster
Posts: 9221
Joined: 30 Sep 2013, 06:48

Re: #If and ComObjCreate return error 0x8001010D

04 May 2018, 12:10

Sorry, this code makes no sense at all. What is the expected outcome of this?
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: #If and ComObjCreate return error 0x8001010D

04 May 2018, 12:16

I want to know why when I create some com objects inside #If I receive error 0x8001010D.
awel20
Posts: 211
Joined: 19 Mar 2018, 14:09

Re: #If and ComObjCreate return error 0x8001010D

04 May 2018, 12:58

https://autohotkey.com/docs/commands/_If.htm#General_Remarks wrote:Note: Scripts should not assume that the expression is only evaluated when the key is pressed (see below).

The expression may also be evaluated whenever the program needs to know whether the hotkey is active. For example, the #If expression for a custom combination like a & b:: might be evaluated when the prefix key (a in this example) is pressed, to determine whether it should act as a custom modifier key.
You are creating a new instance of IE every time the expression is evaluated. How long does it take for IE to load-up when you launch it manually? I don't think it can keep up. Try re-thinking your approach to limit the number of times ComObjCreate is called, and be sure to close the objects you create when finished.
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: #If and ComObjCreate return error 0x8001010D

04 May 2018, 14:10

Try re-thinking your approach to limit the number of times ComObjCreate is called
I will get error after first run.
How long does it take for IE to load-up when you launch it manually? I don't think it can keep up
Ok, one more example:

Code: Select all

;ComObjError(false)
#If test()
f10::
#if

test()
{
   a := a_tickcount
   ComObjGet("winmgmts:")
   msgbox % a_tickcount - a
}
If I press F10 I will get the error.
If I uncomment ComObjError(false) then I will have 15ms.
lexikos
Posts: 9780
Joined: 30 Sep 2013, 04:07
Contact:

Re: #If and ComObjCreate return error 0x8001010D

05 May 2018, 00:38

0x8001010D means RPC_E_CANTCALLOUT_ININPUTSYNCCALL: "An outgoing call cannot be made since the application is dispatching an input-synchronous call."

The "input-synchronous call" is from the keyboard/mouse hook thread to the main thread, asking it to evaluate the #if expression.

You can't do it, so just don't.
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: #If and ComObjCreate return error 0x8001010D

05 May 2018, 04:37

I see. Could You tell me please, why the result of ACC function is wrong inside #If but there is no error.
You can test it:
1) open google chrome, move cursor to address bar, and press f10, f11.
If we press f10 we will get "New Tab - Google Chrome" (wrong result).
If we press f11 we will get "Address and search bar" (right result).
There is the same behaviour in Firefox.

Code: Select all

#If !test()
f10:: return 
#If
return

f11::test()
return

test()
{
   tooltip % Acc_test(child).accName(child)
}

Acc_test(ByRef _idChild_ = "", x = "", y = "")
{
	Static	h
	If Not	h
		h:=DllCall("LoadLibrary","Str","oleacc","Ptr")
	If	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)=0
	Return	ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,"UInt")
}
lexikos
Posts: 9780
Joined: 30 Sep 2013, 04:07
Contact:

Re: #If and ComObjCreate return error 0x8001010D

05 May 2018, 05:08

I assume it is unable to get a more specific result for the same reason as the other error: "An outgoing call cannot be made [while] the application is dispatching an input-synchronous call."

Methods of out-of-process COM objects cannot be called while #If is being evaluated.

There is no error message because 1) DllCall in v1 does not show error messages except in critical situations, and 2) nothing happened which could be considered an error condition (DllCall called the function, it did not throw an exception, it unwound the stack correctly and returned a value).

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: eagerahk, lavender, pizzatime, regnonmolina and 96 guests