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.

Show OSD plugin variables?

If you have a question or need help, this is the place to be.
Post Reply
molitar
Experienced User
Posts: 209
Joined: Fri Sep 11, 2009 6:44 am

Show OSD plugin variables?

Post by molitar »

I wish to show filename playing on screen. But I could find nothing for variables for Show OSD is their no variables for items like filename, time, ect?
User avatar
jinxdone
Plugin Developer
Posts: 443
Joined: Tue Jan 02, 2007 4:08 pm

Re: Show OSD plugin variables?

Post by jinxdone »

You can show whatever you want with python. Just put the code you want inside a curly brace {} pair, whatever is in there is interpreted by python.

So, the most common use is with the event variables, like {eg.event.string} or {eg.event.payload}.. Just as an example you could have a plugin that stores the current filename from your media player in a variable and then show it with ShowOSD {eg.myplugin.fileplaying}. It's really upto you how you use it.

-jinxdone
molitar
Experienced User
Posts: 209
Joined: Fri Sep 11, 2009 6:44 am

Re: Show OSD plugin variables?

Post by molitar »

jinxdone wrote:You can show whatever you want with python. Just put the code you want inside a curly brace {} pair, whatever is in there is interpreted by python.

So, the most common use is with the event variables, like {eg.event.string} or {eg.event.payload}.. Just as an example you could have a plugin that stores the current filename from your media player in a variable and then show it with ShowOSD {eg.myplugin.fileplaying}. It's really upto you how you use it.

-jinxdone
Ok so the Show OSD plugin does not have default variables than? Other remote management software If I wanted current time I would use a show OSD and have a variable like %time% and time would be what displayed. So ShowOSD plugin is useless for my needs than.. so how would I show the filename than? Really be nice if someone did create a OSD plugin with common variable types that make it quick to show something like filename, time, ect. One thing uICE did very well.
User avatar
jinxdone
Plugin Developer
Posts: 443
Joined: Tue Jan 02, 2007 4:08 pm

Re: Show OSD plugin variables?

Post by jinxdone »

No no. In fact ShowOSD is far more flexible than that. When you put code inside the curly braces {} you are infact evaluating Python code with the eval() statement. (through eg\Utils.py ParseString function). Essentially the user is free to run whatever code he wants to, there is no artificial limit imposed by %% tags. If we used that approach the user would be restricted to whatever tag functions the plugin author has coded. Probably there would never be enough of them, right?

For example:
- To show current date, try ShowOSD with something like; "The current date is: {eg.Utils.time.strftime('%Y-%m-%d')}"
- To get the current playing song from winamp with the winamp plugin; {eg.plugins.Winamp.GetPlayingSongTitle()}


Alternatively:

Instead of executing the code directly in ShowOSD, you can run an action just before the ShowOSD, which will return some data and put it in the eg.result variable, which you can then show with {eg.result}. Simple.

OR

Instead of running a ready made action, you could just as well run a python script just before your ShowOSD action. In this script you can do whatever you like and put the result for example in the eg.result (or any other) variable. Example script

Code: Select all

import time
eg.result = time.time()
OR

You can skip using the ShowOSD action entirely and just call it from a Python Script instead. like so..

Code: Select all

import time
eg.plugins.EventGhost.ShowOSD(
    u'TEST: ' + str(time.time()), # This line is the text of the ShowOSD command..
     u'0;-24;0;0;0;700;0;0;0;1;0;0;2;32;Arial',
    (255, 255, 255),
    (0, 0, 0),
    0,
    (0, 0),
    0,
    3.0,
    False
)
OR

Use the EG event system (with eg.TriggerEvent) to pass some data to the ShowOSD action. This would be accessible with {eg.event.*}

I hope this explained a bit the possibilities there are for passing data between the EG actions. What is actually needed is some better documentation, tutorials and use case examples for the most common commands. My advice is to use the PyCrust shell (in EG window's help -> Python Shell) and browse the eg NameSpace to see what is available.

If these concepts are unfathomable I recommend first reading a programming book about any programming language. Preferrably a Python book. ;)

----

The real question is; do we want to make EG easy enough for the average joe who has 0 programming ability to use? Sort of one click deal with a GUI for everything? This would bloat the program really fast and I think it's not easily archieved with such a small developer and userbase. It's especially pointless since I think EG appeals to exactly the kind of tech savvy users who have atleast a general idea what programming is.

If something should be improved, it's the way EG passes data between events and actions. This would make building complex configurations even easier and more powerful using only the config tree, which is already EG's strong point. For example it would be great to be able to get the eg.result value from a number of past actions, not just the latest one that finished.

These are just my thoughts on it and may not be what BitMonster or other people have planned for EG.

-jinxdone
molitar
Experienced User
Posts: 209
Joined: Fri Sep 11, 2009 6:44 am

Re: Show OSD plugin variables?

Post by molitar »

Jinx, thanks for the explanation.. I see how to make items like time and date show now.. but what class or winapi do I need to find the command to get the current filename? I wish to display with playtime in MPC-Home the filename while looking inside of MediaPlayerClassic plugin their is none for calling the current playing file.
User avatar
jinxdone
Plugin Developer
Posts: 443
Joined: Tue Jan 02, 2007 4:08 pm

Re: Show OSD plugin variables?

Post by jinxdone »

Well.. It looks like the MPC plugin actions simply send a windows message to the MPC window, so it can't be used to retrieve data. Looks like you could check what file is playing either from the MPC's webinterface or maybe grab the filename from the title of the MPC window.
molitar
Experienced User
Posts: 209
Joined: Fri Sep 11, 2009 6:44 am

Re: Show OSD plugin variables?

Post by molitar »

jinxdone wrote:Well.. It looks like the MPC plugin actions simply send a windows message to the MPC window, so it can't be used to retrieve data. Looks like you could check what file is playing either from the MPC's webinterface or maybe grab the filename from the title of the MPC window.
Ok that is what I have done.. now I have a serious problem with my OSD display though.. The display doesn't come out right it messes up my playtime bar and the text is too large for the filename. Is their perhaps a method to show more than one line of OSD at a time so I can have a different font size for it?

Code: Select all

Find_MPC_Time=eg.WindowMatcher(u'mpc-hc.exe', u'{*}Media Player Classic{*}', u'MediaPlayerClassicW', None, u'Static', 2, True, 0.0, 0)
hwnd = Find_MPC_Time()

if len(hwnd) > 0:
    if eg.globals.WindowsState == "Fullscreen": howManyBars = 60
    if eg.globals.WindowsState != "Fullscreen": howManyBars = 80

    timeE,timeR = eg.WinApi.GetWindowText(hwnd[0]).split(' / ')
    secArray = timeE.split(':')
    secArrayTotal = timeR.split(':')
    secondsTotal = int(secArrayTotal[0])*(60)+int(secArrayTotal[1])
    secondsElapsed = int(secArray[0])*(60)+int(secArray[1])
    percent = (secondsElapsed*howManyBars)/secondsTotal
    text = eg.globals.grabbedText
    osd = "[" + "|"*(percent) + " "*(howManyBars-percent) + "]" + "\n" + " "*30 + timeE + " / " + timeR
    osd2 = text + "\n" + osd
    if eg.globals.WindowsState != "Fullscreen":
        eg.plugins.EventGhost.ShowOSD(osd2, u'0;-64;0;0;0;700;0;0;0;0;3;2;1;34;Arial', (0, 255, 255), (0, 0, 0), 4, (0, 0), 0, 1.0, False)
    else:
        eg.plugins.EventGhost.ShowOSD(osd, u'0;-64;0;0;0;700;0;0;0;0;3;2;1;34;Arial', (0, 255, 255), (0, 0, 0), 4, (0, 0), 1, 1.0, False)
    
Drabert
Posts: 19
Joined: Wed Feb 18, 2009 8:30 am

Re: Show OSD plugin variables?

Post by Drabert »

is it possible to use something from the network event reciever to display with the OSD. I am sending the current song in winamp to a computer to show what song is playing, but would like it to show up on the OSD. I am using a wild card for the action trigger, but need to figure out how to catch the event from the network event reciever.

thanks for the assistance!

Drabert
Post Reply