Click here to Skip to main content
15,895,538 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,
I want to identify currently active component to display incoming data through port. Currently active component is any component containing mouse pointer eg Window textbox, Web textbox, notepad, MS Word etc etc.
Thanks in advance.....
Posted
Comments
Sergey Alexandrovich Kryukov 23-Jul-15 15:34pm    
Define "containing mouse pointer".
—SA

1 solution

By "currently active component" I take it you mean the current foreground application (The mousepointer can be over any application - it doesn't mean that the application has focus).

If so then try this solution[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 23-Jul-15 15:36pm    
This is the answer to an invalid question, but with a good link. I would also add: there are different things like 1) active window, 2) foreground window, 3) control currently having a keyboard focus (no more than one per desktop), and it also have top-level (desktop child) window parent or is such a window itself...
—SA
Umesh AP 24-Jul-15 4:58am    
Thanks CHill60 for the link.
Let me clear my concept about ‘currently active component’. Currently active component means any component which has focus, mouse pointer in it and having writable area eg Notepad, MS Word, TextBox etc etc. Basically I want to implement functionality like barcode reader. When barcode is scanned, it will display value in active component if it has writable area. If browser window is active & it doesn’t have writable area then it will display nothing.
Hope I have cleared all doubts.
Umesh AP 27-Jul-15 2:39am    
Hi All, how to write data once i got handle to an currently active component? Pls give suggestions regarding this.
Umesh AP 29-Jul-15 6:49am    
After searching a lot on net, the following link found useful for me.
http://www.codeproject.com/Articles/34752/Control-in-Focus-in-Other-Processes
And to display data added -
if (focusedControlHandle != IntPtr.Zero)
SendMessage(focusedControlHandle, WM_SETTEXT, 0, "This is the new Text!!! From C#");

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900