c++ - C++ 中函数 GetCursorPos() 和 SetCursorPos() 的一些问题
问题描述
我是 C++ 的新用户,对变量类型一无所知。
我有这个代码,但它不能正常工作。对于正常情况,我的意思是 - 启动光标后,必须随机移动 -25 到 25 像素的屏幕。
抱歉,如果我提供的信息很少。问我我可以发送你想要的。对不起我的英语不好。
#include <iostream>
#include "MyForm1.h"
#include <windows.h>
#include <cstdlib>
#include <winuser.h>
#include <playsoundapi.h>
using namespace System;
using namespace System::Windows::Forms;
using namespace std;
// Cursor random moving here :3
int shakecursor() {
POINT p;
int __cdecl GetCursorPos(int &p);
cout << p.x << p.y << endl;
int x_p1;
int y_p1;
x_p1 = rand() % 0 -25;
y_p1 = rand() % 0 -25;
int x_p = p.x + x_p1;
int y_p = p.y + y_p1;
int __cdecl SetCursorPos(int x_p1, int y_p1);
Sleep(10);
return 0;
}
[STAThreadAttribute]
int main(cli::array<System::String ^> ^args) {
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
My3yPaB::MyForm mainForm;
Application::Run(%mainForm);
bool shaking = true;
while (shaking = true) {
shakecursor();
}
}```
解决方案
这些
int __cdecl GetCursorPos(int &p);
int __cdecl SetCursorPos(int x_p1, int y_p1);
不是函数调用。它们是函数声明。
相反,您的意思似乎是
GetCursorPos( p );
和
SetCursorPos( x_p, y_p );
推荐阅读
- python-3.x - 在pycharm中安装gdal
- javascript - 如果输入字段为空,Javascript 禁用和启用按钮
- java - 如何从 Java 中的 while 循环中返回 count 的值
- logstash - 带有动态主机的 Logstash 输入
- c# - XML 名称不能以“=”字符开头
- snowflake-cloud-data-platform - 从 s3 阶段读取时需要选择存储桶名称
- sql - 计算值在分区上更改时的运行总计
- node.js - 并行处理大量数据,平均分为可用内核
- c# - 使用 IStringLocalizer 的当前区域性不存在任何清单
- forms - 使用 Google Apps 脚本从传入的 webhook 解析“表单数据”