How do I manipulate a text box from a remote process ?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14

Thread: How do I manipulate a text box from a remote process ?

  1. #1
    Join Date
    Jun 2008
    Location
    greater Cincinnati
    Posts
    54

    Question How do I manipulate a text box from a remote process ?

    Hello, and good day to everyone.

    Please excuse my ignorance. I am a novice C++ programmer, and I have 0 experience with Java.
     
    ----------------------------------------------------------------------------------------------------------------------------------
    I am trying to edit a text box of a program from another application. The program that contains the edit box is written in Java.

    I do not have the source for the program but I do have compiled classes though.

    I actually have already started a thread in the "C++ and WinAPI" forum querying different possible solutions to my problem, but I received no answer. I am posting in this forum to see if there are any Java specific resolutions.

    I have also read these two very old threads:

    Enumerate child windows
    Hooking into Java Application
     
    The latter thread seems to express that the only way to accomplish this task is by using Spy++, and home in on the messages pertaining to the window of interest. I have been trying this approach, and I've filtered through each of the various messages, but still I can't seem to pinpoint any messages that pertain to just that one textbox. I don't totally know what I am doing though.

    The former thread points out two routes to a possible solution.


    Norm mentions there are Swing methods to get all the components that are in one of those windows. But I don't know if after having retrieved a window's text box components how viable it would then be to manipulate the text using that component.



    dlorde seem to describe that RMI (Remote Method Invocation) could possibly be used to manipulate various controls within a remote Java application.




    remkop described a window class that seemed like it could do the job:

    Quote Originally Posted by remkop View Post
    The java.awt.Window class has several method that may be useful:
    static Window[] getWindows() - Returns an array of all Windows, both owned and ownerless
    static Window[] getOwnerlessWindows() - Returns an array of all Windows created by this application that have no owner.
    Window getOwner() - Returns the owner of this window.
    Window[] getOwnedWindows() - Returns an array containing all the windows this window currently owns.

    =================================================QUESTIONS============================================
    Q1) Is there a Java specific way to get some kind of handle or reference to the afore mentioned text box that would enable me to send text to it ?
    -------- I am hoping for something that is as easy to use as the Win32 " EnumWindows() " function, but I'll take anything. If you know of - any - way to accomplish this task I would like to hear that too.

    Q2) Do you think that any of the ways mentioned above could work for me?
    ------I am asking this because RMI and Java are very new to me, and I don't want to waste an enormous amount of time barkin' up the wrong tree.

    Q3) If there is no reasonable way to manipulate controls in a remote Java application then how in the world do Java programmers deal with such a task?


    Thanks for your invaluable time.
    Last edited by kmkkra; May 30th, 2011 at 06:50 PM.

  2. #2
    Join Date
    Jun 1999
    Location
    SW Missouri
    Posts
    3,430

    Re: How do I manipulate a text box from a remote process ?

    I do not have the source for the program but I do have compiled classes though.
    Without the source it will be much harder. Not all GUI controls are real/have OS peers. Some of the Swing components are "lightweight" which I assume means its a long way from the GUI to the real OS component.

    If you can't modify the Java program, one way to put text into an input field would be to use the Robot class. It positions the cursor on the screen, clicks and write characters.
    Norm

  3. #3
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: How do I manipulate a text box from a remote process ?

    Hmm, I don't recall mentioning RMI in this context, but there's a lot of stuff I don't recall these days...

    I know this kind of thing is possible because I used to play with a testing framework (Mercury's 'Quick Test Professional', now renamed 'HP Unified Functional Testing Software' - way to kill the magic, HP) that could run automatic test scripts on Java applications, but I don't know how their Java plug-in did it

    You might find the Java Debug Interface useful - I believe it allows you to hook into applications on remote JVMs.

    It's not something I've ever needed to do, apart from scripted testing - what's the context of this requirement?

    Today, most software exists, not to solve a problem, but to interface with other software...
    I. O. Angell
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  4. #4
    Join Date
    Jun 2008
    Location
    greater Cincinnati
    Posts
    54

    Re: How do I manipulate a text box from a remote process ?

    Quote Originally Posted by dlorde View Post
    It's not something I've ever needed to do, apart from scripted testing - what's the context of this requirement?

    The context is, I suppose, rather petty. The progam that I am trying to write is just for personal use. I am simply trying to use DDE to retrieve the Last ("Last price") of a stock and run it through a simple formula and continuously place/inject the result in "Share Quantity" text box within the "ThinkDesktop" trading platform.

    I actually have already started a thread in the "C++ and WinAPI" forum which details what I am trying to accomplish.
    Last edited by kmkkra; May 31st, 2011 at 12:48 PM.

  5. #5
    Join Date
    Jun 1999
    Location
    SW Missouri
    Posts
    3,430

    Re: How do I manipulate a text box from a remote process ?

    What is supposed to happen after you enter the text in the textbox?
    I have used Robot to automatically enter a password for me in a thirdparty app that always required it everytime I started it. Only requirement was that the app be positioned at the same spot on the screen.
    Norm

  6. #6
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: How do I manipulate a text box from a remote process ?

    Quote Originally Posted by Norm View Post
    What is supposed to happen after you enter the text in the textbox?
    I was wondering that myself - to be used by the app, text box contents usually need to be submitted, and if that was done regularly or every time the pasted data changed, grabbing focus and whatever else, wouldn't that make the user's session a bit annoying?

    One of the principal objects of theoretical research in any department of knowledge is to find the point of view from which the subject appears in its greatest simplicity...
    J. W. Gibbs
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  7. #7
    Join Date
    Jun 2008
    Location
    greater Cincinnati
    Posts
    54

    Re: How do I manipulate a text box from a remote process ?

    Quote Originally Posted by Norm View Post
    What is supposed to happen after you enter the text in the textbox?


    Well the share quantity will - automatically - float with respect to the current share price. And, when I get ready to actually open an order on the market I simply click "confirm and send" and the last values placed/injected in my order will be the ones that I use for my official open order.
    Last edited by kmkkra; May 31st, 2011 at 01:11 PM.

  8. #8
    Join Date
    Jun 2008
    Location
    greater Cincinnati
    Posts
    54

    Re: How do I manipulate a text box from a remote process ?

    Quote Originally Posted by dlorde View Post
    I was wondering that myself - to be used by the app, text box contents usually need to be submitted, and if that was done regularly or every time the pasted data changed, grabbing focus and whatever else, wouldn't that make the user's session a bit annoying?

    Well, I was hoping that I would find (be offered) a way to continuously place/inject the data - without - giving focus to that text box. As a matter of fact, I know at least one way to do this. I could just type in a long random number in the text box, and then scan the process's memory with Win32 " ReadProcessMemory() " for that number, and then replace that number with what I want. That is assuming I would have access rights to that memory. I think the window area would have to be repainted though to see the new values.
    Last edited by kmkkra; May 31st, 2011 at 01:18 PM.

  9. #9
    Join Date
    Jun 1999
    Location
    SW Missouri
    Posts
    3,430

    Re: How do I manipulate a text box from a remote process ?

    without - giving focus to that text box
    Don't know how to do that. Would it take input out of focus?
    Norm

  10. #10
    Join Date
    Jun 2008
    Location
    greater Cincinnati
    Posts
    54

    Re: How do I manipulate a text box from a remote process ?

    Quote Originally Posted by Norm View Post
    Don't know how to do that. Would it take input out of focus?

    Yes.


    Well, I would guess that there are ways of inputing values to a control without having to set focus to it. I guess - I don't know....

    The way I metioned above is one way.


    Actually I could live with focus being repeatedly set to the Quantity control. I geuss, typically, share prices change - maybe as much as every half second. I just have to devise a system to stop updates at undesirable times, like maybe when I set another window in focus or maybe when I move the mouse.


    But I'll consider anything really. By the way. I think I will at least temporarily go with the method you described earlier. You know - autonomously positioning the cursor, clicking, and entering data.

    Thanks bud, Good tidings.
    Last edited by kmkkra; May 31st, 2011 at 04:29 PM.

  11. #11
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: How do I manipulate a text box from a remote process ?

    I dunno - I can't help thinking it would be so much simpler to have little app to continually display the share price in a separate window (or the task bar?). You could arrange that clicking on it would copy the value to the system clipboard, allowing you to just paste it into the main application field when required. YMMV.

    Indirection is the right direction...
    A. Glew
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  12. #12
    Join Date
    Jun 2008
    Location
    greater Cincinnati
    Posts
    54

    Re: How do I manipulate a text box from a remote process ?

    @dlorde


    Hey that's actually a good idea. I think I may just write my program to do just that. I haven't yet learned how to properly format info that is to be copied to the clipboard. Also I'm not sure wether to go with a window or taskbar because my taskbar is always extremely crowded, and have it on auto-hide. That, however, is a good idea though.




    Thanks for your opinion. Good tidings friend.
    Last edited by kmkkra; June 1st, 2011 at 08:54 AM.

  13. #13
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: How do I manipulate a text box from a remote process ?

    It's worth a try - make a window just big enough to display the data in a text field or label, add a mouse listener/adapter, and Robert is your father's brother...

    Putting stuff on the system clipboard is fairly simple - check out Cut, Copy, & Paste and Clipboard Copy & Paste.

    Computer Science is a science of abstraction -creating the right model for a problem and devising the appropriate mechanizable techniques to solve it...
    A. Aho and J. Ullman
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  14. #14
    Join Date
    Jun 1999
    Location
    SW Missouri
    Posts
    3,430

    Re: How do I manipulate a text box from a remote process ?

    Who is this Bob guy?
    Norm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center