Using OSD and display current volume level [SOLVED]

If you have a question or need help, this is the place to be.

Re: Using OSD and display current volume level [SOLVED]

Postby bskchaos » Sun Oct 02, 2011 12:03 am

Try this:

Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1540">
    <Folder Name="Volume Control" Expanded="True">
        <Macro Name="Decrease Volume" Expanded="True">
            <Event Name="X10.VolumeDown" />
            <Event Name="ErgoMouse.Button.234" />
            <Event Name="HID.Button.3" />
            <Action>
                System.ChangeMasterVolumeBy(-5.0, 0)
            </Action>
            <Action id="762">
                EventGhost.ShowOSD(u'{"c" *int(round(eg.result) * 0.20) + "g" *int(round(100-(eg.result)) * 0.20)}', u'0;-12;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', (255, 255, 255), (0, 0, 0), 3, (8, 48), 0, 2.0, True)
            </Action>
            <Action>
                EventGhost.AutoRepeat(0.40000000000000002, 0.050000000000000003, 0.01, 0.40000000000000002)
            </Action>
        </Macro>
        <Macro Name="Increase Volume" Expanded="True">
            <Event Name="X10.VolumeUp" />
            <Event Name="ErgoMouse.Button.233" />
            <Event Name="HID.Button.4" />
            <Action>
                System.ChangeMasterVolumeBy(5.0, 0)
            </Action>
            <Action id="770">
                EventGhost.ShowOSD(u'{"c" *int(round(eg.result) * 0.20) + "g" *int(round(100-(eg.result)) * 0.20)}', u'0;-12;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', (255, 255, 255), (0, 0, 0), 3, (8, 48), 0, 2.0, True)
            </Action>
            <Action>
                EventGhost.AutoRepeat(0.40000000000000002, 0.050000000000000003, 0.01, 0.40000000000000002)
            </Action>
        </Macro>
        <Macro Name="Mute Sound Card" Expanded="True">
            <Event Name="X10.Mute" />
            <Action>
                System.ToggleMute(0)
            </Action>
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(777), 0, False)
            </Action>
            <Action>
                EventGhost.ShowOSD(u'X\xf0', u'0;-64;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', (255, 255, 255), (0, 0, 0), 3, (16, 56), 0, 2.0, True)
            </Action>
        </Macro>
        <Macro Name="Show OSD: Mute ON" id="777" Expanded="True">
            <Action>
                EventGhost.ShowOSD(u'Xr', u'0;-64;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', (255, 255, 255), (0, 0, 0), 3, (16, 56), 0, 0.0, True)
            </Action>
        </Macro>
    </Folder>
</EventGhost>
bskchaos
 
Posts: 42
Joined: Tue Mar 25, 2008 3:04 pm

Re: Using OSD and display current volume level [SOLVED]

Postby InterlinkKnight » Sun Oct 02, 2011 12:52 am

That works, thanks. But I don't understand why works like this. I mean, how you setup this manually (without editing the XML file)?
User avatar
InterlinkKnight
 
Posts: 28
Joined: Mon Sep 13, 2010 1:17 am

Re: Using OSD and display current volume level [SOLVED]

Postby bskchaos » Sun Oct 02, 2011 1:35 am

copy the code an paste into EG
bskchaos
 
Posts: 42
Joined: Tue Mar 25, 2008 3:04 pm

Re: Using OSD and display current volume level [SOLVED]

Postby InterlinkKnight » Sun Oct 02, 2011 2:22 am

bskchaos wrote:copy the code an paste into EG

Every time i try that doesnt work. Shows: "Xð" and that's it
User avatar
InterlinkKnight
 
Posts: 28
Joined: Mon Sep 13, 2010 1:17 am

Re: Using OSD and display current volume level [SOLVED]

Postby bskchaos » Sun Oct 02, 2011 5:12 am

Remember that you must use the font Webdings
bskchaos
 
Posts: 42
Joined: Tue Mar 25, 2008 3:04 pm

Re: Using OSD and display current volume level [SOLVED]

Postby InterlinkKnight » Sun Oct 02, 2011 5:31 am

bskchaos wrote:Remember that you must use the font Webdings

You are right. Dah!. My mistake. Although you forgot to mention that you need to add a macro and a JUMP action to show when sound is muted. I am not sure how to do that, but i think i can figure it out.

Overall, this technique work and I will include it on the main instructions as another way to do it, but is complicated to do it right. For example I notes that if i change the increase volume rate from 5% to any other (like 4%), the bar move strange. It need a specific setup to work good. Even so, is useful.

Thanks for the help.
User avatar
InterlinkKnight
 
Posts: 28
Joined: Mon Sep 13, 2010 1:17 am

Re: Using OSD and display current volume level [SOLVED]

Postby bskchaos » Thu Oct 06, 2011 12:03 pm

I know that it lacks precision. But I prefer it instead of a long bar.

The logic behind the Mute OSD is this:
"Toggle mute" disables sound and the "If susessful..." jumps to another macro with the Mute On OSD.
If you press mute again the "If susessful..." criteria won't be meet and the next action (Mute Off OSD) is executed.
bskchaos
 
Posts: 42
Joined: Tue Mar 25, 2008 3:04 pm

Re: Using OSD and display current volume level [SOLVED]

Postby tomde » Wed Oct 12, 2011 5:18 pm

Hello,

Code: Select all
Sound {("On", "Off")[eg.result]}

works fine

Code: Select all
Volume - {eg.WinApi.SoundMixer.GetMasterVolume()}

shows always 100% - (but Volume is changing)

Code: Select all
Volume - {int(round(eg.result))}%

force an error:
Log: Decrease Volume
Verändere Master-Lautstärke: -3.00 %
Automatische Wiederholung: 0.6
Zeige OSD: Volume - {int(round(eg.result))}%
Fehler in Befehl: "Zeige OSD: Volume - {int(round(eg.result))}%"
Traceback (most recent call last) (1540):
File "C:\APPS\EventGhost\eg\Classes\ActionBase.py", line 170, in CallWrapper
return self(*args)
File "C:\APPS\EventGhost\plugins\EventGhost\ShowOSD.py", line 385, in __call__
osdText = eg.ParseString(osdText)
File "C:\APPS\EventGhost\eg\Utils.py", line 204, in ParseString
res = eval(word, {}, eg.globals.__dict__)
File "<string>", line 1, in <module>
TypeError: a float is required

Any idea? Thanks, Tom
tomde
 
Posts: 3
Joined: Wed Oct 12, 2011 12:46 pm

Re: Using OSD and display current volume level [SOLVED]

Postby InterlinkKnight » Thu Oct 13, 2011 12:10 pm

tomde wrote:Hello,

Code: Select all
Volume - {eg.WinApi.SoundMixer.GetMasterVolume()}

shows always 100% - (but Volume is changing)

Don't use that code because doesn't work on Windows 7, unless you run Eventghost in Windows XP sp3 compatibility mode. You better use the other code (I show the solution next).

tomde wrote:
Code: Select all
Volume - {int(round(eg.result))}%

force an error:
Log: Decrease Volume
Verändere Master-Lautstärke: -3.00 %
Automatische Wiederholung: 0.6
Zeige OSD: Volume - {int(round(eg.result))}%
Fehler in Befehl: "Zeige OSD: Volume - {int(round(eg.result))}%"
Traceback (most recent call last) (1540):
File "C:\APPS\EventGhost\eg\Classes\ActionBase.py", line 170, in CallWrapper
return self(*args)
File "C:\APPS\EventGhost\plugins\EventGhost\ShowOSD.py", line 385, in __call__
osdText = eg.ParseString(osdText)
File "C:\APPS\EventGhost\eg\Utils.py", line 204, in ParseString
res = eval(word, {}, eg.globals.__dict__)
File "<string>", line 1, in <module>
TypeError: a float is required

The error is caused because you place the "Autorepeat current macro" before the OSD command. As I say in the instructions, you need to place the "Autorepeat current macro" after the "Show OSD".

Should work after you fix that.
User avatar
InterlinkKnight
 
Posts: 28
Joined: Mon Sep 13, 2010 1:17 am

Re: Using OSD and display current volume level [SOLVED]

Postby tomde » Thu Oct 13, 2011 3:31 pm

Now, it works perfect. Thank you.
tomde
 
Posts: 3
Joined: Wed Oct 12, 2011 12:46 pm

Re: Using OSD and display current volume level [SOLVED]

Postby debennett2 » Mon Jan 23, 2012 3:25 pm

Code: Select all
FF.VolumeUp
   Change Master Volume: 0.50 %
      Show OSD: Volume - {int(round(eg.result))}%
         Error in Action: "Show OSD: Volume - {int(round(eg.result))}%"
         Traceback (most recent call last) (1544):
           File "C:\Program Files\EventGhost\eg\Classes\ActionBase.py", line 170, in CallWrapper
             return self(*args)
           File "C:\Program Files\EventGhost\plugins\EventGhost\ShowOSD.py", line 385, in __call__
             osdText = eg.ParseString(osdText)
           File "C:\Program Files\EventGhost\eg\Utils.py", line 204, in ParseString
             res = eval(word, {}, eg.globals.__dict__)
           File "<string>", line 1, in <module>
         TypeError: a float is required
      Change Master Volume: 0.50 %
      Autorepeat current macro: 0.6



Any ideas? This is in a Windows 7 machine. I'm lost.

Thanks!
debennett2
 
Posts: 4
Joined: Mon Jan 23, 2012 3:23 pm

Re: Using OSD and display current volume level [SOLVED]

Postby Pako » Tue Jan 24, 2012 7:49 am

debennett2 wrote: I'm lost.
I'm also lost.
I need to see not only the result but also a source or originator of it.
Why are you here did not give either a screenshot or your configuration file?
Thus, it seems that there are missing the action Change Master Volume.
It must be before the action Show OSD.

Pako
User avatar
Pako
Plugin Developer
 
Posts: 1283
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic

Re: Using OSD and display current volume level [SOLVED]

Postby InterlinkKnight » Tue Jan 24, 2012 11:53 am

Pako wrote:Why are you here did not give either a screenshot or your configuration file?
Thus, it seems that there are missing the action Change Master Volume.
It must be before the action Show OSD.

Pako

I was thinking that you can do it yourself, with your own "change master volume". I mean, this is to show the volume, not to make a volume change button. Anyway, you are right. I better place the configuration file in here just in case anyone is lost:

Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1544" Guid="{93CA3DF2-7148-4B9C-9F06-FB3D578935B9}" Time="1327405609.27">
    <Autostart Name="Autostart" Expanded="True">
        <Plugin Identifier="Lirc" Guid="{17A77662-BB69-4C37-AA43-71213958C5C4}" File="Lirc">
            gAIoWAkAAAAxMjcuMC4wLjFxAE09IomJiUsAS8iIS0BLCnRxAS4=
        </Plugin>
    </Autostart>
    <Folder Name="Change Volume">
        <Macro Name="Volume Up">
            <Event Name="Lirc.vol+" />
            <Action>
                System.ChangeMasterVolumeBy(1.0, 0)
            </Action>
            <Action>
                EventGhost.ShowOSD(u'Volumen {int(round(eg.result))}%', u'0;-64;0;0;0;700;0;0;0;0;3;2;1;34;Arial', (255, 255, 255), (0, 0, 0), 5, (0, 100), 0, 3.0, True)
            </Action>
            <Action>
                EventGhost.AutoRepeat(0.5, 0.20000000000000001, 0.029999999999999999, 0.0)
            </Action>
        </Macro>
        <Macro Name="Volume Down">
            <Event Name="Lirc.vol-" />
            <Action>
                System.ChangeMasterVolumeBy(-1.0, 0)
            </Action>
            <Action>
                EventGhost.ShowOSD(u'Volumen {int(round(eg.result))}%', u'0;-64;0;0;0;700;0;0;0;0;3;2;1;34;Arial', (255, 255, 255), (0, 0, 0), 5, (0, 100), 0, 3.0, True)
            </Action>
            <Action>
                EventGhost.AutoRepeat(0.5, 0.20000000000000001, 0.029999999999999999, 0.0)
            </Action>
        </Macro>
        <Macro Name="Mute" Expanded="True">
            <Event Name="Lirc.mute" />
            <Action>
                System.ToggleMute()
            </Action>
            <Action>
                EventGhost.ShowOSD(u'Mute {("Off", "On")[eg.result]}', u'0;-64;0;0;0;700;0;0;0;0;3;2;1;34;Arial', (255, 255, 255), (0, 0, 0), 5, (0, 100), 0, 3.0, True)
            </Action>
        </Macro>
    </Folder>
</EventGhost>


That solve your problem?
Attachments
ScreenShot - 2012-01-24 - 07.24.11 - 001.jpg
configuration
ScreenShot - 2012-01-24 - 07.24.11 - 001.jpg (35 KiB) Viewed 1335 times
User avatar
InterlinkKnight
 
Posts: 28
Joined: Mon Sep 13, 2010 1:17 am

Re: Using OSD and display current volume level [SOLVED]

Postby bskchaos » Fri Aug 03, 2012 3:35 am

The new event (system.volume) seems to be accurate and I want to use it for a better volume bar.

Right now I need to convert the eg.event.payload to a number, need help with this.

BTW, this code should help those trying to use a Mute icon OSD.

Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1568">
    <Folder Name="Volume" Expanded="True">
        <Macro Name="Mute Sound Card">
            <Event Name="X10.Mute" />
            <Event Name="HID.Button.225" />
            <Action>
                System.ToggleMute(0)
            </Action>
        </Macro>
        <Macro Name="Show OSD: Mute ON">
            <Event Name="System.UnMute" />
            <Action>
                EventGhost.ShowOSD(u'X\xf0', u'0;-96;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', (255, 255, 255), (0, 0, 0), 3, (32, 32), 0, 2.0, True)
            </Action>
        </Macro>
        <Macro Name="Show OSD: Mute ON">
            <Event Name="System.Mute" />
            <Action>
                EventGhost.ShowOSD(u'Xr', u'0;-96;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', (255, 255, 255), (0, 0, 0), 3, (32, 32), 0, 0.0, True)
            </Action>
        </Macro>
    </Folder>
</EventGhost>
bskchaos
 
Posts: 42
Joined: Tue Mar 25, 2008 3:04 pm

Re: Using OSD and display current volume level [SOLVED]

Postby Vilsepi » Fri Aug 10, 2012 9:02 pm

First of all, thanks for everyone for this thread. I've been using EG for a couple of years but for some reason I've been neglecting the OSD completely. Today I started to come up with a simple volume OSD.

bskchaos wrote:The new event (system.volume) seems to be accurate and I want to use it for a better volume bar.
Right now I need to convert the eg.event.payload to a number, need help with this.


That's what I also wanted to use (didn't actually know any other alternative). My problem with System.Volume was that the payload is a string, depicting a float/double with a comma as a decimal separator. Having the comma instead of a period is what seems to fail the type conversion, thus I simply split the string from the comma and take only the numbers before it:

Value only:
Volume: {eg.event.payload.split(",")[0]}%

Volume bar (100 characters long, made of | and .)
Volume: {"|"*int(eg.event.payload.split(",")[0])+"."*(100-int(eg.event.payload.split(",")[0]))}%

Shorter volume bar (20 characters long, made of | and .) with numerical value in the end
Volume: {"|"*((int(eg.event.payload.split(",")[0]))/5)+"."*((20-int(eg.event.payload.split(",")[0])/5))}%

Webdings bar (20 characters long, made of blocks), make sure you set font to Webdings!
{"g"*((int(eg.event.payload.split(",")[0]))/5)+"c"*((20-int(eg.event.payload.split(",")[0])/5))}

Webdings bar (50 characters long, made of blocks), make sure you set font to Webdings!
{"g"*((int(eg.event.payload.split(",")[0]))/2)+"c"*((50-int(eg.event.payload.split(",")[0])/2))}


Hope this helps. It could be a bit too heavy, I dunno, but I think I might be going with just the numerical display.
Attachments
webdings_bar.png
Webdings bar
webdings_bar.png (11.02 KiB) Viewed 948 times
bar.png
Ascii volume bar with numerical value
event.png
Event payload has a float with a comma-separator
event.png (6.85 KiB) Viewed 948 times
Vilsepi
 
Posts: 1
Joined: Fri Aug 10, 2012 8:48 pm

PreviousNext

Return to General Support

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests