getting text entered in textbox of other applications using c#

前端 未结 3 1280
傲寒
傲寒 2020-12-17 07:26

I am fighting with this thing for the whole day. Still i couldn\'t figure out the exact solution for this. Help me out.

My objective is very simple. I want to get t

3条回答
  •  醉话见心
    2020-12-17 08:03

    You are correct. You will need to use the Windows API. For example:

    [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
    static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
    

    But first, you'll probably need to use FindWindow or FindWindowEx(?) recursively from the desktop down to where the text box is in the window hieracrchy to get the right window handle.

    It looks like http://www.pinvoke.net/ has a good database of Win API's.

    Hope that helps.

提交回复
热议问题