c - Windows - What can we deduce from a mouse click on something "clickable"? -
as title suggests, i'm asking can find out click on screen.
more precisely, can click on precise element (which can +
symbol opening new tab on generic browser, or file
, save as...
elements on open office document) detected , return kind of string of has been clicked?
by working win32 api able detect if left button of mouse has been clicked:
for(character=1; character<=222; character++) { if(getasynckeystate(character) == -32767) { ... switch(character) { case vk_lbutton: ...; break; ... } } }
and when click detected, know has been clicked (or, @ least, name of window click happened):
void whichwindow(file *f) { hwnd foreground = getforegroundwindow(); char window_title[256]; if(foreground) { getwindowtext(foreground, window_title, 256); fputs(window_title, f); getmenufromwindow(f, foreground); } else fputs("problem retrieving window's title name", f); }
yet, don't know what has been clicked.
you'll have figured out getting mouse click's coordinates useless me, unless know coordinates of can clickable on screen.
i checked windowsui automation, of in c# and, porpouses, i'd prefer stay in c.
lot of people told me use 1 of programs in web, said, i'd prefer use c, without including extern library.
so: there way find out if clicked "new file" on text editor, or "play" on vlc, using windows api?
you can hold of handle, text , classname of (child) window under mouse cursor logic like:
hwnd hwndf = getforegroundwindow(); if (hwndf != null) { hwnd hwndc; tchar szclassname[64], szwindowtext[256]; point pt; getclassname(hwndf, szclassname, _countof(szclassname)); // main window getwindowtext(hwndf, szwindowtext, _countof(szwindowtext)); // main window getcursorpos(&pt); // in screen coordinates screentoclient(hwndf, &pt); // in client coordinates of main window hwndc = childwindowfrompointex(hwndf, pt, cwp_all); if (hwndc != null && hwndc != hwndf) { getclassname(hwndc, szclassname, _countof(szclassname)); // child window getwindowtext(hwndc, szwindowtext, _countof(szwindowtext)); // child window } }
Comments
Post a Comment