c++ 模拟鼠标消息不成功
代码如下希望能对计算器进行随机操作但是没反应#include"windows.h"#include"winuser.h"#include"iostream.h"#incl...
代码如下 希望能对计算器进行随机操作 但是没反应
#include "windows.h"
#include "winuser.h"
#include "iostream.h"
#include "cstdlib"
#include "ctime"
int main(int argc, char *argv[])
{
HWND hwnd3;
RECT rect;
while(1)
{
hwnd3=FindWindow(NULL,"计算器");
GetWindowRect(hwnd3,&rect);
int x1=rect.right;
int x2=rect.left;
int y1=rect.bottom;
int y2=rect.top;
srand(time(0));
int i,j;
for(int k=0;k<100;k++){
i=rand()%(x1-x2);
j=rand()%(y1-y2);
if(PostMessage(hwnd3, WM_LBUTTONDOWN, MK_LBUTTON, MAKELONG(i,j)))
cout<<MAKELONG(i,j)<<endl;
PostMessage(hwnd3, WM_LBUTTONUP, MK_LBUTTON, MAKELONG(i,j));
}
}
return 0;
} 展开
#include "windows.h"
#include "winuser.h"
#include "iostream.h"
#include "cstdlib"
#include "ctime"
int main(int argc, char *argv[])
{
HWND hwnd3;
RECT rect;
while(1)
{
hwnd3=FindWindow(NULL,"计算器");
GetWindowRect(hwnd3,&rect);
int x1=rect.right;
int x2=rect.left;
int y1=rect.bottom;
int y2=rect.top;
srand(time(0));
int i,j;
for(int k=0;k<100;k++){
i=rand()%(x1-x2);
j=rand()%(y1-y2);
if(PostMessage(hwnd3, WM_LBUTTONDOWN, MK_LBUTTON, MAKELONG(i,j)))
cout<<MAKELONG(i,j)<<endl;
PostMessage(hwnd3, WM_LBUTTONUP, MK_LBUTTON, MAKELONG(i,j));
}
}
return 0;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询