winapi - Get text from a button in an application using win32 C++ and hooks -


i trying retrieve text of button on calculator (calc.exe) using winapi. have hooked wh_callwndproc , hook works fine. unable retrieve text of button (say numeric 7). using getdlgitemtext:

tchar text[256]; getdlgitemtext((hwnd)0x7068c, 0x89, text, strlen(text)); 

here 0x7068c parent window handle of numeric 7 button, while 0x89 control id. no text returned, though able click programmatically.

what doing wrong? tried use sendmessage wm_gettext, still doesnt work. want take approach , retrieve text buttons, textboxes in other applications.

you use accessibility:

        #include "windows.h"         #include "oleacc.h"         #include "atlbase.h"         #pragma comment(lib,"oleacc.lib")          int main()         {             ccomptr<iaccessible> pacc;             variant varchild;             if (succeeded(accessibleobjectfromwindow((hwnd)0x000d18e0,                  objid_window,iid_iaccessible, reinterpret_cast<void**>(&pacc))))             {                 ccombstr bstrname;                 varchild.vt = vt_i4;                 varchild.lval = childid_self;                 if (succeeded(pacc->get_accname(varchild, &bstrname)))                 {                     wprintf(l"%s", bstrname.m_str);                 }              }             return 0;         } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -