每项分辨率的自动关闭程序



我是一个兴奋不来的程序员,我只是从我的朋友学到了我的基础上开始。(诸如:'keybd_event(vk_shift,0、0、0);'和x 之类的东西; setCursorPos(x,y); 睡眠(1);)但是我的程序有问题,我想为每个屏幕分辨率制作程序。不仅是我的1600x900。我尝试了许多事情,例如" getDesktopresolution(水平,垂直);"one_answers" getWindowRect",但这无济于事。我已经为我的解决方案制作了一个代码,但是我输入的内容无法与拥有1910x1075或类似内容的人一起工作。因此,我希望它自动检测屏幕并运行程序并关闭PC。最大的问题是将我的鼠标置于焦点,以便可以转到X-Lenght的中间,然后进入Y-Lenght的中间。这是我的分辨率的代码(1600x900):

int main()
{
    while (X < 800)
    {
        X++;
        SetCursorPos(X, Y);
        Sleep(1);
    }
    while (X < 450)
    {
        Y++;
        SetCursorPos(X, Y);
        Sleep(1);
    }
    while (X < 1600)
    {
        X++;
        SetCursorPos(X, Y);
        Sleep(1);
    }
    while (Y < 900)
    {
        Y++;
        SetCursorPos(X, Y);
        Sleep(1);
    }
    while (X > 800)
    {
        X--;
        SetCursorPos(X, Y);
        Sleep(1);
    }
    while (Y > 450)
    {
        Y--;
        SetCursorPos(X, Y);
        Sleep(1);
    }
    while (X > 1)
    {
        X--;
        SetCursorPos(X, Y);
        Sleep(1);
    }
    while (Y > 1)
    {
        Y--;
        SetCursorPos(X, Y);
        Sleep(1);`enter code here`
    }
    while (X < 1589)
    {
        X++;
        SetCursorPos(X, Y);
        Sleep(1);
    }
    void left_click()
        ;
    {
        mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); //Clicks to close program
        mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
    }
    while (X < 800)
    {
        X++;
        SetCursorPos(X, Y);
        Sleep(1);
    }
    while (Y < 450)
    {
        Y++;
        SetCursorPos(X, Y);
        Sleep(1);
    }
    while (X < 1600)
    {
        X++;
        SetCursorPos(X, Y);
        Sleep(1);
    }
    while (Y < 900)
    {
        Y++;
        SetCursorPos(X, Y);
        Sleep(1);
    }
    while (X > 800)
    {
        X--;
        SetCursorPos(X, Y);
        Sleep(1);
    }
    while (Y > 450)
    {
        Y--;
        SetCursorPos(X, Y);
        Sleep(1);
    }
    while (X > 1)
    {
        X--;
        SetCursorPos(X, Y);
        Sleep(1);
    }
    while (Y > 1)
    {
        Y--;
        SetCursorPos(X, Y);
        Sleep(1);
    }
    while (Y < 900)
    {
        Y++;
        SetCursorPos(X, Y);
        Sleep(1);
    }
    void right_click()
        ;
    {
        mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0); //Right clicks on windows icon
        mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
    }
    while (Y > 862)
    {
        Y--;
        SetCursorPos(X, Y);
        Sleep(1);
    }
    while (X < 378)
    {
        X++;
        SetCursorPos(X, Y);
        Sleep(1);
    }
    while (Y > 835)
    {
        Y--;
        SetCursorPos(X, Y);
        Sleep(1);
    }
    void left_click()
        ;
    {
        mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); //Clicks on Shut Down
        mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
    }
}

感谢您的帮助!

用于获取Mswindows中屏幕的大小您可以使用getDevicecaps函数https://msdn.microsoft.com/en-us/library/windows/desktop/dd144877(v=vs。85).aspx

相关内容

  • 没有找到相关文章

最新更新