PDA

View Full Version : DotNet getting screen info


MerlinEl
03-23-2012, 01:07 PM
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 :cool:

MerlinEl
03-23-2012, 01:40 PM
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()

Kameleon
03-23-2012, 07:33 PM
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.

MerlinEl
03-23-2012, 09:30 PM
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.

Hi Kameleon (http://forums.cgsociety.org/member.php?u=109790) :-)

Maybe I'm stupid to :-D I'm not realy understand you question :-D My english is not very good,
try write it with an example...

PiXeL_MoNKeY
03-23-2012, 10:29 PM
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.It is returning a point2 value for the screen position, if I understand you correctly. Point (http://docs.autodesk.com/3DSMAX/14/ENU/MAXScript%20Help%202012/files/GUID-A2C25DDF-2FC1-456B-90C2-B91D98296C3-393.htm) values are returned in [<expr>.,<expr>] format.

-Eric

CGTalk Moderation
03-23-2012, 10:29 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.