Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,,
I want to make a c# app that detects the active window and detects if a textbox is placed in it (Obviously this textbox should be the focused control of the form), and then pastes a certain text into this textbox.
NOTE: The application we are going to paste text in it is NOT our c# application AND is not a web page.


All I want is some ideas or suggestions on how this could be made...
Thanks in advance.
Posted
Updated 9-Oct-10 12:06pm
v3
Comments
DavidKiryazi 9-Oct-10 18:07pm    
I am not sure how to do this in C#, but there is an application called AutoIT (free automation tool) that can do exactly what you want. You might be able to call it from inside C# and run the script using clipboard as shared data repos.
AliNajjar 9-Oct-10 18:16pm    
Thanks for your fast response.
What I had in mind was something like the following:
1st- Detecting the active window, Maybe Process ID and handle of window..
2nd- Detecting the textbox that would be focused as I mentiond before.
3rd- Pasting the text needed in that textbox.
Nevertheless I am going to consider the idea you presented. But for now Thanks again and Any new ideas are appreciated.
shakil0304003 9-Oct-10 23:44pm    
What will you do by this work!!!
AliNajjar 10-Oct-10 0:13am    
This idea has just popped out when I found my self filling the same fields in so many programs for regestering it after I had my computer formatted and a fresh copy of windows installed.
So I thought something like this will be useful.
DavidKiryazi 10-Oct-10 20:55pm    
Ali based on this requirement I STRONGLY suggest you look at AutoIT. It will do EXACTLY what you want. It is a free tool and is very powerful for pre-form filling. The help file is also very easy to learn so browsing that you should be able to pick out the commands you need in no longer than 1-2 hours

HI ..,

i think you can achive this by using send keys , see the CP article in
the below link.., you have to made your own application by using this wrappers
Sending Keystrokes to another Application in C#[^]

First you have to active the window(third party application).
   <pre lang="midl">int iHandle = NativeWin32.FindWindow(null, txtTitle.Text);
NativeWin32.SetForegroundWindow(iHandle);




see the above code block how to active the window of third party application. then send the TAB keys to focus the text box which you want. select the text and copy to clip board, then activate your c# application paste it where you want. (selection and copy also you can done with SEND KEYS).

This solution will not help you 100%, but you will get an idea ..

Thanks & Regards
Rajesh B
 
Share this answer
 
Use clipboard class

follow the link

http://msdn.microsoft.com/en-us/library/system.windows.forms.clipboard.aspx
 
Share this answer
 
Comments
Kubajzz 10-Oct-10 7:22am    
Reason for my vote of 1:
does not answer the question at all.
OK PLEASE GIV A LIVE SCENARIO OR A BRIEF DESCR.. SO THAT I COULD HELP U FURTHER.
AS I VE POSTED IF U USE CLIPBOARD CLASS U CAN COPY TEXT OR OTHER TO CLIPBOARD AND CAN BE PASTED ANY WHERE,
MEANS ANY APPLICATION..
USING CTRL+V..

PASS UR COMMENTS PLS...
 
Share this answer
 
Comments
Toli Cuturicu 11-Oct-10 7:10am    
Don't YELL!

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