Sign in to follow this  
Followers 0
E1M1

how to write ControlGetText in C++?

3 posts in this topic

I cant find way to read text from notepad. I want to write ControlGetText in C++. I got no errors but for some reason messagebox shows me nothing. I've googled but havent found any good example yet.

void CopyDataSend(){
    //HWND hWnd =  FindWindowW(NULL,L"D4672AD6-EA21-4FFD-88F5-4641A2B33E9F");
    HWND hWnd =  FindWindowW(NULL,L"Untitled - Notepad");
    HWND hEdit = FindWindowEx(hWnd,NULL,"Edit",NULL);
    printf("%X %X",hWnd,hEdit);
    char  sData[100];
    GetWindowTextA(hEdit, sData,100);
    MessageBoxA(0,sData,"",0);
}

edited

Share this post


Link to post
Share on other sites



From MSDN:

GetWindowText cannot retrieve the text of a control in another application

To retrieve the text of a control in another process, send a WM_GETTEXT message directly instead of calling GetWindowText.


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

Thanks. Didn't notice it on first read.


edited

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0