reading editbox contents from a different program - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

reading editbox contents from a different program

I need to read the contents of an editbox (or possibly a richedit box) from another program, and I'm not at all sure how to do this. GetWindowText() works when called on editboxes from my own program, but it just returns an empty string when I've tried it on editboxes from other programs. Does anyone know how I could do this?

Comments

  • pingpongpingpong Posts: 937Member
    Well, you cant easily read another process memory and they cannot read yours. When you call GetWindowText, you send that process a pointer to your local memory, they get it as null.

    I havent tried this but might work, but why not send the control WM_COPY then read the text off the clipboard?

    : I need to read the contents of an editbox (or possibly a richedit box) from another program, and I'm not at all sure how to do this. GetWindowText() works when called on editboxes from my own program, but it just returns an empty string when I've tried it on editboxes from other programs. Does anyone know how I could do this?
    :

  • ifaqsifaqs Posts: 13Member
    You could get the desktop window:

    HWND dtop = GetDesktopWindow();

    and then work with all or everyone of its child windows:

    EnumChildWindows(dtop, &EnumChildProc, 0);

    , being EnumChildProc() something like that:

    BOOL CALLBACK EnumChildProc(HWND hWnd, LPARAM lParam) {
    //Send the message to every window. You could specify only
    //some childwindows by asking for its (Get)ClassName.
    SendMessage(hWnd, EM_GetOrSetWhatYouWant, 0, 0);
    return TRUE;
    }

    Hope useful.
Sign In or Register to comment.