Add files

This commit is contained in:
olari
2019-05-15 17:44:39 +03:00
parent ad2727652d
commit 4ec0e2569d
3 changed files with 90 additions and 0 deletions

43
cpp/spinner.cpp Executable file
View File

@@ -0,0 +1,43 @@
#include <Windows.h>
#include <cstdio>
#include <cmath>
#include <tuple>
constexpr auto num_points = 10;
constexpr auto sleep_msec = 1;
constexpr auto radius = 100.0f;
int main() {
const auto window_handle = FindWindow(nullptr, "osu!");
if (!window_handle) {
printf("FATAL: Could not find osu!. (0x%X)\n", GetLastError());
return -1;
}
auto get_desired_pos = [&]() -> std::tuple<int, int> {
static auto counter = 0;
counter++;
RECT rect;
GetWindowRect(window_handle, &rect);
const auto center_x = rect.left + (rect.right - rect.left) / 2;
const auto center_y = rect.top + (rect.bottom - rect.top) / 2;
const auto angle = 3.1415926f * 2.0f * (float)counter / (float)num_points;
if (counter > num_points) {
counter = 0;
}
return { center_x + radius * sin(angle), center_y + radius * cos(angle) };
};
while (!GetAsyncKeyState(VK_DELETE)) {
if (GetAsyncKeyState('P')) {
std::apply(SetCursorPos, get_desired_pos());
}
Sleep(sleep_msec);
}
}