PHP桌面自动化拓展分享
php-windows-robot
PHP Windows的桌面自动化
最新内容-> GITHUB
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
{}
屏幕
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
{}
实例一 获取当前鼠标位置
// 引入
use KingBes\PhpRobot\Mouse;
// 实例
$Mouse = new Mouse();
// 获取鼠标当前指针位置
$pos = $Mouse->mouse_pos();
var_dump($pos);
实例二 监听键盘A键
use KingBes\PhpRobot\Keyboard;
$Keyboard = new Keyboard;
while (true) {
if ($Keyboard->isKeyPressed(65)) {
echo "点击了键盘A \n";
}
usleep(100); // 减轻负担
}
实例三 按下键盘A键
use KingBes\PhpRobot\Keyboard;
$Keyboard = new Keyboard;
sleep(5); //延迟5秒
$Keyboard->onClickKey(65)
键盘的整数键码值
在 Windows 操作系统中,键盘上的一些按键对应着特定的整数键码值(keyCode)。以下是一些常见的 win 键盘按键及其对应的十进制数字:
- 字母和数字键:
a
:65b
:66c
:67d
:68e
:69f
:70g
:71h
:72i
:73j
:74k
:75l
:76m
:77n
:78o
:79p
:80q
:81r
:82s
:83t
:84u
:85v
:86w
:87x
:88y
:89z
:900
:481
:492
:503
:514
:525
:536
:547
:558
:569
:57
- 控制键:
Backspace
:8Tab
:9Clear
:12Enter
:13Shift
:16Control
:17Alt
:18Caps Lock
:20Esc
:27Spacebar
:32Page Up
:33Page Down
:34End
:35Home
:36Left Arrow
:37Up Arrow
:38Right Arrow
:39Down Arrow
:40Insert
:45Delete
:46Num Lock
:144
- 数字键盘上的键:
0
:961
:972
:983
:994
:1005
:1016
:1027
:1038
:1049
:105*
:106+
:107Enter
:108-
:109.
:110/
:111
- 其他键:
Left Windows 键
:91Right Windows 键
:92Applications 键
(右 Ctrl 左边键,点击相当于点击鼠标右键,会弹出快捷菜单):93
本作品采用《CC 协议》,转载必须注明作者和本文链接
这个可以用来做测试吗 测试 web网站是否正常这样子
工作:招聘远程全职前端,硬性要求,必须有uniapp跨端开发经验。 前端uniapp远程工作哦,欢迎来
你还是都用驼峰命名吧 php用下划线 c/c++用驼峰 倒反天罡了