Extract Text from External Application into C# Application.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anilkumar025
    New Member
    • Aug 2013
    • 1

    Extract Text from External Application into C# Application.

    Hello,
    I have developed an Application in C# which extract text from external application's textbox , I am using user32.dll, The application is working fine but my problem is this - The external application's textbox contains text in unicode format, so whenever I extract text in my application it shows "??????" text. I have tried setting charset.unicode , and also used RichTextBox to show text in my application.
    Please let me know how to exract unicode text from external application.

    Here is code I am using


    private void button1_Click(o bject sender, EventArgs e)
    {
    IntPtr MytestHandle = new IntPtr(0x000603 42); // address of window displaying in SPY++.



    HandleRef hrefHWndTarget = new HandleRef(null, MytestHandle);


    // encode text into
    richTextBox1.Te xt = ModApi.GetText( hrefHWndTarget. Handle);
    }

    public static class ModApi
    {
    [DllImport("user 32.dll", EntryPoint = "SendMessageTim eout", SetLastError = true, CharSet = CharSet.Unicode )]
    public static extern uint SendMessageTime outText(IntPtr hWnd, int Msg, int countOfChars, StringBuilder text, uint flags, uint uTImeoutj, uint result);


    public static string GetText(IntPtr hwnd)
    {
    var text = new StringBuilder(1 024);

    if (SendMessageTim eoutText(hwnd, 0xd, 1024, text, 0x2, 1000, 0) != 0)
    {
    return text.ToString() ;
    }

    MessageBox.Show (text.ToString( ));
    return "";
    }
    }

    Please look at image attached.. it is showing result after extraction.
    Attached Files
Working...