Implement --exec flag and PyAutoGUI-compatible automation API
- Add --exec flag to execute multiple scripts before main program - Scripts are executed in order and share Python interpreter state - Implement full PyAutoGUI-compatible automation API in McRFPy_Automation - Add screenshot, mouse control, keyboard input capabilities - Fix Python initialization issues when multiple scripts are loaded - Update CommandLineParser to handle --exec with proper sys.argv management - Add comprehensive examples and documentation This enables automation testing by allowing test scripts to run alongside games using the same Python environment. The automation API provides event injection into the SFML render loop for UI testing. Closes #32 partially (Python interpreter emulation) References automation testing requirements
This commit is contained in:
parent
763fa201f0
commit
68c1a016b0
15 changed files with 1896 additions and 90 deletions
56
src/McRFPy_Automation.h
Normal file
56
src/McRFPy_Automation.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#pragma once
|
||||
#include "Common.h"
|
||||
#include "Python.h"
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <SFML/Window.hpp>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
class GameEngine;
|
||||
|
||||
class McRFPy_Automation {
|
||||
public:
|
||||
// Initialize the automation submodule
|
||||
static PyObject* init_automation_module();
|
||||
|
||||
// Screenshot functionality
|
||||
static PyObject* _screenshot(PyObject* self, PyObject* args);
|
||||
|
||||
// Mouse position and screen info
|
||||
static PyObject* _position(PyObject* self, PyObject* args);
|
||||
static PyObject* _size(PyObject* self, PyObject* args);
|
||||
static PyObject* _onScreen(PyObject* self, PyObject* args);
|
||||
|
||||
// Mouse movement
|
||||
static PyObject* _moveTo(PyObject* self, PyObject* args, PyObject* kwargs);
|
||||
static PyObject* _moveRel(PyObject* self, PyObject* args, PyObject* kwargs);
|
||||
static PyObject* _dragTo(PyObject* self, PyObject* args, PyObject* kwargs);
|
||||
static PyObject* _dragRel(PyObject* self, PyObject* args, PyObject* kwargs);
|
||||
|
||||
// Mouse clicks
|
||||
static PyObject* _click(PyObject* self, PyObject* args, PyObject* kwargs);
|
||||
static PyObject* _rightClick(PyObject* self, PyObject* args, PyObject* kwargs);
|
||||
static PyObject* _middleClick(PyObject* self, PyObject* args, PyObject* kwargs);
|
||||
static PyObject* _doubleClick(PyObject* self, PyObject* args, PyObject* kwargs);
|
||||
static PyObject* _tripleClick(PyObject* self, PyObject* args, PyObject* kwargs);
|
||||
static PyObject* _scroll(PyObject* self, PyObject* args, PyObject* kwargs);
|
||||
static PyObject* _mouseDown(PyObject* self, PyObject* args, PyObject* kwargs);
|
||||
static PyObject* _mouseUp(PyObject* self, PyObject* args, PyObject* kwargs);
|
||||
|
||||
// Keyboard
|
||||
static PyObject* _typewrite(PyObject* self, PyObject* args, PyObject* kwargs);
|
||||
static PyObject* _hotkey(PyObject* self, PyObject* args);
|
||||
static PyObject* _keyDown(PyObject* self, PyObject* args);
|
||||
static PyObject* _keyUp(PyObject* self, PyObject* args);
|
||||
|
||||
// Helper functions
|
||||
static void injectMouseEvent(sf::Event::EventType type, int x, int y, sf::Mouse::Button button = sf::Mouse::Left);
|
||||
static void injectKeyEvent(sf::Event::EventType type, sf::Keyboard::Key key);
|
||||
static void injectTextEvent(sf::Uint32 unicode);
|
||||
static sf::Keyboard::Key stringToKey(const std::string& keyName);
|
||||
static void sleep_ms(int milliseconds);
|
||||
|
||||
private:
|
||||
static GameEngine* getGameEngine();
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue