-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathgui_checkgeo.pm
75 lines (61 loc) · 1.47 KB
/
gui_checkgeo.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package gui_checkgeo;
use strict;
my $monitors;
sub init{
require Win32::API;
require Win32::API::Callback;
Win32::API::Struct->typedef( RECT => qw{
LONG Left;
LONG Top;
LONG Right;
LONG Bottom; });
Win32::API::Struct->typedef( MONITORINFO => qw{
LONG cbSize;
RECT rcMonitor;
RECT rcWork;
LONG dwFlags; });
Win32::API->Import('User32', 'EnumDisplayMonitors', 'NPKN', 'N');
Win32::API->Import('User32', 'int GetMonitorInfoA (int hMonitor, LPMONITORINFO lpmi)');
my $MonitorEnumProc = Win32::API::Callback->new(
sub {
my( $hMonitor, $hdcMonitor, $lprcMonitor, $dwData) = @_;
my $MI = Win32::API::Struct->new('MONITORINFO');
my $R = Win32::API::Struct->new('RECT');
$MI->{cbSize} = 40;
GetMonitorInfoA ($hMonitor, $MI);
my $mon;
$mon->{l} = $MI->{rcMonitor}->{Left};
$mon->{r} = $MI->{rcMonitor}->{Right};
$mon->{t} = $MI->{rcMonitor}->{Top};
$mon->{b} = $MI->{rcMonitor}->{Bottom};
push @{$monitors}, $mon;
return 1;
},
"NNPN", "N",
);
EnumDisplayMonitors ( 0x0, 0x0, $MonitorEnumProc, 0x0 );
my $t = 'Monitors';
foreach my $i (@{$monitors}){
$t .= ": $i->{l}, $i->{r}, $i->{t}, $i->{b} ";
}
print "$t\n";
}
sub check{
my $x = shift;
my $y = shift;
&init unless $monitors;
my $r = 0;
foreach my $i (@{$monitors}){
if (
$x >= $i->{l}
&& $x <= $i->{r}
&& $y >= $i->{t}
&& $y <= $i->{b}
){
$r = 1;
last;
}
}
return $r;
}
1;