使用C中的鼠标sendInput [英] using mouse with sendInput in C

查看:245
本文介绍了使用C中的鼠标sendInput的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以编程方式移动,并使用Windows API中的C.我已搜查谷歌高,低点击鼠标并不能找到任何sendInput教程平原C.所有我能找到的是C#/ C ++。我有一个Windows API的一点经验,并会爱一个伟大的教程将涵盖sendInput!谢谢!

I would like to programmatically move and click the mouse using the windows API in C. I have searched google high and low and can't find any sendInput tutorials for plain C. All I can find is C#/C++. I have little experience with the windows API and would love a great tutorial that would cover sendInput! Thanks!

推荐答案

汉斯帕桑特是正确的用C ++ code是几乎相同。这里是我结束了:

Hans Passant was right with C++ code being almost identical. Here's what I ended up with:

INPUT input;
input.type = INPUT_MOUSE;
input.mi.mouseData=0;
input.mi.dx =  x*(65536/GetSystemMetrics(SM_CXSCREEN));//x being coord in pixels
input.mi.dy =  y*(65536/GetSystemMetrics(SM_CYSCREEN));//y being coord in pixels
input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
SendInput(1,&input,sizeof(input));

这篇关于使用C中的鼠标sendInput的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆