Window titles and windowlist visible matching
This commit is contained in:
@ -26,11 +26,6 @@ class Window
|
||||
foreach ($output as $line) {
|
||||
if (preg_match('/^(.+?): (.+?)$/', trim($line), $match)) {
|
||||
switch ($match[1]) {
|
||||
case 'xwininfo':
|
||||
if (preg_match('/Window id: .+? "(.+?)"/', $match[2], $m)) {
|
||||
$this->windowTitle = $m[1];
|
||||
}
|
||||
break;
|
||||
case 'Map State':
|
||||
$this->isVisible = ($match[2]=='IsViewable');
|
||||
break;
|
||||
@ -54,16 +49,20 @@ class Window
|
||||
|
||||
public function getWindowTitle()
|
||||
{
|
||||
return $this->windowTitle;
|
||||
return trim(exec("xdotool getwindowname {$this->windowId}"));
|
||||
}
|
||||
|
||||
public function sendKeys($keys, $forceFocus=false)
|
||||
public function setWindowTitle($title)
|
||||
{
|
||||
if ($forceFocus) {
|
||||
$this->focus();
|
||||
$cmdl = sprintf("xdotool key %s", $keys);
|
||||
} else {
|
||||
exec("xdotool set_window --name ".escapeshellarg($title)." {$this->windowId}");
|
||||
}
|
||||
|
||||
public function sendKeys($keys, $forceWindow=false)
|
||||
{
|
||||
if ($forceWindow) {
|
||||
$cmdl = sprintf("xdotool key --delay 100 --window %d %s", $this->windowId, $keys);
|
||||
} else {
|
||||
$cmdl = sprintf("xdotool key %s", $keys);
|
||||
}
|
||||
echo "$ {$cmdl}\n";
|
||||
exec($cmdl);
|
||||
|
@ -63,11 +63,12 @@ class WindowList implements IteratorAggregate, Countable
|
||||
|
||||
}
|
||||
|
||||
public function visible()
|
||||
public function visible($match=true)
|
||||
{
|
||||
$found = [];
|
||||
$match = (bool)$match;
|
||||
foreach ($this->windows as $window) {
|
||||
if ($window->isVisible())
|
||||
if ($window->isVisible() == $match)
|
||||
$found[] = $window;
|
||||
}
|
||||
return new WindowList($found);
|
||||
|
Reference in New Issue
Block a user