Windows hotkeys in Ruby

Hi,
as a tutorial to Ruby learning, I'm trying to create a clone of a
Windows program, RndSig, which allows, from the stroke of a "global
hotkey" (I don't know if this expression is fully exact), to take the
content of current text editor in order to choose from it the most
accurate signature.
The signature selection has already been done.
But, now, I want to be able to execute the active part of the script
(launching can occur at session start) from a hotkey, and allow it to
copy the content of the current text area.
Is it possible using Ruby ? I think it will imply some use of the
WIN32API "module" (is it the right word ?), but how ...
From the initial program, the content of the text area was copied to
the clipboard, and then used in the program (don't know if it can be
of any help). And, were you willing to test it, it is available at
http://www.lacave.net/~fred/divers/rndsig.html
Thanks

···

--
Nicolas Delsaux
"Si tu peux voir détruire l'ouvrage de ta vie et, sans dire un seul
mot, te remettre à le rebâtir, tu seras un homme, mon fils."
Rudyard Kipling

But, now, I want to be able to execute the active part of the script
(launching can occur at session start) from a hotkey, and allow it to
copy the content of the current text area.
Is it possible using Ruby ? I think it will imply some use of the
WIN32API "module" (is it the right word ?), but how ...

There's RegisterHotKey()
http://www.google.com/search?hl=en&q=registerhotkey

You might be able to call that via Win32API, but, you'll
need a window handle too.

Regards,

Bill

···

From: "Nicolas Delsaux" <nicolas.delsaux@gmail.com>

Nicolas Delsaux wrote:

Hi,
as a tutorial to Ruby learning, I'm trying to create a clone of a
Windows program, RndSig, which allows, from the stroke of a "global
hotkey" (I don't know if this expression is fully exact), to take the
content of current text editor in order to choose from it the most
accurate signature.

If you get stuck on this and just want to get it done, you might
consider creating a Windows shortcut to "ruby rndsig.rb", then
add a global hotkey to the shortcut's "Properties".

Pressing the global hotkey will fire up "rndsig.rb" which would
need to find the "source" window, copy the text, choose a .sig
based on that text, then paste it back and close.

would facilitate that.

You'll learn more by doing it the hard way but I'd suggest that
Ruby (on its own) isn't your best tool for this.

daz

Thanks.
From what I can see, " If this parameter is NULL, WM_HOTKEY messages
are posted to the message queue of the calling thread and must be
processed in the message loop.". Is it to say that, provided i have a
running Ruby thread (or the local equivalent to this Java word)
running, I will be able to recieve "events" ?
If it is the case, it seems to me rather simple, isn't it ?

···

On Wed, 23 Mar 2005 02:06:09 +0900, Bill Kelly <billk@cts.com> wrote:

There's RegisterHotKey()
registerhotkey - Google Search

You might be able to call that via Win32API, but, you'll
need a window handle too.

--
Nicolas Delsaux
"Chasseur-elle-bat-le-beurre a des idées bien arrêtées sur la
dynamique sémantique de la taxonomie idéologique"
Chasseur-idiot alias Socrate in frjn en tant que métaphore
conceptuelle économique

>
> There's RegisterHotKey()
> registerhotkey - Google Search
>
> You might be able to call that via Win32API, but, you'll
> need a window handle too.

Thanks.
From what I can see, " If this parameter is NULL, WM_HOTKEY messages
are posted to the message queue of the calling thread and must be
processed in the message loop.". Is it to say that, provided i have a
running Ruby thread (or the local equivalent to this Java word)
running, I will be able to recieve "events" ?
If it is the case, it seems to me rather simple, isn't it ?

Ah - cool, I missed the part about passing in NULL.

Note, that all Ruby threads really run in the same operating
system thread. This means if you call an operating system
function that blocks, all of your ruby threads will wait until
it returns. This can sometimes make things challenging; but
for what you're doing I don't think it will be an issue.

Sounds like you can call RegisterHotKey() ... then start calling
either PeekMessage() or GetMessage() and watch for your WM_HOTKEY
messages.

Regards,

Bill

···

From: "Nicolas Delsaux" <nicolas.delsaux@gmail.com>

On Wed, 23 Mar 2005 02:06:09 +0900, Bill Kelly <billk@cts.com> wrote: