c++ - C++中的函数GetCursorPos()和SetCursorPos()的一些问题

标签 c++ function variables types

我是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 );

关于c++ - C++中的函数GetCursorPos()和SetCursorPos()的一些问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60059304/

相关文章:

R,将变量传递给系统命令

c++ - 如何在 ubuntu 12.04 中的 C/c++ 项目中链接库

c - table 游功能

Javascript 点击时乘法

python - Python 中有声明关键字吗?

javascript - 使用 javascript/jquery 加载文件

c++ - 如何在 C++ 中编辑和覆盖文件中的特定位置

c++ - 了解模板偏特化

c++ - unordered_set::erase(pos) 是否保留元素的顺序?

swift - 在文本字段更改时调用函数