System Hooks needed?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: System Hooks needed?

  1. #1
    Join Date
    May 2009
    Posts
    2

    System Hooks needed?

    I am working on a little side project that needs to read information from a text box of another program. I have used FindWindow, FindWindowEx, GetWindowText and was able to grab the initial values of the text box. The problem is that this is an ever changing value that I want to monitor in real time. Let me give you an example of what is happening and what needs to happen.

    Output.exe is putting a random number into TextBox1 with an initial value of 1.5. I programmed GetText.exe to grab the text from TextBox1 and it does this successfully every time I run through the routine, but it will always return the inital value of 1.5 it wont change with Output.exe.

    From what I have found thus far I think I am going to have to establish a System hook to monitor the text box in real time. My question is pretty much what API's should I be looking at, what types of web resources are there for this type of application, and is this NT/2000/XP/Vista specific or will I be able to port to a 9x machine?

    Any and all help is appreciated.

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,101

    Re: System Hooks needed?

    I would suggest DDE.
    Initially I thought of the PeekMessage API, but the problem is that VB6 applications retrieve all messages using GetMessage, and they'll never stay in the queue long enough for you to pick them up.

    With DDE you can use the LinkTopic, LinkItem, LinkMode, LinkTimeout properties.

    Here is a very good article about DDE :
    http://www.codeguru.com/vb/gen/vb_ge...le.php/c11549/

  3. #3
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: System Hooks needed?

    If you have already established a method using FindWindowEx and GetWindowText, why not doing this always again whenever you want to get the text out of the textbox-window.
    Run a timer which will do this chain of scanning:
    a) Find the main window handle
    b) find the window handle of the TextBox
    c) Get the contents of the TextBox

    Usually the handles of a window don't change until the window is closed and then reopened...

    Another thought about getting the text from the TextBox:
    Use SendMessage together with EM_GETTEXTEX code to fetch the text.
    You can research this at MSDN, if you are unseccessful, I shall see if I can find some sample.

  4. #4
    Join Date
    May 2009
    Posts
    2

    Re: System Hooks needed?

    Quote Originally Posted by WoF View Post
    If you have already established a method using FindWindowEx and GetWindowText, why not doing this always again whenever you want to get the text out of the textbox-window.
    Run a timer which will do this chain of scanning:
    a) Find the main window handle
    b) find the window handle of the TextBox
    c) Get the contents of the TextBox

    Usually the handles of a window don't change until the window is closed and then reopened...

    Another thought about getting the text from the TextBox:
    Use SendMessage together with EM_GETTEXTEX code to fetch the text.
    You can research this at MSDN, if you are unseccessful, I shall see if I can find some sample.
    I have done this already and it keeps on returning the original value of 1.5. I will try the DDE Method and let you guys know how it goes, thanks.

Tags for this Thread

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