Skip to content

Instantly share code, notes, and snippets.

@kumatti1
Last active December 10, 2015 01:18
Show Gist options
  • Save kumatti1/4356793 to your computer and use it in GitHub Desktop.
Save kumatti1/4356793 to your computer and use it in GitHub Desktop.
タグ名を得るの巻
#define UNICODE
#include <windows.h>
#include <stdio.h>
#include <Mshtml.h>
#include <Oleacc.h>
#include <Shlwapi.h>
#include <OleAuto.h>
VOID CALLBACK TimerProc(
_In_ HWND hwnd,
_In_ UINT uMsg,
_In_ UINT_PTR idEvent,
_In_ DWORD dwTime
);
int CALLBACK WinMain(
_In_ HINSTANCE hInstance,
_In_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nCmdShow
)
{
CoInitialize(NULL);
SetTimer(0,0,5000,&TimerProc);
MessageBox(nullptr,nullptr,nullptr,MB_OK);
CoUninitialize();
return 0;
}
VOID CALLBACK TimerProc(
HWND hwnd, // ウィンドウのハンドル
UINT uMsg, // WM_TIMER メッセージ
UINT_PTR idEvent, // タイマの識別子
DWORD dwTime // 現在のシステム時刻
)
{
POINT point;
VARIANT varItem;
IAccessible* pAcc;
KillTimer(0,idEvent);
GetCursorPos(&point);
HRESULT hr = AccessibleObjectFromPoint(point, &pAcc, &varItem);
if ((hr == S_OK))
{
IHTMLElement* pElements;
IUnknown_QueryService(pAcc,
__uuidof(pElements),
IID_PPV_ARGS(&pElements));
if(pElements)
{
BSTR bstr;
pElements->get_tagName(&bstr);
MessageBox(nullptr,(LPCWSTR)bstr,nullptr,MB_OK);
SysFreeString(bstr);
pElements->Release();
}
VariantClear(&varItem);
pAcc->Release();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment