Get text from the focused control in another window
-
Hello. I have the hwnd of another window and I am trying to get the text. I know how to get text from another window (WM_GETTEXT) but I don't know hot to get the text from the currently focused control in that window. Unfortunately GetFocus() won't work so I am out of ideas.. I would even try using EnumChildWindows, but I don't know how to find out if a particular control is focused. Can anybody help? Thank you in advance.
-
Hello. I have the hwnd of another window and I am trying to get the text. I know how to get text from another window (WM_GETTEXT) but I don't know hot to get the text from the currently focused control in that window. Unfortunately GetFocus() won't work so I am out of ideas.. I would even try using EnumChildWindows, but I don't know how to find out if a particular control is focused. Can anybody help? Thank you in advance.
nc3b wrote:
Unfortunately GetFocus() won't work...
Is it because the window (containing the control) is in another thread?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
nc3b wrote:
Unfortunately GetFocus() won't work...
Is it because the window (containing the control) is in another thread?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
Then you may need to use
GetGUIThreadInfo()
first."Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
Hello. I have the hwnd of another window and I am trying to get the text. I know how to get text from another window (WM_GETTEXT) but I don't know hot to get the text from the currently focused control in that window. Unfortunately GetFocus() won't work so I am out of ideas.. I would even try using EnumChildWindows, but I don't know how to find out if a particular control is focused. Can anybody help? Thank you in advance.
-
Then you may need to use
GetGUIThreadInfo()
first."Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
Can you please give an example? Suppose I have a HWND of a window (GetForegroundWindow()) and wnat to get it's focused child. How would I do that? Thank you.
First you need to get the list of processes that are running to find the one you are interested in. This can be done by calling
CreateToolhelpSnapshot()
, and then looping through each one with theProcessFirst()
/ProcessNext()
pair. Once found, use the PID as the first argument toGetGUIThreadInfo()
."Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
First you need to get the list of processes that are running to find the one you are interested in. This can be done by calling
CreateToolhelpSnapshot()
, and then looping through each one with theProcessFirst()
/ProcessNext()
pair. Once found, use the PID as the first argument toGetGUIThreadInfo()
."Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
Can you please give an example? Suppose I have a HWND of a window (GetForegroundWindow()) and wnat to get it's focused child. How would I do that? Thank you.
consider [GetWindowThreadProcessId^] also for getting the processid of the foreground window and thread id needed for GetGUIThreadInfo
-
consider [GetWindowThreadProcessId^] also for getting the processid of the foreground window and thread id needed for GetGUIThreadInfo