get an object from a window and editing it

This is a discussion on get an object from a window and editing it within the Windows Programming forums, part of the Platform Specific Boards category; hello, i trying to build a program which takes (on mouse click) the text of any given input text box ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    2

    get an object from a window and editing it

    hello,
    i trying to build a program which takes (on mouse click) the text of
    any
    given input text box on any window and change it.
    how do i get the object of the text box and set my text to its value.

    thanks...

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,602
    To get the window the cursor is over:
    Code:
    GetCursorPos(&pt);
    hwnd = WindowFromPoint(pt);
    Then you can call GetWindowText with the handle and SetWindowText with the modified text.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Quote Originally Posted by Elysia View Post
    Then you can call GetWindowText with the handle and SetWindowText with the modified text.
    SetWindowText() can not change the text of a control in another app......
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,602
    My bad.
    You need to send WM_SETTEXT directly.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Jan 2008
    Posts
    2
    Thanks for the fast reply

    i got the position with GetCursorPos like you said,
    but getting the handler of the whole window was not good for me, so i used AccessibleObjectFromPoint() to get IAccessible.
    it was good enough for reading the tex but i couldn't figure out how to set the text,
    (set_accValue didn't work). is there a SETTEXT message for Iaccessible?

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,602
    No idea; never used it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    is there a SETTEXT message for Iaccessible?
    You'll probably have to enumerate thru the windows to find the window in question. Give the following a try:

    Call get_accChildCount
    Enumerate the child windows based on what is returned from get_accChildCount
    Attempt to get an Idispatch interface for the child
    Convert the Idispatch interface to an IAccessible interface
    Call WindowFromAccessibleObject to get window handle
    Call SendMessage using handle returned from WindowFromAccessibleObject function with WM_SETTEXT to send message to the targeted window.

    At this point you could continue recursively to identify other child windows.

    I haven't tested the above, It's just my interpretation of the MSDN docs.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help editing console output
    By Longbow0705 in forum C++ Programming
    Replies: 6
    Last Post: 03-27-2009, 08:57 AM
  2. internet
    By yeah in forum C Programming
    Replies: 16
    Last Post: 02-12-2005, 09:37 PM
  3. .rc and resource.h file editing
    By killdragon in forum C++ Programming
    Replies: 8
    Last Post: 08-31-2004, 01:27 PM
  4. Edit controls not sending messages to parent window
    By EMiller in forum Windows Programming
    Replies: 5
    Last Post: 11-13-2001, 10:03 PM
  5. Editing Instant Messenger (please help!)
    By Leeman_s in forum C++ Programming
    Replies: 6
    Last Post: 10-09-2001, 02:23 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21