PHP code example of joetannenbaum / php-mac-automator
1. Go to this page and download the library: Download joetannenbaum/php-mac-automator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
joetannenbaum / php-mac-automator example snippets
use Automator\Automator;
$automator = new Automator();
// Open Warp terminal and list the files in the current directory
$automator->open('Warp')->typeAndEnter('ls')->run();
// or
Automator::make()->open('Warp')->typeAndEnter('ls')->run();
$automator->open('Warp');
$automator->type('Hello World');
$automator->typeAndEnter('Hello World');
// With modifier keys (e.g. zoom in)
$automator->withCommand('+');
$automator->withShift('+');
$automator->withOption('+');
$automator->withControl('+');
// With multiple modifier keys (e.g. re-open last tab)
$automator->type('t', [Modifier::COMMAND, Modifier::SHIFT]);
// Helpers
$automator->enter();
$automator->tab();
$automator->backspace();
$automator->delete();
$automator->escape();
$automator->space();
$automator->arrowUp();
$automator->arrowDown();
$automator->arrowLeft();
$automator->arrowRight();
$automator->home();
$automator->end();
$automator->pageUp();
$automator->pageDown();
// Add modifer(s) to helper
$automator->enter(Modifier::SHIFT);
$automator->enter([Modifier::COMMAND, Modifier::SHIFT]);
// Set the typing speed
// 0.1 seconds between each character (default is 0.05)
$automator->setTypingSpeed(0.1);
// Open an app
$automator->open('Warp');
// Pause (seconds)
$automator->pause(1);
// Repeat a block of code (e.g. zoom in five times)
$automator->repeat(
5,
fn (Automator $remote) => $remote->typeWithCommand('+')->pause(.05),
);
Automator::make()
->setTypingSpeed(.1)
->open('Visual Studio Code')
->pause(1)
->type('n', [Modifier::SHIFT, Modifier::COMMAND]) // Open a new window
->pause(.5)
->typeWithCommand('n') // Open a new file
->pause(.5)
->type('')
->pause(.5)
->repeat(2, fn (Automator $remote) => $remote->enter()->pause(.25))
->type('echo "Hello World!";')
->run();
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.