The Atomy library provides simple mouse, keyboard, screen control, and screenshot functionality through a single header file.
- Place the
atomy.hppfile in your project. - Add the following line to your code:
#include "atomy.hpp"- Use the functions directly from the
Atomynamespace.
Atomy::Mouse::moveMouseTo(x, y); // Moves the cursor to coordinates (x, y)Atomy::Mouse::mouseButtonDown(Atomy::LeftButton); // Press the left mouse button
Atomy::Mouse::mouseButtonUp(Atomy::Mouse::LeftButton); // Release the left mouse button
Atomy::Mouse::clickMouseButton(Atomy::Mouse::RightButton); // Click the right mouse buttonint x, y;
Atomy::Mouse::getMousePosition(x, y);Atomy::Mouse::scrollMouse(1); // Scroll up
Atomy::Mouse::scrollMouse(-1); // Scroll downif (Atomy::Mouse::isMouseButtonPressed(Atomy::Mouse::LeftButton)) {
// Left button is currently pressed
}Using keyboard functions can be a bit tricky, as you must pass platform-specific key codes. On Linux, use `XK`; on Windows, use `VK`.
Linux:
Atomy::Keyboard::keyDown(XK_Return);Windows:
Atomy::Keyboard::keyDown(VK_Return);keyDownkeyUpkeyPressisKeyPressed
You can use all of them under the Atomy::Keyboard namespace.
int width, height;
Atomy::Monitor::getScreenSize(width, height);Atomy::Monitor::takeScreenshot("screenshot.png");Atomy::General::sleep(500, "ms"); // Wait for 500 milliseconds
Atomy::General::sleep(2, "s"); // Wait for 2 seconds- The library supports both Linux and Windows out of the box.
- On Linux, you must link against
X11andXtst(-lX11 -lXtst). - Some functions may require elevated permissions depending on the system.
#include "atomy.hpp"
int main() {
Atomy::Mouse::moveMouseTo(100, 100);
Atomy::Mouse::clickMouseButton(Atomy::Mouse::MouseButton::LeftButton);
int x, y;
Atomy::Mouse::getMousePosition(x, y);
std::cout << "Mouse at: " << x << ", " << y << std::endl;
Atomy::General::sleep(1, "s");
Atomy::Monitor::takeScreenshot("shot.png");
return 0;
}The library is free and open-source, available under the MIT license.