简体   繁体   English

鼠标移动脚本/程序

[英]Mouse Movement Script / Program

This is the code I have written. 这是我编写的代码。

#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
    POINT cursorPos;
    HWND handle = FindWindowA(NULL,"MyGame");

    ScreenToClient(handle,&cursorPos);

    repeat:

    int x,y;

    if (GetKeyState(VK_UP) & 0x8000) goto Script;

    else goto repeat;

    Script:

    GetCursorPos(&cursorPos);

    cursorPos.x = cursorPos.x;

    cursorPos.y = cursorPos.y + 4;

    SetCursorPos(cursorPos.y, cursorPos.y);


    system("cls");

    cout << "Y Pos : " << cursorPos.y << "\n X Pos: " << cursorPos.x << endl;

    Sleep(5.3);

    goto repeat;


    system("PAUSE");
    return 0;

}

It is so that when I press the 'UP' arrow it will slowly move the mouse down 4 pixels every 5.3 ms. 这样,当我按下“向上”箭头时,它将每5.3毫秒将鼠标缓慢下移4个像素。 The problem I have with it is that I am only trying to modify the Y coordinates of the mouse (To make it move down by adding to its coordinates) but, it is also moving the X coordinates of the mouse down, resulting in a slanted line instead of a straight down one. 我遇到的问题是,我仅尝试修改鼠标的Y坐标(通过添加到鼠标的坐标来使其向下移动),但是它也向下移动了鼠标的X坐标,导致倾斜线而不是直线向下的线。 Any help appreciated. 任何帮助表示赞赏。

try changing SetCursorPos(cursorPos.y, cursorPos.y); 尝试更改SetCursorPos(cursorPos.y,cursorPos.y); to SetCursorPos(cursorPos.x, cursorPos.y); 到SetCursorPos(cursorPos.x,cursorPos.y);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM