php-x11/examples/find_windows.php

29 lines
662 B
PHP
Raw Normal View History

2016-12-26 19:54:28 +00:00
<?php
require_once __DIR__."/../vendor/autoload.php";
use NoccyLabs\X11\WindowList;
// Create a list of all windows
$windows = new WindowList();
$windows->dump();
// Select only visible windows
$visible = $windows->visible();
$visible->dump();
2016-12-26 19:54:28 +00:00
// Select all the windows with a title matching *code*
$codewindows = $visible->find("*code*");
if (count($codewindows)==0) {
printf("Sorry, couldn't find any vscode instances running!\n");
exit;
}
$codewindows->dump();
2016-12-26 19:54:28 +00:00
// Grab the first window
$codewindow = $codewindows->first();
$codewindow->dump();
2016-12-26 19:54:28 +00:00
// Focus the window and simulate F1 being pressed
$codewindow->focus()->activate()->sendKeys("F1");