Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Read & show resolution and frequency of the screen.

If you have a question or need help, this is the place to be.
Post Reply
User avatar
FCB38
Experienced User
Posts: 50
Joined: Mon Nov 28, 2011 10:28 am

Read & show resolution and frequency of the screen.

Post by FCB38 »

Hello,

I want to know the frequency and the resolution of my screen using EventGhost. I just want to press a key and see an message via the OSD.
Some body know how I can do this? I don't find a function in EventGhost.

Can you help me please?

Regards.
User avatar
FCB38
Experienced User
Posts: 50
Joined: Mon Nov 28, 2011 10:28 am

Re: Read & show resolution and frequency of the screen.

Post by FCB38 »

Hello,

Nobody can help me?
Actually it's to choose the good parameters to see my movie via XBMC :
  • Bluray => 72Hz
  • DVD Pal => 50Hz
  • DVD NTSC => 60Hz
Perhaps there a solution to do this automatically but for the moment I think it's easier to choose the good fr├®quency manually.

Regards.
eatmeimadanish
Experienced User
Posts: 118
Joined: Thu Oct 01, 2009 5:11 pm

Re: Read & show resolution and frequency of the screen.

Post by eatmeimadanish »

Decompress the EG_DB_site-packages.zip from viewtopic.php?f=2&t=4005#p23194 to your sitepackages directory. (C:\Eventghost\lib26\site-packages\) then restart EG. Once this is done, create a python script with below. You can then just feed the variables to the screen anyway you want. I just print them to give you an example.

Hope that helps!

Code: Select all

import wmi
d = wmi.WMI ()
for s in d.Win32_DisplayConfiguration ():
    # If you want to see everything uncomment below
    # print s
    eg.globals.displaywidth = s.PelsWidth
    eg.globals.displayheight = s.PelsHeight
    eg.globals.displayfrq = s.DisplayFrequency
    eg.globals.displaypix = s.LogPixels
    eg.globals.displaybit = s.BitsPerPel
    eg.globals.displayname = s.Caption

print "Device: ",eg.globals.displayname
print "Resolution: ",eg.globals.displaywidth, "x", eg.globals.displayheight
print "Frequency: ",eg.globals.displayfrq
print "Pixel Density: ",eg.globals.displaypix
print "Color Depth: ",eg.globals.displaybit,"bit"
jonib
Plugin Developer
Posts: 1328
Joined: Thu Mar 26, 2009 9:33 pm
Location: Sweden

Re: Read & show resolution and frequency of the screen.

Post by jonib »

FCB38 wrote:Perhaps there a solution to do this automatically but for the moment I think it's easier to choose the good fr├®quency manually.
There is an option in XBMC for this here, it's called "Adjust display refresh rate to match video".

jonib
XBMC2 plugin to control XBMC. If you want to flatter me Image
User avatar
FCB38
Experienced User
Posts: 50
Joined: Mon Nov 28, 2011 10:28 am

Re: Read & show resolution and frequency of the screen.

Post by FCB38 »

Hello,

Thank you Eatmeimadanish & Jonib.
I've seen before the option in XBMC in the past but I forgot it. I will try.
I will try the solution of Eatmeimadanish. It can be useful to know if the screen really change his frequency.

Regards.
User avatar
FCB38
Experienced User
Posts: 50
Joined: Mon Nov 28, 2011 10:28 am

Re: Read & show resolution and frequency of the screen.

Post by FCB38 »

OK, I decompress the file "EG_DB_site-packages.zip" in my folder (C:\Logiciels\Utilitaires\EventGhost\lib26\site-packages).
I create the new python script at the begining of my XML file:

Code: Select all

    import wmi
    d = wmi.WMI ()
    for s in d.Win32_DisplayConfiguration ():
        # If you want to see everything uncomment below
        # print s
        eg.globals.displaywidth = s.PelsWidth
        eg.globals.displayheight = s.PelsHeight
        eg.globals.displayfrq = s.DisplayFrequency
        eg.globals.displaypix = s.LogPixels
        eg.globals.displaybit = s.BitsPerPel
        eg.globals.displayname = s.Caption

    print "Device: ",eg.globals.displayname
    print "Resolution: ",eg.globals.displaywidth, "x", eg.globals.displayheight
    print "Frequency: ",eg.globals.displayfrq
    print "Pixel Density: ",eg.globals.displaypix
    print "Color Depth: ",eg.globals.displaybit,"bit"
Now I can read this in the log file:

Code: Select all

   Device:  NVIDIA GeForce 8600 GT 
   Resolution:  1024 x 768
   Frequency:  60
   Pixel Density:  96
   Color Depth:  32 bit
How can I read this and put it in an OSD message?

Thank you for your help!
jonib
Plugin Developer
Posts: 1328
Joined: Thu Mar 26, 2009 9:33 pm
Location: Sweden

Re: Read & show resolution and frequency of the screen.

Post by jonib »

FCB38 wrote:How can I read this and put it in an OSD message?
Putting this in the ShowOSD {eg.globals.displaywidth} should show the displaywidth, just change it to one of the other eg.globals. for other data.

jonib
XBMC2 plugin to control XBMC. If you want to flatter me Image
User avatar
FCB38
Experienced User
Posts: 50
Joined: Mon Nov 28, 2011 10:28 am

Re: Read & show resolution and frequency of the screen.

Post by FCB38 »

It' me again. I've got a problem. I execute the script to show me information in the log file. But If I change resolution (after EventGhost starts), the script doesn't see the new values.
What's wrong? How can I repare it?

Can you help me?

Thank you.
User avatar
FCB38
Experienced User
Posts: 50
Joined: Mon Nov 28, 2011 10:28 am

Re: Read & show resolution and frequency of the screen.

Post by FCB38 »

jonib wrote:
FCB38 wrote:How can I read this and put it in an OSD message?
Putting this in the ShowOSD {eg.globals.displaywidth} should show the displaywidth, just change it to one of the other eg.globals. for other data.

jonib
Your command Jonib is functionning perfectly. Thank you for this.

I always got my problem of reading values for frequencies and r├®solution. The script given by eatmeimadanish seen to return always the same values.
I don't know where I have too put the script. For the moment I put it at the begening of my configuration tree with an other one:

Code: Select all

#Script "Minimize XBMC"
from win32gui import FindWindow, GetWindowPlacement
try:
    if (GetWindowPlacement(FindWindow('XBMC','XBMC'))[1] == 2):
        eg.result = True
    else:
        eg.result = False
except:
    pass

#Script "Read screen's state"
    import wmi
    d = wmi.WMI ()
    for s in d.Win32_DisplayConfiguration ():
        # If you want to see everything uncomment below
        # print s
        eg.globals.displaywidth = s.PelsWidth
        eg.globals.displayheight = s.PelsHeight
        eg.globals.displayfrq = s.DisplayFrequency
        eg.globals.displaypix = s.LogPixels
        eg.globals.displaybit = s.BitsPerPel
        eg.globals.displayname = s.Caption

    print "Device: ",eg.globals.displayname
    print "Resolution: ",eg.globals.displaywidth, "x", eg.globals.displayheight
    print "Frequency: ",eg.globals.displayfrq
    print "Pixel Density: ",eg.globals.displaypix
    print "Color Depth: ",eg.globals.displaybit,"bit"
One more time I need your help. THANK YOU!
eatmeimadanish
Experienced User
Posts: 118
Joined: Thu Oct 01, 2009 5:11 pm

Re: Read & show resolution and frequency of the screen.

Post by eatmeimadanish »

Code: Select all

import wmi
d = wmi.WMI ()
for s in d.Win32_VideoController ():
    # If you want to see everything uncomment below
    # print s
    eg.globals.displaywidth = s.CurentHorizontalResolution
    eg.globals.displayheight = s.CurrentVerticalResolution
    eg.globals.displayfrq = s.CurrentRefreshRate
    eg.globals.displaybit = s.CurrentBitsPerPixel
    eg.globals.displayname = s.Name

print "Device: ",eg.globals.displayname
print "Resolution: ",eg.globals.displaywidth, "x", eg.globals.displayheight
print "Frequency: ",eg.globals.displayfrq
print "Color Depth: ",eg.globals.displaybit,"bit"
You could try the video controller WMI lookup
User avatar
FCB38
Experienced User
Posts: 50
Joined: Mon Nov 28, 2011 10:28 am

Re: Read & show resolution and frequency of the screen.

Post by FCB38 »

Hello,

It's me. I try you solution and I'm sorry but it doesn't work.
In attached you can find 2 files:
  • First
    2012-10-10 - XBMC.xml
    (27.9 KiB) Downloaded 181 times
    give no error but the returned resolution and frequency are alwayys the same.
  • Second
    2012-10-19 - XBMC.xml
    (27.63 KiB) Downloaded 278 times
    give errors and return nothing:
---> Welcome to EventGhost <---
Error compiling script.
Traceback (most recent call last) (1582):
File "C:\Logiciels\Utilitaires\EventGhost\eg\Classes\ActionItem.py", line 121, in SetArguments
self.compiled = self.executable.Compile(*args)
File "C:\Logiciels\Utilitaires\EventGhost\plugins\EventGhost\PythonScript.py", line 71, in __init__
self.PrintTraceback()
File "C:\Logiciels\Utilitaires\EventGhost\plugins\EventGhost\PythonScript.py", line 97, in PrintTraceback
treeItem.PrintError("Traceback (most recent call last):")
AttributeError: 'NoneType' object has no attribute 'PrintError'

Autostart
Plugin: ATI Remote Wonder II (WinUSB)
Plugin: Task Create/Switch Events
Plugin: XBMC2
JSON-RPC connected
HTTP API connected
Disable: Monitor Switching
Listening for XBMC broadcast events
Plugin: OS Menu
Plugin: On screen explorer
Plugin: ffdshow
Main.OnInit
It seems to be hard, I don't understand what I do, but if you can help me I'll be happy.

Thank you and regards.
eatmeimadanish
Experienced User
Posts: 118
Joined: Thu Oct 01, 2009 5:11 pm

Re: Read & show resolution and frequency of the screen.

Post by eatmeimadanish »

That error is when a value is empty. Just declare the variables at the top of the script, and give them empty values. This should resolve that issue.

Like:

eg.globals.displaywidth = "NA"
eg.globals.displayheight = "NA"
eg.globals.displayfrq = "NA"
eg.globals.displaybit = "NA"
eg.globals.displayname = "NA"
User avatar
FCB38
Experienced User
Posts: 50
Joined: Mon Nov 28, 2011 10:28 am

Re: Read & show resolution and frequency of the screen.

Post by FCB38 »

Hello,

I have no more errors but the returned values are always the same. I change resolution and the values don't change.
---> Welcome to EventGhost <---
Autostart
Plugin: ATI Remote Wonder II (WinUSB)
Plugin: Task Create/Switch Events
Plugin: XBMC2
JSON-RPC connected
HTTP API connected
Disable: Monitor Switching
Listening for XBMC broadcast events
Plugin: OS Menu
Plugin: On screen explorer
Plugin: ffdshow
Main.OnInit
Scripts
Device: NVIDIA GeForce 8600 GT
Resolution: 1024 x 768
Frequency: 60
Pixel Density: 96
Color Depth: 32 b
If you don't understand let it fall.
Thank you very much for your help.

PS : I put the new configuration file.
Attachments
2012-10-27 - XBMC.xml
(28.04 KiB) Downloaded 187 times
User avatar
FCB38
Experienced User
Posts: 50
Joined: Mon Nov 28, 2011 10:28 am

Re: Read & show resolution and frequency of the screen.

Post by FCB38 »

Hello,

I find what's wrong. In fact I was using "Win32_DisplayConfiguration" instead of "Win32_VideoController".
I can read the good values now.

Thank you and see you later.
Post Reply