How do I find the classname in C#?

Discussion in 'Software' started by Demon4231, Dec 9, 2007.

  1. Demon4231

    Demon4231 Private E-2

    How do you find a programs ClassName? I used:

    private void button2_Click(object sender, EventArgs e)
    {
    string lpClassName = "Notepad";
    string lpWindowName = "Untitled - Notepad";
    IntPtr hWnd = FindWindow(lpClassName, lpWindowName);
    SetForegroundWindow(hWnd);
    string z = "TEXT";
    const int WM_SETTEXT = 0x0C;
    SendMessage(hWnd, WM_SETTEXT, IntPtr.Zero, z);
    SendKeys.Send("This is my text");
    }

    for notepad and it worked just fine, but when I try:

    private void button2_Click(object sender, EventArgs e)
    {
    string lpClassName = "Wordpad";
    string lpWindowName = "Document1 - WordPad";
    IntPtr hWnd = FindWindow(lpClassName, lpWindowName);
    SetForegroundWindow(hWnd);
    string z = "TEXT";
    const int WM_SETTEXT = 0x0C;
    SendMessage(hWnd, WM_SETTEXT, IntPtr.Zero, z);
    SendKeys.Send("This is my text");
    }

    for Wordpad it either just stalls, puts "This is my text" into the textbox in my program, or just puts it in notepad (if it's open). How do I find what the ClassName is?
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds