Skip to content

7snDev/Atomy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Atomy

A Desktop Automation Library in C++ (Linux/Windows)

The Atomy library provides simple mouse, keyboard, screen control, and screenshot functionality through a single header file.

Quick Usage

  1. Place the atomy.hpp file in your project.
  2. Add the following line to your code:
#include "atomy.hpp"
  1. Use the functions directly from the Atomy namespace.

Mouse Functions

Move the Mouse

Atomy::Mouse::moveMouseTo(x, y); // Moves the cursor to coordinates (x, y)

Mouse Button Press

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 button

Get Mouse Position

int x, y;
Atomy::Mouse::getMousePosition(x, y);

Scroll the Mouse

Atomy::Mouse::scrollMouse(1);   // Scroll up
Atomy::Mouse::scrollMouse(-1);  // Scroll down

Check Mouse Button State

if (Atomy::Mouse::isMouseButtonPressed(Atomy::Mouse::LeftButton)) {
    // Left button is currently pressed
}

Keyboard Functions

Using keyboard functions can be a bit tricky, as you must pass platform-specific key codes. On Linux, use `XK`; on Windows, use `VK`.

KeyDown

Linux:

Atomy::Keyboard::keyDown(XK_Return);

Windows:

Atomy::Keyboard::keyDown(VK_Return);

Available Keyboard Functions

  • keyDown
  • keyUp
  • keyPress
  • isKeyPressed

You can use all of them under the Atomy::Keyboard namespace.


Screen Functions

Get Screen Size

int width, height;
Atomy::Monitor::getScreenSize(width, height);

Take a Screenshot

Atomy::Monitor::takeScreenshot("screenshot.png");

General Functions

Sleep

Atomy::General::sleep(500, "ms"); // Wait for 500 milliseconds
Atomy::General::sleep(2, "s");    // Wait for 2 seconds

Notes

  • The library supports both Linux and Windows out of the box.
  • On Linux, you must link against X11 and Xtst (-lX11 -lXtst).
  • Some functions may require elevated permissions depending on the system.

Full Example

#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;
}

License

The library is free and open-source, available under the MIT license.

About

Automation Library Support Windows & Linux

Topics

Resources

License

Stars

Watchers

Forks