Finding handle of control in another process

  • Thread starter Thread starter farseer
  • Start date Start date
F

farseer

Hi,
how can i find the handle of the control in another process that has
focus?

i can find the handle of a window in that process. i now want to
determine what control in that window has cursor focus, if any. i've
tried setting focus to the window using SetFocus API then calling
GetCapture and GetFocus to no avail.

thanks for any assistance
 
What are you trying to achieve in the end? Do you want to send
keystrokes to that control:- then you have to use keybd_event P/Invoke.

The problem with the fact that GetFocus returns incorrect HWND for
application in different process is that you should invoke
AttachThreadInput to connect to local-input state (but that function is
not available for WinCE platforms).
 
No, i don't want to send keystrokes, that i know how to do.
i want to determine if the input focus of a window in another process
is a specific control. For instance, for Internet Explorer, i want to
be able to determine when the control that has focus is th Address url
control (where a user would type "http...").

based on what you are telling me, this is probably not possible...
 
That's still *what* you're trying to do, not *why* you're trying to do it...

Paul T.
 
hi,
i am not clear as to what you your response means, could you explain.
In this case, i am not concerned with sending keystrokes (the question
asked of me by Sergey). In this case i simply want to determine the
focused control in another process's window.

anyway,
i was able to achieve this by using the dll injection trick i found on
this (or was it the pocket pc) group. I basically created a simple dll
that subclasses the window of concern, and that allows me to determine
the handle of the control.

thank you.
 
You've told us, so far, *how* you plan to do "something". What we can best
use to help you is what the "something" is. Maybe your method of
approaching this, by getting a control handle from another process is
utterly the wrong way to do whatever the actual job is. If you tell us what
the job is, we may be able to help.

Compare "I want to open a MSMQ queue and binary serialize a .NET CF object
through it for reassembly on the other end, which is running Linux", to "I
need to send an object's data to a Linux server using a mechanism that is
tolerant of disconnection". You see why we might say, "No, you can't." to
the first, but might have a real answer to the second? The second is what I
want to know about this thread...

Paul T.
 
Paul,
i'm writing something that will allow me to bookmark urls in PIE
without having to go thru the cumbersteps currently required. As i
browse from site to site, would like to quickly add urls that i may
want to come back to later...the tools activation will be a hotkey, but
will only activate if the focus of the cursor is in PIE's url listbox.
This simple rule allows me to overload that hotkey.

I wanted to say one more thing...i genuinely appreciate very much, the
assistance provided by you and other posters, but i guess i'm also
bothered or a bit perplexed by what seems to be some frustration i have
caused. I understand in many cases, being specific about what
application one might be working on would be helpful, but in this case,
while there did exist a specific application, i truly wanted to
understand whether i could do it AS asked, which was in short was: can
i do cross process inspection. Knowing the answer to the question as i
asked, was important to me as it gives me some ideas of what avenues to
pursue when encountering similar issues in the future...i.e., i'm not
just looking for a solution to my immediate problem, i'm also trying to
understand and learn...

anyway, thanks much as always..
 
OK, I'll think on that topic a bit and see what else comes to mind. We're
talking about PIE as it exists on PPC? The goal is an add-on piece of
software that adds this behavior to PIE? You could probably create your own
"PIE" that would make this a lot easier, for example, as another way of
doing this that might be more future-proof.

There's no frustration, except at feeling like we're not able to give the
quality of help that we want to. As with most any professional group, the
quality of our 'product' is a matter of personal pride and we want to give
the best possible answer, since that's the product here. When I'm asking a
question, I always try to give motivation for the question. What am I
trying to do (not how, but what)? What have I tried unsuccessfully (so that
roads already traveled won't waste time)? If I have one, what strategy am I
currently investigating (in case that suggests something to someone)? None
of that is absolutely necessary to get a good answer, but it increases the
probability of getting the best one, which you hope is everyone's goal.

Paul T.
 
oops, wrong thread..i was referring to your response to my other
question regarding Keyboard hooking.
with regards to PIE, the technique of injecting the dll into the
"other" process works..so i'm good there also...
 
Back
Top