X11: Launch the application



examples/X/xcalc01.pl
#!/usr/bin/perl

use strict;
use warnings;

use X11::GUITest qw(:ALL);

StartApp('xcalc');

my ($Main) = WaitWindowViewable('Calculator');
if (!$Main) {
  die("Couldn't find xcalc window in time!");
}
print "Main: $Main\n";

my $Focus = GetInputFocus();
print "Focus: $Focus\n";

if ($Focus != $Main) {
   die "The focus is not on the main window or you have two xcalcs open\n";
}

perl examples/X/xcalc01.pl As you can see we only open the xcalc window and do not close it yet. So now if you run this for a second time (without manually closing the first xcalc window) you will see the error message and you'll see that the Main windows id is the same as previously as the first windows was found first but the Focus is on another window, the one we have just opened.