1, how to click a button, on the other program
Such as click other programs on the determination of the above button above,
2, how to obtain other program click the confirm button,
CodePudding user response:
With spy++ find out that the window handle of the button, and then sends the message
If PostMessage (the window handle of the button, the WM_LBUTTONDOWN MK_LBUTTON, MakeLParam (10, 10)) Handle to the window and PostMessage (button, WM_LBUTTONUP, MK_LBUTTON, MakeLParam (10, 10)) then The begin ShowMessage (' click success); end; CodePudding user response:
reference 1st floor sololie response: with spy++ find out that the window handle of the button, and then sends the message If PostMessage (the window handle of the button, the WM_LBUTTONDOWN MK_LBUTTON, MakeLParam (10, 10)) Handle to the window and PostMessage (button, WM_LBUTTONUP, MK_LBUTTON, MakeLParam (10, 10)) then The begin ShowMessage (' click success); end; Ask a question, if it has a few buttons, how to determine whether the button I need? CodePudding user response:
Do you want to press the button to note down the handle to the button, the point that button will send message to the button Var BtnHwnd1 btnHwnd2: HWND; The begin //spy++ find such as a 'confirm' button on the handle Handle btnHwnd1:=sure button; //spy++ find such as a 'confirm' button on the handle BtnHwnd2:=cancel button handle; If PostMessage (btnHwnd1, WM_LBUTTONDOWN MK_LBUTTON, MakeLParam (10, 10)) And PostMessage (btnHwnd1, WM_LBUTTONUP MK_LBUTTON, MakeLParam (10, 10)) then The begin ShowMessage (' click confirm success); end; If PostMessage (btnHwnd2, WM_LBUTTONDOWN MK_LBUTTON, MakeLParam (10, 10)) And PostMessage (btnHwnd1, WM_LBUTTONUP MK_LBUTTON, MakeLParam (10, 10)) then The begin ShowMessage (' click cancel success); end; end; CodePudding user response:
reference sololie reply: 3/f do you want to press the button to note down the handle to the button, the point that button will send message to the button Var BtnHwnd1 btnHwnd2: HWND; The begin //spy++ find such as a 'confirm' button on the handle Handle btnHwnd1:=sure button; //spy++ find such as a 'confirm' button on the handle BtnHwnd2:=cancel button handle; If PostMessage (btnHwnd1, WM_LBUTTONDOWN MK_LBUTTON, MakeLParam (10, 10)) And PostMessage (btnHwnd1, WM_LBUTTONUP MK_LBUTTON, MakeLParam (10, 10)) then The begin ShowMessage (' click confirm success); end; If PostMessage (btnHwnd2, WM_LBUTTONDOWN MK_LBUTTON, MakeLParam (10, 10)) And PostMessage (btnHwnd1, WM_LBUTTONUP MK_LBUTTON, MakeLParam (10, 10)) then The begin ShowMessage (' click cancel success); end; end; Okay, I try CodePudding user response:
reference sololie reply: 3/f do you want to press the button to note down the handle to the button, the point that button will send message to the button Var BtnHwnd1 btnHwnd2: HWND; The begin //spy++ find such as a 'confirm' button on the handle Handle btnHwnd1:=sure button; //spy++ find such as a 'confirm' button on the handle BtnHwnd2:=cancel button handle; If PostMessage (btnHwnd1, WM_LBUTTONDOWN MK_LBUTTON, MakeLParam (10, 10)) And PostMessage (btnHwnd1, WM_LBUTTONUP MK_LBUTTON, MakeLParam (10, 10)) then The begin ShowMessage (' click confirm success); end; If PostMessage (btnHwnd2, WM_LBUTTONDOWN MK_LBUTTON, MakeLParam (10, 10)) And PostMessage (btnHwnd1, WM_LBUTTONUP MK_LBUTTON, MakeLParam (10, 10)) then The begin ShowMessage (' click cancel success); end; end; Thank you, this code can be used, the second problem can be done? Is on the contrary, such as external program click on the button, I need to send this message to return, this how to implement? CodePudding user response:
If PostMessage (btnHwnd1, WM_LBUTTONDOWN MK_LBUTTON, MakeLParam (10, 10)) And PostMessage (btnHwnd1, WM_LBUTTONUP MK_LBUTTON, MakeLParam (10, 10)) then The begin //don't you click the confirm button here, what to confirm button to perform the nature is no way of knowing you //you can only confirm if click on the button, and then do what you want to do ShowMessage (' click confirm success); end; CodePudding user response:
Click on the button, to simulate mouse press and lift is unreliable, directly sending BM_CLICK message is king, Of course, the premise is to find target button on the handle, CodePudding user response:
refer to 7th floor ccrun response: click on the button, to simulate the mouse press and lift is unreliable, directly sending BM_CLICK message is king, Of course, the premise is to find the target button handle, The webmaster, how to implement? CodePudding user response:
refer to 6th floor sololie response: if PostMessage (btnHwnd1 WM_LBUTTONDOWN, MK_LBUTTON, MakeLParam (10, 10)) And PostMessage (btnHwnd1, WM_LBUTTONUP MK_LBUTTON, MakeLParam (10, 10)) then The begin //don't you click the confirm button here, what to confirm button to perform the nature is no way of knowing you //you can only confirm if click on the button, and then do what you want to do ShowMessage (' click confirm success); end; Master, I through H1:=FindWindow (nil, 'UploadFTP');//h is the login window handle H2:=FindWindowEx (H1, 0, PChar (' TBitBtn), PChar (' manual upload '));//button To obtain the handle, but must be the target point up first, and then you can get to handle, but the target is to start automatically after the tray, this how to modify?