win32gui

G

Gandalf

Hi,
I'm trying to capture the text word under the user cursor,
so I was searching the win32 lib for functions I can use.
i used this to fined the controller under the cursor
win32gui.WindowFromPoint(win32gui.GetCursorPos())
to get the controller, but then when I try to read the text with this
GetWindowText function it most of the time doesn't work, all the
"getline" methon like the following didn't worked in most of the time
too
win32gui.SendMessage(hwnd, win32con.EM_GETLINE, line, linetext)

I found this GetCharFromPosition in a VB forum which sound promising
but unfortunately it's not part of the win32gui for python

so now i'm looking for a reliable way to rich text from a controller
or position if you know a function who may do it or a better way
please tell me/
thank you and have a nice day
 
T

Tim Roberts

Gandalf said:
I'm trying to capture the text word under the user cursor,
so I was searching the win32 lib for functions I can use.

You should know that, in the general case, this is impossible. Remember
that the screen image you are looking at is just a big array of dots. If
the window underneath happens to be an image, there won't be any text to
fetch.

Now, in many cases it IS possible, but it's not easy.
i used this to fined the controller under the cursor
win32gui.WindowFromPoint(win32gui.GetCursorPos())
to get the controller,

That's the first step. Then, you need to figure out what kind of window it
is. If it is a standard edit box, you can use the EM_GETLINE functions. If
it's a rich text edit box, you can use the rich text messages.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,737
Latest member
Georgeengab

Latest Threads

Top