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.

Limit PC Volume percentage?

If you have a question or need help, this is the place to be.
Post Reply
debennett2
Posts: 4
Joined: Mon Jan 23, 2012 3:23 pm

Limit PC Volume percentage?

Post by debennett2 »

I am new to eventghost but use o use girder back in the day so am a little familiar with the concepts in general. I am trying too find a way to limit the percentage that the Windows 7 PC master volume is alowed to increase to (percentage-wise of course). I use my PC with studio monitor speaker...so no volume control other than from the source (the PC). It would be nice to set a certain percentage as the limit.

As an extra aded bonus, if a message could be returned if I hit that limit and try o exceed (OSD), that would be even more awesome!

Anyone have any ideas on howto accomplish such a feet?!

Thanks so much!
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Limit PC Volume percentage?

Post by Pako »

I think it could be very simple.
I just need to confirm a single information:
The volume control will be performed exclusively through EventGhost?

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

Re: Limit PC Volume percentage?

Post by debennett2 »

Yes. The only volume input would be from Eventghost. No other volumes would be touched other than the system volume.
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Limit PC Volume percentage?

Post by Pako »

If the volume control will be performed exclusively through EventGhost, then you can try the following method:
LimitedVolume.png
Copy this code an paste into EG:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1544">
    <Folder Name="Limited volume" Expanded="True">
        <Macro Name="Set volume limit and volume step" Expanded="True">
            <Event Name="Main.OnInit" />
            <Action Name="Python Script 1">
                EventGhost.PythonScript(u'#Variable settings (percentage)\neg.globals.Vol_Limit  = 75.0\neg.globals.volumeStep =  2.0')
            </Action>
        </Macro>
        <Macro Name="Change Master Volume +" Expanded="True">
            <Event Name="Remote.Vol+" />
            <Action>
                System.ChangeMasterVolumeBy(0.0, 0)
            </Action>
            <Action Name="Python Script 2">
                EventGhost.PythonScript(u'eg.globals.volumeStep = 2.0 \nif eg.globals.Vol_Limit >= (eg.result + eg.globals.volumeStep):\n    eg.plugins.System.ChangeMasterVolumeBy(eg.globals.volumeStep, 0)\n    eg.result = False\nelse:\n    if eg.globals.Vol_Limit > eg.result:\n        eg.plugins.System.SetMasterVolume(eg.globals.Vol_Limit, 0)\n    eg.result = True\nprint "eg.result =",eg.result\n')
            </Action>
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(85), 0, False)
            </Action>
            <Action>
                System.ChangeMasterVolumeBy(0.0, 0)
            </Action>
            <Action>
                EventGhost.ShowOSD(u'Volume: {int(round(eg.result))}%', u'0;-32;0;0;0;700;0;0;0;238;3;2;1;66;Comic Sans MS', (255, 255, 0), (0, 0, 0), 0, (5, 5), 0, 3.0, True)
            </Action>
        </Macro>
        <Macro Name="Show OSD: Volume limit exceeded !" id="85" Expanded="True">
            <Action>
                EventGhost.ShowOSD(u'Volume limit exceeded!', u'0;-32;0;0;0;700;0;0;0;238;3;2;1;66;Comic Sans MS', (255, 255, 0), (0, 0, 0), 0, (5, 5), 0, 3.0, True)
            </Action>
        </Macro>
        <Macro Name="Change Master Volume: -" Expanded="True">
            <Event Name="Remote.Vol-" />
            <Action>
                EventGhost.PythonCommand(u'eg.plugins.System.ChangeMasterVolumeBy(-eg.globals.volumeStep, 0)')
            </Action>
            <Action>
                EventGhost.ShowOSD(u'Volume: {int(round(eg.result))}%', u'0;-32;0;0;0;700;0;0;0;238;3;2;1;66;Comic Sans MS', (255, 255, 0), (0, 0, 0), 0, (5, 5), 0, 3.0, True)
            </Action>
        </Macro>
    </Folder>
</EventGhost>
Limitation can be set inside the Python Script 1.

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

Re: Limit PC Volume percentage?

Post by debennett2 »

Can you explain the flow of the control a litle bit? I'm not following it completely...as in how it is even a;lwing volume change since none of them say they change the volume at all. Just a smidge confused on the flow.

Thanks!
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Limit PC Volume percentage?

Post by Pako »

debennett2 wrote:Can you explain the flow of the control a litle bit? I'm not following it completely...as in how it is even a;lwing volume change since none of them say they change the volume at all. Just a smidge confused on the flow.
I'm sorry, but I do not understand your question.
Can you please write in other words?
Unfortunately I do not speak English.

Pako
hotbuddha
Experienced User
Posts: 99
Joined: Tue Mar 29, 2011 5:14 am

Re: Limit PC Volume percentage?

Post by hotbuddha »

See here for real volume events, using these events you can limit volume through eventghost no mater how the volume change is made even through the system volume or some other program etc:

viewtopic.php?f=10&t=3744&hilit=volume+change
Post Reply