PHPackages                             kingbes/phprobot - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kingbes/phprobot

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kingbes/phprobot
================

Desktop automation for PHP Windows

v0.0.4(1y ago)17153[2 issues](https://github.com/KingBes/php-windows-robot/issues)Apache-2.0VPHP &gt;=8.1.0

Since Jun 21Pushed 1y ago2 watchersCompare

[ Source](https://github.com/KingBes/php-windows-robot)[ Packagist](https://packagist.org/packages/kingbes/phprobot)[ RSS](/packages/kingbes-phprobot/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)DependenciesVersions (5)Used By (0)

php-windows-robot
=================

[](#php-windows-robot)

PHP Windows的桌面自动化

composer

```
composer require kingbes/phprobot
```

要求
==

[](#要求)

php `>=8.1.0`

拓展 `FFI`

系统 `Windows`

文档
==

[](#文档)

鼠标
--

[](#鼠标)

```
use KingBes\PhpRobot\Mouse;

$Mouse = new Mouse();
```

```
/**
 * 鼠标指针位置 function
 *
 * @return array
 */
public function mouse_pos(): array
{}

/**
 * 鼠标单击 function
 *
 * @param string $button left right middle
 * @return self
 */
public function mouse_click(string $button): self
{}

/**
 * 鼠标双击 function
 *
 * @param string $button left right middle
 * @return self
 */
public function mouse_double_click(string $button): self
{}

/**
 * 将鼠标(左)拖动到指定位置。 function
 *
 * @param integer $x
 * @param integer $y
 * @return self
 */
public function mouse_left_drag(int $x, int $y): self
{}

/**
 * 相对于当前位置拖动鼠标(左)。 function
 *
 * @param integer $offset_x
 * @param integer $offset_y
 * @return self
 */
public function mouse_drag_rel(int $offset_x, int $offset_y): self
{}

/**
 * 移动鼠标到 x y function
 *
 * @param integer $x
 * @param integer $y
 * @return self
 */
public function mouse_move_mouse(int $x, int $y): self
{}

/**
 * 相对于当前位置移动鼠标。 function
 *
 * @param integer $offset_x
 * @param integer $offset_y
 * @return self
 */
public function move_mouse_rel(int $offset_x, int $offset_y): self
{}

/**
 * 鼠标平滑移动指定位置 function
 *
 * @param integer $x
 * @param integer $y
 * @param integer $duration_ms 毫秒
 * @param string $tween 预览补间 参数请看下面 `预览补间` 说明
 * @return self
 */
public function move_mouse_smooth(int $x, int $y, int $duration_ms, string $tween): self
{}

/**
 * 当前平滑移动鼠标 function
 *
 * @param integer $offset_x
 * @param integer $offset_y
 * @param integer $duration_ms 毫秒
 * @param string $tween 预览补间 参数请看下面 `预览补间` 说明
 * @return self
 */
public function move_mouse_smooth_rel(int $offset_x, int $offset_y, int $duration_ms, string $tween): self
{}

/**
 * 鼠标按下 function
 *
 * @param string $button left right middle
 * @return self
 */
public function mouse_down(string $button): self
{}

/**
 * 鼠标弹起 function
 *
 * @param string $button left right middle
 * @return self
 */
public function mouse_up(string $button): self
{}
```

屏幕
--

[](#屏幕)

```
use KingBes\PhpRobot\Screen;

$Screen = new Screen();
```

```
/**
 * 获取屏幕指定位置的颜色rgb function
 *
 * @param integer $x
 * @param integer $y
 * @return array
 */
public function pixel_color(int $x, int $y): array
{}

/**
 * 获取屏幕大小 function
 *
 * @return array
 */
public function screen_size(): array
{}
```

键盘
--

[](#键盘)

```
use KingBes\PhpRobot\Keyboard;

$Keyboard = new Keyboard;
```

```
/**
 * 是否点击键盘某键 function
 *
 * @param integer $key 整数键码值
 * @return boolean
 */
public function isKeyPressed(int $key): bool
{}

/**
 * 点击键盘某键 function
 *
 * @param integer $key 整数键码值
 * @return void
 */
public function onClickKey(int $key): void
{}

/**
 * 按下键盘某键 function
 *
 * @param integer $key
 * @return self
 */
public function pressKey(int $key): self
{}

/**
 * 弹起键盘某键 function
 *
 * @param integer $key
 * @return self
 */
public function releaseKey(int $key): self
{}
```

实例一 `获取当前鼠标位置`
==============

[](#实例一-获取当前鼠标位置)

```
// 引入
use KingBes\PhpRobot\Mouse;

// 实例
$Mouse = new Mouse();
// 获取鼠标当前指针位置
$pos = $Mouse->mouse_pos();

var_dump($pos);
```

实例一点二 `鼠标按下和弹起`
===============

[](#实例一点二--鼠标按下和弹起)

```
// 引入
use KingBes\PhpRobot\Mouse;

sleep(3);// 等待
// 按下 左键
$Mouse->mouse_down("left");

sleep(3);// 等待
// 弹起 左键
$Mouse->mouse_up("left");
```

实例二 `监听键盘A键`
============

[](#实例二-监听键盘a键)

```
use KingBes\PhpRobot\Keyboard;

$Keyboard = new Keyboard;

while (true) {
    if ($Keyboard->isKeyPressed(65)) {
        echo "点击了键盘A \n";
    }
    usleep(100); // 减轻负担
}
```

实例三 `按下键盘A键`
============

[](#实例三-按下键盘a键)

```
use KingBes\PhpRobot\Keyboard;

$Keyboard = new Keyboard;

sleep(5); //延迟5秒

$Keyboard->onClickKey(65)
```

实例三点二 `按下和弹起键盘某键`
=================

[](#实例三点二-按下和弹起键盘某键)

```
use KingBes\PhpRobot\Keyboard;

$Keyboard = new Keyboard;

sleep(3);// 等待
// 按下
$Keyboard->pressKey(65);

sleep(3);// 等待
// 弹起
$Keyboard->releaseKey(65);
```

预览补间 `可用的鼠标补间`
==============

[](#预览补间-可用的鼠标补间)

你可以在这里预览补间:

- `linear`
- `ease_in_quad`
- `ease_out_quad`
- `ease_in_out_quad`
- `ease_in_cubic`
- `ease_out_cubic`
- `ease_in_out_cubic`
- `ease_in_quart`
- `ease_out_quart`
- `ease_in_out_quart`
- `ease_in_quint`
- `ease_out_quint`
- `ease_in_out_quint`
- `ease_in_sine`
- `ease_out_sine`
- `ease_in_out_sine`
- `ease_in_expo`
- `ease_out_expo`
- `ease_in_out_expo`
- `ease_in_circ`
- `ease_out_circ`
- `ease_in_out_circ`
- `ease_in_elastic`
- `ease_out_elastic`
- `ease_in_out_elastic`
- `ease_in_back`
- `ease_out_back`
- `ease_in_out_back`
- `ease_in_bounce`
- `ease_out_bounce`
- `ease_in_out_bounce`

键盘的整数键码值
========

[](#键盘的整数键码值)

在 Windows 操作系统中，键盘上的一些按键对应着特定的整数键码值（keyCode）。以下是一些常见的 win 键盘按键及其对应的十进制数字：

- **字母和数字键**：
    - `a`：65
    - `b`：66
    - `c`：67
    - `d`：68
    - `e`：69
    - `f`：70
    - `g`：71
    - `h`：72
    - `i`：73
    - `j`：74
    - `k`：75
    - `l`：76
    - `m`：77
    - `n`：78
    - `o`：79
    - `p`：80
    - `q`：81
    - `r`：82
    - `s`：83
    - `t`：84
    - `u`：85
    - `v`：86
    - `w`：87
    - `x`：88
    - `y`：89
    - `z`：90
    - `0`：48
    - `1`：49
    - `2`：50
    - `3`：51
    - `4`：52
    - `5`：53
    - `6`：54
    - `7`：55
    - `8`：56
    - `9`：57
- **控制键**：
    - `Backspace`：8
    - `Tab`：9
    - `Clear`：12
    - `Enter`：13
    - `Shift`：16
    - `Control`：17
    - `Alt`：18
    - `Caps Lock`：20
    - `Esc`：27
    - `Spacebar`：32
    - `Page Up`：33
    - `Page Down`：34
    - `End`：35
    - `Home`：36
    - `Left Arrow`：37
    - `Up Arrow`：38
    - `Right Arrow`：39
    - `Down Arrow`：40
    - `Insert`：45
    - `Delete`：46
    - `Num Lock`：144
- **数字键盘上的键**：
    - `0`：96
    - `1`：97
    - `2`：98
    - `3`：99
    - `4`：100
    - `5`：101
    - `6`：102
    - `7`：103
    - `8`：104
    - `9`：105
    - `*`：106
    - `+`：107
    - `Enter`：108
    - `-`：109
    - `.`：110
    - `/`：111
- **其他键**：
    - `Left Windows 键`：91
    - `Right Windows 键`：92
    - `Applications 键`（右 Ctrl 左边键，点击相当于点击鼠标右键，会弹出快捷菜单）：93

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~15 days

Total

4

Last Release

645d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fb58545c720c65fc3a128dec9077ca1e63c7de006c8ffa6f2041636ad94d1d74?d=identicon)[KingBes](/maintainers/KingBes)

---

Top Contributors

[![KingBes](https://avatars.githubusercontent.com/u/48203677?v=4)](https://github.com/KingBes "KingBes (9 commits)")

---

Tags

phpwindowsDesktop automation

### Embed Badge

![Health badge](/badges/kingbes-phprobot/health.svg)

```
[![Health](https://phpackages.com/badges/kingbes-phprobot/health.svg)](https://phpackages.com/packages/kingbes-phprobot)
```

###  Alternatives

[jolicode/php-os-helper

Helpers to detect the OS of the machine where PHP is running.

212.8M4](/packages/jolicode-php-os-helper)[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
