Advanced API Question: Hooking textfield in any/unknown application...

  • 12 years ago

    Question:

    In brief, I'd like to be able to get a handle to or track the current text-accepting object when I execute my program.  For example, the text-accepting interface could be the "To:" field in a Windows Live Mail message I'm writing, the Windows XP "Run" dialog, a notepad file, or the Visual Basic IDE.

     
    Elaboration (if required):
    I want to be able to hit a hotkey while I am selecting text in one of these fields, the text gets copied and is displayed in my application (which has been sitting listening for the key in the SystemTray), I do some formatting in the application, hit an "Execute" button, and my application retreats, automatically modifying the text in the text-accepting interface I was working in.  I have all the other parts required working (the HotKey, SysTray, copying to/from clipboard, etc.).  However, I don't know how to get a handle to a specific field in an unknown application.  I have played around with the FindWindow API's, but I won't necessary know in advance what the name of the application is (and, how to deal with multiple instances), and to ensure that the control returns to the specific field in which I am working.
     
    I could use a simulated "CTRL+C" call (or hook into it), but this seems a little sloppy if something occurs in between the program I am working on and my program.  I'm assuming that there must be a set of API calls I could use to do what I need?
     
    Any help would be greatly appreciated, even a link, or just a list of the API function/s I should use...
     
    Regards,
     
    Daniel
     
    P.S. - bonus: I'd love to be able to do this for files as well.  For example, calling my program while selecting files on the desktop, activating my program which records the paths allowing me to execute a move command and making notes as to why I downloaded them...
     

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“PHP is a minor evil perpetrated and created by incompetent amateurs, whereas Perl is a great and insidious evil perpetrated by skilled but perverted professionals.” - Jon Ribbens