arnaudbablon / systemctl
提供PHP抽象类以与系统交互(截图、复制、粘贴、点击)
dev-master
2019-02-18 11:27 UTC
Requires
- php: ^7.1
- psr/container: ^1.0
- symfony/process: 4.2.*
This package is auto-updated.
Last update: 2024-09-18 23:34:35 UTC
README
PHP包装器,允许执行基本系统操作,如截图、点击...(已在debian 9 / php 7.2上测试)
要求
- xdotool
- xclip
- shutter
如何安装
$ apt-get install xdotool xclip shutter $ composer require arnaudbablon/systemctl dev-master
当前支持的操作
- 点击(左键/右键)
- 复制(ctrl+c)
- 粘贴(ctrl+v)
- 设置剪贴板
- 按键
- 截图
- 滚动
- 终止程序
- 运行程序
我开发这个库是为了个人用途,并将根据我的需求更新操作。
如何使用
$actions = [ new ClickAction(), new CopyAction(), new PasteAction(), new ClipboardAction(), new ScrollAction(), new ScreenShotAction(), new KeyAction(), new KillallAction(), new RunAction() ]; $container = new ActionContainer($actions); $application = new Application($container); application->clipboard('use ctrl+v to see the result'); application->click(x, y); //left click application->click(x, y, false); //right click application->paste(); application->screenshot('/path/name.png'); application->key('KP_Enter'); $application->run('google-chrome > /dev/null 2>&1 &'); $application->sleep(4); $application->killall('chrome');
与symfony集成(可选)
#config/services.yaml ... imports: - { resource: '../vendor/arnaudbablon/systemctl/Resource/config/services.yaml' }
现在可以正常注入Application类,而不需要实例化任何操作。