Notifications
Clear all

[Closed] DotNet getting screen info

Hi Mans

I write a function for getting screens info. My can be useful for someone

struct SCREENS_DATA
(
scr = (dotNetClass “System.Windows.Forms.Screen”),
fn count = (scr.AllScreens.count),
fn name num:1 = (scr.AllScreens[num].DeviceName),
fn size num:1 =
(
local all_scr = scr.AllScreens
if all_scr.count < num do return false
[all_scr[num].Bounds.Width, all_scr[num].Bounds.Height]
),
fn fullSize =
(
local size = [0, 0]
for s in scr.AllScreens do size += [s.Bounds.Width, s.Bounds.Height]
return size
)
)

my_screens = SCREENS_DATA()

my_screens.count()
my_screens.name num:2
my_screens.size num:1
my_screens.size num:2
my_screens.fullSize()

ps:also I’m searching to track which monitor is focused, if you know please let me know

have a nice day

4 Replies

ok found it , here is it


struct mcSCREENS_DATA --NEED a INSTANCE
(
	scr = (dotNetClass "System.Windows.Forms.Screen"),	
	fn count = (scr.AllScreens.count),
	fn name num:1 = (scr.AllScreens[num].DeviceName),
	fn size num:1 = 
	(
		if scr.AllScreens.count < num do return false
		[scr.AllScreens[num].Bounds.Width, scr.AllScreens[num].Bounds.Height]
	),
	fn fullSize = 
	(
		local size = [0, 0]
		for s in scr.AllScreens do size += [s.Bounds.Width, s.Bounds.Height]
		return size
	),
	fn active =
	(
		local p = dotnetObject "Drawing.Point" mouse.screenpos.x mouse.screenpos.y
		for i=1 to scr.AllScreens.count where scr.AllScreens[i] == (scr.FromPoint p) do return i
		--(scr.FromPoint p).DeviceName
	),
	fn pos num:1 = 
	(
		if scr.AllScreens.count < num do return false
		[scr.AllScreens[num].Bounds.x, scr.AllScreens[num].Bounds.y]
	)
 )
 
my_screens = mcSCREENS_DATA()
 
my_screens.count()
my_screens.name num:2
my_screens.size num:1
my_screens.size num:2
my_screens.fullSize()
my_screens.active()

Maybe a stupid question but what does the [] does envolving the last line on the functions of the struct? I’ve only used [] when calling array stuff.

2 Replies
(@merlinel)
Joined: 11 months ago

Posts: 0

Hi Kameleon

Maybe I’m stupid to I’m not realy understand you question My english is not very good,
try write it with an example…

(@pixel_monkey)
Joined: 11 months ago

Posts: 0

It is returning a point2 value for the screen position, if I understand you correctly. Point values are returned in [<expr>.,<expr>] format.

-Eric