Python,; KeyError; Volumeup
-
- Posts: 16
- Joined: Mon Dec 28, 2009 6:21 pm
Python,; KeyError; Volumeup
Hi,
I'm currently writing a python script so I can change te volume with an exponential curve.
I've sort of done it, but now I' want to embed the keystrokes into that python script.
I've googled my ass off and still can't seem to figure it out:
When I use:
__ if eg.plugins.Keyboard.VolumeDown:
__ ...
I get:
__ Traceback (most recent call last):
__ Python script "63", line 15, in <module>
__ if eg.plugins.Keyboard.VolumeDown:
__ File "C:\Program Files\EventGhost\eg\Classes\PluginInfo.py", line 39, in __getattr__
__ KeyError: 'VolumeDown'
The keyboard pluging is loaded, but
Same for the MceRemote.VolumeDown, MceRemote.Mute, etc
I can't seem to figure out what the syntax is...
Thx, in advance,
Nick
I'm currently writing a python script so I can change te volume with an exponential curve.
I've sort of done it, but now I' want to embed the keystrokes into that python script.
I've googled my ass off and still can't seem to figure it out:
When I use:
__ if eg.plugins.Keyboard.VolumeDown:
__ ...
I get:
__ Traceback (most recent call last):
__ Python script "63", line 15, in <module>
__ if eg.plugins.Keyboard.VolumeDown:
__ File "C:\Program Files\EventGhost\eg\Classes\PluginInfo.py", line 39, in __getattr__
__ KeyError: 'VolumeDown'
The keyboard pluging is loaded, but
Same for the MceRemote.VolumeDown, MceRemote.Mute, etc
I can't seem to figure out what the syntax is...
Thx, in advance,
Nick
- jitterjames
- Experienced User
- Posts: 677
- Joined: Thu Aug 13, 2009 4:36 pm
- Location: Quebec, Canada
- Contact:
Re: Python,; KeyError; Volumeup
I'm not exactly sure what you are trying to do but I don't see how
You should probably be using the keyboard plugin to generate the event that executes your python script. After that I would expect you to be calling another plugin to adjust the volume or something.
maybe this will help:
http://www.eventghost.org/forum/viewtop ... lit=smooth
or maybe you want to use the autorepeat function combined with a global variable? I'm not exactly sure what you are trying to do since you just say "change te volume with an exponential curve" which could mean a few things.
hope this may help...
would evaluate to a boolean. The keyboard plugin is used to generate events so I don't think you can call it like a function and therefore it won't return a boolean value. Am I missing something here?eg.plugins.Keyboard.VolumeDown
You should probably be using the keyboard plugin to generate the event that executes your python script. After that I would expect you to be calling another plugin to adjust the volume or something.
maybe this will help:
http://www.eventghost.org/forum/viewtop ... lit=smooth
or maybe you want to use the autorepeat function combined with a global variable? I'm not exactly sure what you are trying to do since you just say "change te volume with an exponential curve" which could mean a few things.
hope this may help...
-
- Posts: 16
- Joined: Mon Dec 28, 2009 6:21 pm
Re: Python,; KeyError; Volumeup
Hey, thx for your reply,
So, what you is is that it is not possible to check in a Python script wether a key is pressed or not?
Thx,
Nick
So, what you is is that it is not possible to check in a Python script wether a key is pressed or not?
Thx,
Nick
- jitterjames
- Experienced User
- Posts: 677
- Joined: Thu Aug 13, 2009 4:36 pm
- Location: Quebec, Canada
- Contact:
Re: Python,; KeyError; Volumeup
I don't think it's possible, but if it is it would probably be more complicated than that. Maybe if you explain more clearly what you are trying to do someone might be able to make a suggestion.
-
- Posts: 16
- Joined: Mon Dec 28, 2009 6:21 pm
Re: Python,; KeyError; Volumeup
I would like to just have 1 python script for the volume.
This script should be activated by the following keys;
- Keyboard.Volumeup
- Keyboard.VolumeDown
- Keyboard.Mute
- MceRemote.Volumeup
- MceRemote.VolumeDown
- MceRemote.Mute
Below that should be the python script.
And it is withtin the python script that it should be determined
what action should be taken.
Eventually my goal is to just have one python script that is constantly running
so no keyevents above it in the tree and that everything is determend in the script.
thx,
Nick
This script should be activated by the following keys;
- Keyboard.Volumeup
- Keyboard.VolumeDown
- Keyboard.Mute
- MceRemote.Volumeup
- MceRemote.VolumeDown
- MceRemote.Mute
Below that should be the python script.
And it is withtin the python script that it should be determined
what action should be taken.
Eventually my goal is to just have one python script that is constantly running
so no keyevents above it in the tree and that everything is determend in the script.
thx,
Nick
- jitterjames
- Experienced User
- Posts: 677
- Joined: Thu Aug 13, 2009 4:36 pm
- Location: Quebec, Canada
- Contact:
Re: Python,; KeyError; Volumeup
I don't really think that's possible. More importantly I don't see the point in doing it. It sounds like you are trying to remove the "event" part of a program called event ghost!
What you want to do is simple and elegantly handled by the programs basic functionality without having to write any python code.
Even if you wanted to use python to determine what action to perform, you would still need to place events for each of those keypresses in the macro that triggers the macro... but again, why bother since it defeats the purpose of the program.
What you want to do is simple and elegantly handled by the programs basic functionality without having to write any python code.
Even if you wanted to use python to determine what action to perform, you would still need to place events for each of those keypresses in the macro that triggers the macro... but again, why bother since it defeats the purpose of the program.
Re: Python,; KeyError; Volumeup
Just add those events to the Skript and you are done.Kindt.nick wrote:I would like to just have 1 python script for the volume.
This script should be activated by the following keys;
- Keyboard.Volumeup
- Keyboard.VolumeDown
- Keyboard.Mute
- MceRemote.Volumeup
- MceRemote.VolumeDown
- MceRemote.Mute
-
- Posts: 16
- Joined: Mon Dec 28, 2009 6:21 pm
Re: Python,; KeyError; Volumeup
Hi,Bartman wrote:Just add those events to the Skript and you are done.Kindt.nick wrote:I would like to just have 1 python script for the volume.
This script should be activated by the following keys;
- Keyboard.Volumeup
- Keyboard.VolumeDown
- Keyboard.Mute
- MceRemote.Volumeup
- MceRemote.VolumeDown
- MceRemote.Mute
Already tried to add this inside the script:
If Keyboard.Volumeup == true :
j = j+1
Doesn't work.
My problem is that I can't seem to find any documentation about what the Volumeup variable is.
Is it a long, bool, etc? and how can I read the value of them?
thx,
Nick
- jitterjames
- Experienced User
- Posts: 677
- Joined: Thu Aug 13, 2009 4:36 pm
- Location: Quebec, Canada
- Contact:
Re: Python,; KeyError; Volumeup
ok I think I know what you are looking for.
try these:
print eg.event.prefix
print eg.event.suffix
print eg.event.string
I think this is the page you are looking for here:
http://www.eventghost.org/docs/eg/eg.Ev ... Event.html
try these:
print eg.event.prefix
print eg.event.suffix
print eg.event.string
I think this is the page you are looking for here:
http://www.eventghost.org/docs/eg/eg.Ev ... Event.html
-
- Posts: 16
- Joined: Mon Dec 28, 2009 6:21 pm
Re: Python,; KeyError; Volumeup
THX!
Now I understand the purpuse of the "eg.event."- syntax.
I thought is was something completely else.
< if eg.event.string == 'MceRemote.VolumeDwn': > dit the trick
thx,
Nick
Now I understand the purpuse of the "eg.event."- syntax.
I thought is was something completely else.
< if eg.event.string == 'MceRemote.VolumeDwn': > dit the trick
thx,
Nick
-
- Posts: 16
- Joined: Mon Dec 28, 2009 6:21 pm
Re: Python,; KeyError; Volumeup
Another question,
I've written the script now,
is it possible to run continually?
What I mean is, I’ve written the script in a way that it skips automatically all the code untill there the correct key is pressed. (volumeup, down, mute, etc)
I just think it is more neat to just have the script in there in stead of
the script and above it, 6 different events above is.
Or do I have to make it a plugin to make it work like this?
I've tried copying it to the auto start section, but it does not see the key pressed anymore.
Any other way to that a key is pressed besides the eg.event.string?
Thx,
Nick
I've written the script now,
is it possible to run continually?
What I mean is, I’ve written the script in a way that it skips automatically all the code untill there the correct key is pressed. (volumeup, down, mute, etc)
I just think it is more neat to just have the script in there in stead of
the script and above it, 6 different events above is.
Or do I have to make it a plugin to make it work like this?
I've tried copying it to the auto start section, but it does not see the key pressed anymore.
Any other way to that a key is pressed besides the eg.event.string?
Thx,
Nick
- jitterjames
- Experienced User
- Posts: 677
- Joined: Thu Aug 13, 2009 4:36 pm
- Location: Quebec, Canada
- Contact:
Re: Python,; KeyError; Volumeup
welcome to the 20th century. Event driven code is good. Let the events activate your script when necessary.
What do you want to do, have a loop running continually eating up 100% of your cpu resources? This makes no sense to me.
What do you want to do, have a loop running continually eating up 100% of your cpu resources? This makes no sense to me.
Re: Python,; KeyError; Volumeup
To have a smooth volume change the script has to pause between the changes, so it won't eat up all cpu.
-
- Posts: 16
- Joined: Mon Dec 28, 2009 6:21 pm
Re: Python,; KeyError; Volumeup
jitterjames wrote:welcome to the 20th century. Event driven code is good. Let the events activate your script when necessary.
What do you want to do, have a loop running continually eating up 100% of your cpu resources? This makes no sense to me.
"21th century." It's not that I'm some sort of dumbass, I've been programming for years now, but only embedded devices.
I know that you've got to look at some things from a different angle, I've you're not on embedded devices,
but still, it makes sense to me if you write this in the beginning;
_ if not eg.event.string == 'MceRemote.VolumeDwn':
_ exit
it wil only take a minimum of time to run, so a minimum of resource will be taken, not?
Windows is a multitask OS, so eventghost (and the script) will 'pause' automatically between changes, not?Bartman wrote:To have a smooth volume change the script has to pause between the changes, so it won't eat up all cpu.
Of not, how do I do that? I've read somewhere to make is threaded?
-
- Posts: 16
- Joined: Mon Dec 28, 2009 6:21 pm
Re: Python,; KeyError; Volumeup
"21th century." It's not that I'm some sort of dumbass, I've been programming for years now, but only embedded devices.jitterjames wrote:welcome to the 20th century. Event driven code is good. Let the events activate your script when necessary.
What do you want to do, have a loop running continually eating up 100% of your cpu resources? This makes no sense to me.
I know that you've got to look at some things from a different angle, I've you're not on embedded devices,
but still, it makes sense to me if you write this in the beginning;
_ if not eg.event.string == 'MceRemote.VolumeDwn':
_ exit
it wil only take a minimum of time to run, so a minimum of resource will be taken, not?
Windows is a multitask OS, so eventghost (and the script) will 'pause' automatically between changes, not?Bartman wrote:To have a smooth volume change the script has to pause between the changes, so it won't eat up all cpu.
Of not, how do I do that? I've read somewhere to make is threaded?