Findwindowex by handle c#

3.7k views Asked by At

I have been struggling with this for quite a while and could not get any answer I understand. I am new to c#.

So I am launching an application (Accpac to be specific) then I need to send the username via sendkeys/sendmessage to a child window. I've got the handle of the childwindow but I can't get it to work: IntPtr.(00020380), I get the error "Identifier expected"

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Runtime.InteropServices; 
    using System.Diagnostics; 
    using System.Windows.Forms; 
    using System.Threading; 
    
    namespace myNamespace
    {
        class StartAccpac
        {
            [DllImport("user32.dll", SetLastError = true)]
            static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
    
            [DllImport("user32.dll", SetLastError = true)]
            static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
    
            public static void Main3()
            {  
                //START ACCPAC
                //Process.Start("C:\\Programs\\Accpac\\runtime\\accpac.exe");
                IntPtr hwnd = IntPtr.Zero;
                IntPtr hwndChild = IntPtr.Zero;
    
                //Get a MAIN HANDLE
                hwnd = FindWindow(null, "Open Company");
                hwndChild = FindWindowEx(hwnd, IntPtr.(00020380), null, null); <---- ERROR
            }
            
        }
    }

enter image description here enter image description here enter image description here

1

There are 1 answers

0
Lloyd On BEST ANSWER

Your problem is here:

IntPtr.(00020380)

What you need to do is something like this:

new IntPtr(00020380)

However I suspect, being eight digits and looking at your screenshot this is a hex number so you might also want to consider:

new IntPtr(0x00020380)

Have a play with those, see what happens.