2017 © Pedro PelĂĄez
 

library php-bot

A PHP library for creating automation robots

image

nawarian/php-bot

A PHP library for creating automation robots

  • Saturday, January 23, 2016
  • by nawarian
  • Repository
  • 4 Watchers
  • 8 Stars
  • 35 Installations
  • Tcl
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 17 % Grown

The README.md

PHPBot

A PHP library for creating automation robots

This project was made for fun, feel free to improve it :), (*1)

Getting Started: composer

Under your project's folder type: $ composer require nawarian/php-bot dev-master, (*2)

<?php
require_once 'vendor/autoload.php';

Then you are ready to go :D, (*3)

Dependencies

Linux

PHPBot works directly with X11, using xdotool to send commands. Further versions could add support to other devices as well., (*4)

Make it independent from xdotool would also be nice, projects like https://github.com/moriyoshi/php-Xlib are a great shot! But still excludes MS Windows implementations..., (*5)

Windows NT

PHPBot now can work with Windows NT platforms too. Is important to notice that: it uses compiled python files that access the User32.dll API. Because of that, some antivirus software might mark the files under ext/pyautogui/bin/dest folder as threads., (*6)

Also: the command pipeline funcionality has shown some bugs., (*7)

Samples

All commands alone returns a React\Promise\Promise, (*8)

Getting started

You must have a React\EventLoop\LoopInterface object:, (*9)

$loop = React\EventLoop\Factory::create();

// Our code goes here!

$loop->run();

Commands

As a command you can think of a interaction command, like a button pressing, mouse moving ou clicking..., (*10)

Notice that all commands will only run if: - The start() method is called - Is in a command pipeline, (*11)

Is important to also notice that command pipelines will start by the moment you create it., (*12)

Sending keyboard commands

$dm = PHPBot\DesktopManager\Factory::create($loop);
$dm->keyboard()->type('Soooo cool!')->start()->then(function() {
    // Remember, every command returns a Promise!
    echo 'Just wrote it, dude! ;)';
});

Sending pointer commands

$dm = PHPBot\DesktopManager\Factory::create($loop);
$dm->pointer()->moveTo(0, 0)->start()->then(function() {
    // Remember, every command returns a Promise!
    echo 'Guess where your mouse pointer is!';
});

Chaining commands!

$dm = PHPBot\DesktopManager\Factory::create($loop);
$dm->createCommandPipeline(
    $dm->keyboard()->type('Soooo cool!'),         // 1
    $dm->keyboard()->sendKey(Keys::ENTER()),      // 2
    $dm->pointer()->moveTo(200, 200),             // 3
    $dm->pointer()->click(MouseButtons::LEFT())   // 4
)
->start()
->then(function() {
    // This also returns a Promise, resolved when it all finishes
    echo 'DONE!';
});

1, 2, 3 and 4 will execute at this exaclty order!, (*13)

More samples

For more examples, check the examples/ folder out.

Thank you :), (*14)

The Versions

23/01 2016

dev-master

9999999-dev

A PHP library for creating automation robots

  Sources   Download

MIT

The Requires

 

by Nawarian NĂ­ckolas

php bot windows automation linux desktop x11 xlib