#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>

#include<oleacc.h>

#pragma comment( lib,"Oleacc.lib")


HWINEVENTHOOK LHook = 0;


void CALLBACK WinEventProc(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime) {

IAccessible* pAcc = NULL;

VARIANT varChild;

HRESULT hr = AccessibleObjectFromEvent(hwnd, idObject, idChild, &pAcc, &varChild);

if ((hr == S_OK) && (pAcc != NULL)) {

BSTR bstrName, bstrValue;

pAcc->get_accValue(varChild, &bstrValue);

pAcc->get_accName(varChild, &bstrName);


char className[50];

GetClassName(hwnd, className, 50);

if ((strcmp(className, "Chrome_WidgetWin_1") == 0) && (wcscmp(bstrName, L"Address and search bar") == 0)) {

printf("URL change: %ls\n", bstrValue);

}

pAcc->Release();

}

}


void Hook() {

if (LHook != 0) return;

CoInitialize(NULL);

LHook = SetWinEventHook(EVENT_OBJECT_FOCUS, EVENT_OBJECT_VALUECHANGE, 0, WinEventProc, 0, 0, WINEVENT_SKIPOWNPROCESS);

}


void Unhook() {

if (LHook == 0) return;

UnhookWinEvent(LHook);

CoUninitialize();

}


int main(int argc, const char* argv[]) {

MSG msg;

Hook();

while (GetMessage(&msg, NULL, 0, 0)) {

TranslateMessage(&msg);


DispatchMessage(&msg);

}


Unhook();


return 0;

}



위 소스는 크롬의 url을 따는 소스라고해서 실행해봤는데 아무런 응답이없더라구요..


혹시 도움을 주실수있는분 계신가요