matt im trying to recreate your code in a C++ console application to investigate a bit further and im also interested in this method of hooks
ive got this
code:
HWINEVENTHOOK g_hook;
void CALLBACK HandleWinEvent(HWINEVENTHOOK hook, DWORD event, HWND hwnd,
LONG idObject, LONG idChild,
DWORD dwEventThread, DWORD dwmsEventTime)
{
printf("called\n");
IAccessible *pAcc = NULL;
VARIANT varChild;
HRESULT hr = AccessibleObjectFromEvent(hwnd, idObject, idChild, &pAcc, &varChild);
if ((hr == S_OK) && (pAcc != NULL))
{
char *classname;
classname = (char*)malloc(15);
GetClassName(GetParent(hwnd),(LPTSTR)classname,14);
printf("Classname: %s\n", classname);
if(strcmp(classname,"IMWindowClass") == 0){
printf("found\n");
}
}
}
// Initializes COM and sets up the event hook.
//
void InitializeMSAA()
{
CoInitialize(NULL);
g_hook = SetWinEventHook(
EVENT_SYSTEM_ALERT , EVENT_OBJECT_ACCELERATORCHANGE, // Range of events
NULL, // Handle to DLL.
HandleWinEvent, // callback.
0, 0, // Process and thread IDs of interest (0 = all)
WINEVENT_SKIPOWNPROCESS); // Flags.
}
int main(array<System:tring ^> ^args)
{
InitializeMSAA();
printf("init'd\n");
while(1);
system("pause");
return 0;
}
but the "called" is never even printed in the callback, i'm guessing it has something to do with sitting in an infinite loop, what am i supposed to do instead?