Created
March 2, 2016 07:49
-
-
Save kumatti1/9ec94777fbe5da29f14c to your computer and use it in GitHub Desktop.
( ゚∀゚)o彡゜ワッフル!ワッフル!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <oleacc.h> | |
#include <Shlwapi.h> | |
#include <stdio.h> | |
#import <shdocvw.dll> | |
#import <mshtml.tlb> | |
typedef enum { | |
SWC_EXPLORER = 0x0, | |
SWC_BROWSER = 0x00000001, | |
SWC_3RDPARTY = 0x00000002, | |
SWC_CALLBACK = 0x00000004, | |
SWC_DESKTOP = 0x00000008 | |
} ShellWindowTypeConstants; | |
typedef enum { | |
SWFO_NEEDDISPATCH = 0x00000001, | |
SWFO_INCLUDEPENDING = 0x00000002, | |
SWFO_COOKIEPASSED = 0x00000004 | |
} ShellWindowFindWindowOptions; | |
#define URL L"https://appleid.apple.com/" | |
_COM_SMARTPTR_TYPEDEF(IAccessible, __uuidof(IAccessible)); | |
void GetAcc(IAccessiblePtr pAcc); | |
int CALLBACK WinMain( | |
_In_ HINSTANCE hInstance, | |
_In_ HINSTANCE hPrevInstance, | |
_In_ LPSTR lpCmdLine, | |
_In_ int nCmdShow | |
) | |
{ | |
try{ | |
HRESULT hr = S_OK; | |
::CoInitialize(NULL); | |
SHDocVw::IShellWindowsPtr psw; | |
psw.CreateInstance(__uuidof(SHDocVw::ShellWindows)); | |
if (FAILED(hr)) _com_issue_error(hr); | |
_variant_t varLoc(_bstr_t(URL)); | |
_variant_t VarRoot; | |
long h = 0; | |
IDispatchPtr pDisp = psw->FindWindowSW(&varLoc, &VarRoot, SWC_BROWSER, &h, SWFO_NEEDDISPATCH); | |
SHDocVw::IWebBrowser2Ptr pBrowser(pDisp); | |
MSHTML::IHTMLDocument2Ptr pDoc(pBrowser->Document); | |
HWND hwnd; | |
IUnknown_GetWindow(pDoc, &hwnd); | |
IAccessiblePtr pAcc; | |
AccessibleObjectFromWindow(hwnd, OBJID_CLIENT, IID_PPV_ARGS(&pAcc)); | |
GetAcc(pAcc); | |
} | |
catch (_com_error& e) { | |
MessageBoxA(0, e.ErrorMessage(), "", MB_OK); | |
//hr = e.Error(); | |
} | |
::CoUninitialize(); | |
return 0; | |
} | |
void GetAcc(IAccessiblePtr pAcc) | |
{ | |
long tmp = 0; | |
pAcc->get_accChildCount(&tmp); | |
if (tmp == 0) | |
return; | |
VARIANT varChild; | |
varChild.vt = VT_I4; | |
varChild.lVal = 0; | |
BSTR bstr = NULL; | |
pAcc->get_accName(varChild, &bstr); | |
OutputDebugStringW((LPCWSTR) bstr); | |
IDispatchPtr pDisp; | |
pAcc->get_accChild(varChild, &pDisp); | |
pAcc = pDisp; | |
//再帰 | |
GetAcc(pAcc); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment