# Virtual key codes?

**URL:** <https://www.ruby-forum.com/t/virtual-key-codes/124114>\
**Category:** Ruby\
**Created:** [December 24, 2007, 11:55pm UTC](https://www.ruby-forum.com/t/virtual-key-codes/124114 "2007-12-24T23:55:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![pavel989](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/48db29/32.png) [@pavel989](https://www.ruby-forum.com/u/pavel989)\
**Post date:** [December 24, 2007, 11:55pm UTC](https://www.ruby-forum.com/t/virtual-key-codes/124114/1 "2007-12-24T23:55:38Z")

</div>

is it possible to send virtual keycodes through ruby?

---

<div class="post-metadata">

**Author:** ![pavel989](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/48db29/32.png) [@pavel989](https://www.ruby-forum.com/u/pavel989)\
**Post date:** [December 29, 2007, 7:27am UTC](https://www.ruby-forum.com/t/virtual-key-codes/124114/2 "2007-12-29T07:27:16Z")

</div>

well i guess no one knew, or what not. but in this case, is there a  
library that can do this?

---

<div class="post-metadata">

**Author:** ![pavel989](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/48db29/32.png) [@pavel989](https://www.ruby-forum.com/u/pavel989)\
**Post date:** [December 29, 2007, 7:52pm UTC](https://www.ruby-forum.com/t/virtual-key-codes/124114/3 "2007-12-29T19:52:39Z")

</div>

On Sat, Dec 29, 2007, Pavel P. wrote:

> well i guess no one knew, or what not. but in this case, is there a  
> library that can do this?

You didn’t give much information. What’s a virtual key code? What  
operating system are you on? What are you trying to do? All that  
information is necessary to help.

Ben

---

<div class="post-metadata">

**Author:** ![pavel989](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/48db29/32.png) [@pavel989](https://www.ruby-forum.com/u/pavel989)\
**Post date:** [December 29, 2007, 7:56pm UTC](https://www.ruby-forum.com/t/virtual-key-codes/124114/4 "2007-12-29T19:56:17Z")

</div>

> All that information is necessary to help.

I dont think all that information is necessary to help.  
But I agree completely on one point - WHAT is a virtual key?

Is that a key used in an online game? Or one you would like to have on  
your keyboard, but don’t have? 🙂

---

<div class="post-metadata">

**Author:** ![pavel989](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/48db29/32.png) [@pavel989](https://www.ruby-forum.com/u/pavel989)\
**Post date:** [December 29, 2007, 9:00pm UTC](https://www.ruby-forum.com/t/virtual-key-codes/124114/5 "2007-12-29T21:00:41Z")

</div>

On Sat, 29 Dec 2007 13:56:12 -0500, Marc H. wrote:

> But I agree completely on one point - WHAT is a virtual key?
> 
> Is that a key used in an online game? Or one you would like to have on  
> your keyboard, but don’t have? 🙂

I think it’s one of those keys that you find in your drawer and realize  
you  
don’t have any idea what it unlocks.

Philosophically, a key, by definition, is a key TO something. If you  
have  
no something, you have no key. So it’s a virtual key; if you know what  
it  
unlocks, the key actualizes. Ironically, John L. himself _was_ a key  
philosopher.

That said, I suspect the OP _may_ be talking about Windows “virtual key  
codes” - Delphi appears to use them a lot:

> **[Here Are the Top Virtual Key Codes Used by Windows](https://www.thoughtco.com/virtual-key-codes-used-by-windows-4071289)**
>
> Learn symbolic constant names and keyboard equivalents for the virtual key codes used by Windows.

They’re sort-of keyscan codes. I have no idea how or if they are  
accessed  
in Ruby.

---

<div class="post-metadata">

**Author:** ![pavel989](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/48db29/32.png) [@pavel989](https://www.ruby-forum.com/u/pavel989)\
**Post date:** [December 30, 2007, 10:07am UTC](https://www.ruby-forum.com/t/virtual-key-codes/124114/6 "2007-12-30T10:07:37Z")

</div>

Ben B. wrote:

> On Sun, Dec 30, 2007, Marc H. wrote:
> 
> > > All that information is necessary to help.
> > 
> > I dont think all that information is necessary to help.
> 
> Sure it is.
> 
> > But I agree completely on one point - WHAT is a virtual key?
> > 
> > Is that a key used in an online game? Or one you would like to have on  
> > your keyboard, but don’t have? 🙂
> 
> Assuming either one is what he was asking, there’s no way to give an  
> answer without knowing what platform you’re trying to do it on.
> 
> Ben

sorry!  
my internet went out, and didn’t really notice because I haven’t been  
home. so I’m doing this off of my phone.

now first off, ill at least consider myself a newbie here, but:

when I was still toying with programming on XP, I remember VB or c++  
using virtual key codes.

from my understanding, it’s their system of quickly identifying and  
sending key strokes. virtual there just saying whether the keys actually  
exsist or not.

whell I need this towards a windows version of my app (linux ver ready)  
of course unless theres a better way:

I need to tell XP to raise the volume as a system command, and possible  
maybe even get the current volume.

-after long research previous, the closest thing I found was sndvol132  
or something, which only loads the vol config gui. (i do have access to  
XP)

well thanks in advance, and if u wanna check out my app, the link should  
be:

[http://www.sourceforge.net/rJDC](http://www.sourceforge.net/rJDC)

kind of a fun app.

again thanks! and happy new year

---

<div class="post-metadata">

**Author:** ![pavel989](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/48db29/32.png) [@pavel989](https://www.ruby-forum.com/u/pavel989)\
**Post date:** [December 30, 2007, 7:50pm UTC](https://www.ruby-forum.com/t/virtual-key-codes/124114/7 "2007-12-30T19:50:34Z")

</div>

On Sun, Dec 30, 2007, Pavel P. wrote:

> sorry!  
> my internet went out, and didn’t really notice because I haven’t been  
> home. so I’m doing this off of my phone.

No problem 🙂

> now first off, ill at least consider myself a newbie here, but:
> 
> when I was still toying with programming on XP, I remember VB or c++  
> using virtual key codes.
> 
> from my understanding, it’s their system of quickly identifying and  
> sending key strokes. virtual there just saying whether the keys actually  
> exsist or not.

Sure, that makes sense.

> whell I need this towards a windows version of my app (linux ver ready)  
> of course unless theres a better way:
> 
> I need to tell XP to raise the volume as a system command, and possible  
> maybe even get the current volume.

I think there’s probably a more direct route to raising the system  
volume than sending a key stroke… particularly since somewhere that  
key stroke would have to have been registered as a volume up command.  
Though I suppose some keyboards come out-of-the-box with that  
functionality…

> -after long research previous, the closest thing I found was sndvol132  
> or something, which only loads the vol config gui. (i do have access to  
> XP)

You might look at the win32utils project on Rubyforge:  
[http://win32utils.rubyforge.org/](http://win32utils.rubyforge.org/)

It contains a library called win32-sound, which appears to be able to  
set the wave output volume. It’s not the master volume, but it might  
help! Or you might be able to read the code and adapt it to your needs.

Cheers!  
Ben

---

<div class="post-metadata">

**Author:** ![pavel989](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/48db29/32.png) [@pavel989](https://www.ruby-forum.com/u/pavel989)\
**Post date:** [December 31, 2007, 12:28am UTC](https://www.ruby-forum.com/t/virtual-key-codes/124114/8 "2007-12-31T00:28:27Z")

</div>

> You might look at the win32utils project on Rubyforge:  
> [http://win32utils.rubyforge.org/](http://win32utils.rubyforge.org/)
> 
> It contains a library called win32-sound, which appears to be able to  
> set the wave output volume. It’s not the master volume, but it might  
> help! Or you might be able to read the code and adapt it to your needs.
> 
> Cheers!  
> Ben

i think thisll do!  
thnx!

---

<div class="post-metadata">

**Author:** ![pavel989](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/48db29/32.png) [@pavel989](https://www.ruby-forum.com/u/pavel989)\
**Post date:** [December 29, 2007, 9:03pm UTC](https://www.ruby-forum.com/t/virtual-key-codes/124114/9 "2007-12-29T21:03:01Z")

</div>

On Sun, Dec 30, 2007, Marc H. wrote:

> > All that information is necessary to help.
> 
> I dont think all that information is necessary to help.

Sure it is.

> But I agree completely on one point - WHAT is a virtual key?
> 
> Is that a key used in an online game? Or one you would like to have on  
> your keyboard, but don’t have? 🙂

Assuming either one is what he was asking, there’s no way to give an  
answer without knowing what platform you’re trying to do it on.

Ben
