#include <iostream>
#include <windows.h>
bool iskeypressed(unsigned timeout_ms = 0)
{
return WaitForSingleObject(
GetStdHandle(STD_INPUT_HANDLE),
timeout_ms
) == WAIT_OBJECT_0;
}
int main()
{
POINT cursor;
GetCursorPos(&cursor);
std::cout << "Press any key to stop the program!\n";
while (!iskeypressed(500)) {
cursor.x += 10;
SetCursorPos(cursor.x, cursor.y);
Sleep(1000);
cursor.x -= 10;
SetCursorPos(cursor.x, cursor.y);
Sleep(500);
}
std::cout << "Bye, Bye!\n";
return 0;
}
Small program to stop the screen saver or screen blanking by moving cursor.
C/C++ Programming, Uncategorised Posted on 04 Sep, 2020 08:07:31- Comments(0) https://www.guivi.one/?p=62
- Share