Alex Rivera | Logout

How do I get the selected text from the focused window using native Win32 API?

Asked 2010-02-12T11:59:38.363
22

My app. will be running on the system try monitoring for a hotkey; when the user selects some text in any window and presses a hotkey, how do I obtain the selected text, when I get the WM_HOTKEY message?

To capture the text on to the clipboard, I tried sending Ctrl + C using keybd_event() and SendInput() to the active window (GetActiveWindow()) and forground window (GetForegroundWindow()); tried combinations amongst these; all in vain. Can I get the selected text of the focused window in Windows with plain Win32 system APIs?

Edit
Report

1 Answer

0

Try SendMessage(WM_COPY, etc. ).

answered 2010-02-12T15:14:54.353

Your Answer