I'm new to WINAPI and find out how to send a message to another program. The program I am using however, I want to be able to click on a specific button. I've learned by looking at ++ windows programs for handling their controls every time they are reloaded. Control ID remains the same
If I specify the current handle to be seen by Spy ++ and use it and runs the code then it works fine and my external application But click on the button. I am trying to use GetDlgItem because I have read that I can handle the handle (hair window) for control. I am doing something wrong, but if I do not make any difference then I give 0 or 'blank'.
How can I get back handle control to GetDlgItem so that I can send that control to click in the external application?
Thank you for the time before input to help you.
[DllImport ("User32.dll")] static extern bool SetForegroundWindow (IntPtr hWnd); Process [myProcess = Process.GetProcessesByName ("program name here"); [DllImport ("user32.dll", chartset = charset.auto)] static extern int SendMessageA (IntPtr hwnd, int wMsg, int wParam, uint lParam); [DllImport ("user32.dll", Charset = Charset.auto)] Public static extern IntPtr GetDlgItem (Intel HW, int childID); Public const int WM_LBUTTONDOWN = 0x0201; Public const int WM_LBUTTONUP = 0x0202; Public Zero SendClick () {IntPtr hwnd = myProcess [0] .MainWindowHandle; SetForegroundWindow (hwnd); Int intCID = 1389; IntPtr ptrTest = GetDlgItem (HWD, IntisID); SendKids.SendWit (""); Thread.Sleep (1000); SendKeys.SendWait ("Various lessons to be sent here"); Thread.Sleep (1000); SendKeys.SendWait ("{ENTER}"); Thread.Sleep (1000); SendMessageA (ptrTest, WM_LBUTTONDOWN, WM_LBUTTONDOWN, 0); }
I think that you can find the "received" application of the Win32 API Use the window, and then find a child window of that handle. There is something like this that googling me Win32 API FindWindow
Comments
Post a Comment