c++鼠标点击模拟代码
c++ mouse click simulation code
我很难理解下面的代码。我无法对此做出很好的解释。我在有问题的代码段旁边留下了评论。
void LeftClick ( )
{
INPUT input = {0};
// left down
input.type = INPUT_MOUSE;
input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
::SendInput(1,&input,sizeof(INPUT));
// left up
::ZeroMemory(&input,sizeof(INPUT)); // why zeroMemory? removing this code changes nothing that i can tell
input.type = INPUT_MOUSE; // why reset this variable? is it not already set?
input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
::SendInput(1,&input,sizeof(INPUT));
}
我在得到这个代码http://forums.codeguru.com/showthread.php?377394-Windows-SDK-User-Interface-How-can-I-Simulate-mouse-events-in-an-application
input
的结构中的所有数据,这就是代码必须重置input.type
变量的原因。
文件:http://msdn.microsoft.com/en-us/library/windows/desktop/aa366920(v=vs.85).aspx
实际上,我看了一些我写的旧代码,我根本没有使用ZeroMemory宏。这真的没有必要,因为设置的两个值都会再次重置。
相关文章:
- 如何使用Google Mock来模拟gettimeofday()
- 为什么在我的代码中没有调用 g 模拟方法
- 模拟BASH输入,以测试C 中的某些代码
- 如何在代码中模拟 ffmpeg 的empty_moov选项?
- 用代码模拟窗口拖放
- 模拟终止,退出代码:132
- 在C++代码生成器中模拟 C#"new"(隐藏虚拟方法)
- MFC Web 浏览器控件:模拟 Ctrl+N 需要多少(正常)代码行
- 用于模拟弹簧运动的代码中的分段错误
- 使用Google Mock来模拟在客户端代码中复制的对象
- c++鼠标点击模拟代码
- 如何在C代码中模拟c++名称空间特性
- 使用模拟测试迭代代码——它有意义吗?
- c++代码模拟键盘命令
- 如何利用模拟退火的概念来提高这个代码的排序效率
- 如何使用内联汇编模拟下面的c++代码
- c++代码模拟Windows下的虚拟映射网络驱动器
- 如何测试使用 MPI 调用的 CC++ 代码:是否有任何一组我可以使用的模拟函数
- omnet中的导航层次错误:模拟以退出代码:139终止
- 粒子模拟的并行化OpenMP代码性能差