Last active
November 4, 2015 22:09
-
-
Save StepMaher/7fe310e7d8cc9cc2de0b to your computer and use it in GitHub Desktop.
Get X and Y dimensions of all screens. Note: This works once per GH instance.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Get X and Y dimensions of all screens. Note: This works once per GH instance. | |
Outputs: | |
Rights: Width. | |
Bottoms: Height. | |
Names: Monitor displays. | |
""" | |
# Name component | |
ghenv.Component.Name = "Get All Screen Dimensions" | |
ghenv.Component.NickName = 'Get Screens' | |
# Import libraries | |
import clr | |
clr.AddReference("System.Windows.Forms") | |
from System.Windows.Forms import Screen | |
import System.Windows.Forms | |
# Create output lists | |
Rights = [] | |
Bottoms = [] | |
Names = [] | |
# Access screen dimensions and add to output lists | |
screens = Screen.AllScreens | |
for screen in screens: | |
control = System.Windows.Forms.Control() | |
graphics = control.CreateGraphics() | |
mult = (float(graphics.DpiX) / 96) | |
Rights.append(screen.Bounds.Right / mult) | |
Bottoms.append(screen.Bounds.Bottom / mult) | |
Names.append(str(screen.DeviceName)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment