Debian Codegraph @

eg/FindWindowLike.pl

raw
1 #!/usr/bin/perl
2 #-----------------------------------------------------------------------------#
3 # X11::GUITest ($Id: FindWindowLike.pl 203 2011-05-15 02:03:11Z ctrondlp $)
4 # Notes: Example usage of FindWindowLike
5 #-----------------------------------------------------------------------------#
6
7 ## Pragmas/Directives/Diagnostics ##
8 use strict;
9 use warnings;
10
11 ## Imports (use [MODULE] qw/[IMPORTLIST]/;) ##
12 use X11::GUITest qw/
13 FindWindowLike
14 GetWindowName
15 /;
16
17 ## Constants (sub [CONSTANT]() { [VALUE]; }) ##
18
19 ## Variables (my [SIGIL][VARIABLE] = [INITIALVALUE];) ##
20 my @wins = ();
21
22 ## Core ##
23 print "$0 : Script Start\n";
24
25 # Get list of Ids for all windows
26 # (RegExp: .* = zero or more characters, so it will pick up on nameless windows also)
27 @wins = FindWindowLike('.*') or die("Didn't find any windows!");
28
29 # Alternatively, one may use the following syntax in a script if there is
30 # interest in a specific window:
31 # my ($win) = FindWindowLike('My Window');
32
33 print "FindWindowLike found " . @wins . " window(s).\n";
34
35 print "Press <Enter> to display a list of these window(s).";
36 readline(*STDIN);
37
38 # Output a little information for each window
39 foreach my $win (@wins) {
40 my $name = GetWindowName($win) || '[NO NAME]';
41 print "\t" . sprintf("0x%X", $win) . " ($name)\n";
42 }
43
44
45 print "$0 : Script End (Success)\n";
46
47 ## Subroutines ##