evilC / AutoHotInterception

An AutoHotkey wrapper for the Interception driver
MIT License
708 stars 64 forks source link

0x80004002 - No such interface supported #64

Closed Okaghana closed 4 years ago

Okaghana commented 4 years ago

Hey there. I'm trying to send a string via AHI, but I keep getting error messages. Here is my existing code:

#Persistent ; (Interception hotkeys do not stop AHK from exiting, so use this)
#include <AutoHotInterception>

global AHI := new AutoHotInterception()
keyboard = AHI.GetKeyboardId(0x1017, 0xA003)

SendText(string){
    For index, char in StrSplit(string)
    {
        AHI.SendKeyEvent(keyboard, GetKeySC(%char%), 1)
        AHI.SendKeyEvent(keyboard, GetKeySC(%char%), 0)
    }
}

SendText("TEST")

As soon as I run it, the script stops as tells me

0x80004002 - No such interface supported

, followed by an excerpt from AutoHotInjection.ahk.

The rest of AHI works fine, the examples work without a problem

~Okaghana

evilC commented 4 years ago

keyboard in your function is a local variable, not global. You are passing an empty value for that parameter

SendText(string){
    global keyboard ; use keyboard var from global scope
    For index, char in StrSplit(string)
    {
        AHI.SendKeyEvent(keyboard, GetKeySC(%char%), 1)
        AHI.SendKeyEvent(keyboard, GetKeySC(%char%), 0)
    }
}
Okaghana commented 4 years ago

That doesn't fix the error. I still get

0x80004002 - No such interface supported

Same for passing the keyboard as a function parameter

evilC commented 4 years ago

AHI.SendKeyEvent(keyboard, GetKeySC(%char%), 1) is also wrong Function calls (GetKeySC) are already in "expression syntax", so wrapping char in % symbols is performing a double dereference AHI.SendKeyEvent(keyboard, GetKeySC(char), 1)

Okaghana commented 4 years ago

Also doesn't fix it.

evilC commented 4 years ago

keyboard = AHI.GetKeyboardId(0x03EB, 0xFF02) should be keyboard := AHI.GetKeyboardId(0x1017, 0xA003) You were literally setting the variable keyboard to the text AHI.GetKeyboardId(0x1017, 0xA003), not to the value that GetKeyboardId returns

Okaghana commented 4 years ago

That fixes is. Thank you!