ScriptSpot

Forum topic · General Scripting

Primary screen width & height - DOTnet

By Matyrix · 2011-08-06

Description

Hello,

I tried to align my rollout to the center of the screen. First of all i tried to get the screen resolution by maxscript:

sysInfo.desktopSize

The problem is that it shows us the full resolution of all monitors, but i need just the primary screen resolution.

There is a nice DOTnet function for it: "Screen.PrimaryScreen.Bounds.Width" & "Screen.PrimaryScreen.Bounds.Height".
My problem is: How can i use it in maxscript? I tried it on this way:

 local screenWidth = dotNetObject "Screen.PrimaryScreen.Bounds.Width" 

...but don't works.

Comments (3)

Matyrix · 2011-08-06

I couldn't solve this so big thanks for the answer! :)

Anubis · 2011-08-06

freeVBcode is very useful site but what is missed in that function is the parent name space (System.Windows.Forms). i know you solve this but lets post this for the others ;)

fn ScreenResolution = (
	local scr = dotNetClass "System.Windows.Forms.Screen"
	[scr.PrimaryScreen.Bounds.Width, scr.PrimaryScreen.Bounds.Height]
)
--OR...
fn ScreenResolution = (
	local scr = (dotNetClass "System.Windows.Forms.Screen").PrimaryScreen.Bounds
	[scr.Width, scr.Height]
)