Hello,
First of all, congratulations for that wonderful program !!! I used to use ATI program, which was buggy (crashy) and then Girder which was way too complicated; so thank you very much for your work.
I have configured my EG as I wanted to, but I want to add some OSD stuff, and particularely the sound value, when I inscrease or decrease volume, I'd like to see "Volume: 45%" on the screen, but I have no idea of how to do it.
Thanks
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.
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.
[solved] Getting master sound value in a script
[solved] Getting master sound value in a script
Last edited by Bicou on Tue Sep 12, 2006 4:54 pm, edited 1 time in total.
- Bitmonster
- Site Admin
- Posts: 2239
- Joined: Mon Feb 06, 2006 10:28 pm
SetMasterVolume and ChangeMasterVolume return the current volume level in "eg.result".
http://www.eventghost.org/wiki/Scripting#eg.result
ShowOSD accepts curly-brace syntax to show eg.result.
Example (copy&paste this to your tree):
http://www.eventghost.org/wiki/Scripting#eg.result
ShowOSD accepts curly-brace syntax to show eg.result.
Example (copy&paste this to your tree):
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="681">
<Folder Name="Volume Control">
<Macro Name="Decrease Volume">
<Event Name="VolumeDown">
</Event>
<Action>
System.ChangeMasterVolumeBy(-2.0)
</Action>
<Action>
EventGhost.ShowOSD(u'Volume: {int(eg.result)}%', u'0;-32;0;0;0;400;0;0;0;0;0;0;0;0;', (255, 255, 255), (0, 0, 0), 0, (0, 0), 0, 3.0)
</Action>
<Action>
EventGhost.AutoRepeat(0.59999999999999998, 0.29999999999999999, 0.01, 3.0)
</Action>
</Macro>
<Macro Name="Increase Volume">
<Event Name="VolumeUp">
</Event>
<Action>
System.ChangeMasterVolumeBy(2.0)
</Action>
<Action>
EventGhost.ShowOSD(u'Volume: {int(eg.result)}%', u'0;-32;0;0;0;400;0;0;0;0;0;0;0;0;', (255, 255, 255), (0, 0, 0), 0, (0, 0), 0, 3.0)
</Action>
<Action>
EventGhost.AutoRepeat(0.59999999999999998, 0.29999999999999999, 0.01, 3.0)
</Action>
</Macro>
</Folder>
</EventGhost>Thanks a lot! That's really cool 
I have now another question :p
How can I know if a program has a running instance? I've thought of a Python command testing if mplayerc.exe is running, and right after a conditionnal jump depending on the Python command, is that OK? I just don't know how to make my Python command :s
Thanks
I have now another question :p
How can I know if a program has a running instance? I've thought of a Python command testing if mplayerc.exe is running, and right after a conditionnal jump depending on the Python command, is that OK? I just don't know how to make my Python command :s
Thanks
- Bitmonster
- Site Admin
- Posts: 2239
- Joined: Mon Feb 06, 2006 10:28 pm
1. Use a "Find a window" action to find any MPC window (just leave the EXE field enabled, all other can be disabled). Turn off "Stop macro if target is not found"
2. Place a "jump" action after it and don't let it return. If FindWindow has found any MPC windows, it will set eg.result with the list of the windows. "Jump" will regard eg.result with a filled list as "successful" and will jump to the macro you choose. You can let it point to an empty macro, to just interrupt the processing.
3. Place actions to handle the other state after this, like starting MPC.
So this comes down to:
1. Search MPC
2. If found jump to another macro
3. Start MPC.exe
2. Place a "jump" action after it and don't let it return. If FindWindow has found any MPC windows, it will set eg.result with the list of the windows. "Jump" will regard eg.result with a filled list as "successful" and will jump to the macro you choose. You can let it point to an empty macro, to just interrupt the processing.
3. Place actions to handle the other state after this, like starting MPC.
So this comes down to:
1. Search MPC
2. If found jump to another macro
3. Start MPC.exe
- Bitmonster
- Site Admin
- Posts: 2239
- Joined: Mon Feb 06, 2006 10:28 pm
A bit more advanced:
This will start MPC if not started and bring it to front otherwise.
EDIT:
Small fix so this will also work if a video is loaded (title of MPC window has changed).
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="714">
<Folder Name="Start Media Player Classic">
<Macro Name="Start Media Player Classic">
<Action>
Window.FindWindow(u'mplayerc.exe', None, None, None, None, 1, False, 0.0, 2)
</Action>
<Action>
EventGhost.NewJumpIf(XmlIdLink(1355), 0, False)
</Action>
<Action>
System.Execute(u'{eg.PROGRAMFILES}\\Media Player Classic\\mplayerc.exe', u'', 0, False, 2)
</Action>
</Macro>
<Macro Name="Bring to front Media Player Classic" id="1355">
<Action>
Window.FindWindow(u'mplayerc.exe', u'{*} - Media Player Classic', u'MediaPlayerClassicW', None, None, 1, False, 0.0, 0)
</Action>
<Action>
Window.BringToFront()
</Action>
</Macro>
</Folder>
</EventGhost>EDIT:
Small fix so this will also work if a video is loaded (title of MPC window has changed).
Wow, really fast answer, cool :)
Actually I'd like to let Winamp context folder always enabled, except when MPC is turned on. For example if winamp is opened with a playlist, but stopped, and I launch a movie, then I press Play/pause to pause my movie, I don't want winamp to play the playlist!
So I've thought of a macro which triggers on all events in common between MPC and WA (like play/pause, show playlist, stop, jump next file, etc), but this macro must stop process if MPC is running.
My macro is triggered after sending MPC the event :
1. Find Window: MPC
2. If successful, jump to an empty macro (to prevent winamp from getting the event)
But that does not work: if WA and MPC are running at once, say MPC playing and WA stopped, the play/pause button of my remote control will pause MPC and play WA :/
What's wrong?
edit: wow, you're so fast you got time to reply with 2 solutions while I can barely post to explain my problem :p
Actually I'd like to let Winamp context folder always enabled, except when MPC is turned on. For example if winamp is opened with a playlist, but stopped, and I launch a movie, then I press Play/pause to pause my movie, I don't want winamp to play the playlist!
So I've thought of a macro which triggers on all events in common between MPC and WA (like play/pause, show playlist, stop, jump next file, etc), but this macro must stop process if MPC is running.
My macro is triggered after sending MPC the event :
1. Find Window: MPC
2. If successful, jump to an empty macro (to prevent winamp from getting the event)
But that does not work: if WA and MPC are running at once, say MPC playing and WA stopped, the play/pause button of my remote control will pause MPC and play WA :/
What's wrong?
edit: wow, you're so fast you got time to reply with 2 solutions while I can barely post to explain my problem :p
- Bitmonster
- Site Admin
- Posts: 2239
- Joined: Mon Feb 06, 2006 10:28 pm
- Bitmonster
- Site Admin
- Posts: 2239
- Joined: Mon Feb 06, 2006 10:28 pm