Getting Monitor Specs rates

Asked by Tim Tindell

I am creating programs that run on dual monitor systems. They are for geospatial imaging. One of the monitors is 60 hz and the other is 75. I want to know if there is a function or a way to get the refresh rates of the monitors and set each to different screen regions.

NOTE: I can't change the primary windows screen to always be one or the other. I need to be able to differentiate between the two monitors by there refresh rates.

Please let me know if there is any way to do this.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

Have a look at the Java AWT Robot class and the device specific classes around it.

You can use them in Sikuli scripts easily and anyway in Java programs.

Revision history for this message
Tim Tindell (tim-tindell) said :
#2

Thanks RaiMan, that solved my question.

Revision history for this message
Tim Tindell (tim-tindell) said :
#3

So I didn't use Robot. That didn't seem to have what I wanted. I used DisplayMode,GraphicsDevice, and GraphicsEnvironment to get the job done. I wrote it in a definition to be called later. Take a look:

import java.awt.DisplayMode, java.awt.GraphicsDevice, java.awt.GraphicsEnvironment
def getPrimDispAndRef():
    ge=java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment( )
    gs=[ ]
    scr=[ ]
    ref=[ ]
    gs =ge.getScreenDevices()
    a=java.awt.DisplayMode
    for x in range(len(gs)):
        gd=gs[x]
        gw=gd.getIDstring()
        #print gw
        prefix, number = gw.split('y')
        #print number
        d=gd.getDisplayMode()
        num=d.getRefreshRate()
        ref.append(num)
        #print ref
        if number=="0":
            Disp="Primary"
            scr.append(Disp)
        else:
            Disp="Secondary"
            scr.append(Disp)
        print scr[x] + " screen is running at " + repr(ref[x]) + " hz"
    return scr,ref
#It returns two arrays with the displays in one, and the refresh rate in the other.

Revision history for this message
RaiMan (raimund-hocke) said :
#4

Exactly :-) Well done :-)

BTW: that's what I meant with "... and the device specific classes around it"