Global hotkeys in windows

I built a script that does a job for me, and I'd like to call from time
to time, even when the script isn't running. Is there a way I can assign
a global hot key in ruby so that whenever I press the hotkey it launches
it.

Ted.

···

--
Posted via http://www.ruby-forum.com/.

You'd need to use something like AutoHotkey for that. I've never used
it with Ruby, but it could be done.

···

On Sat, Oct 23, 2010 at 9:11 AM, Ted Flethuseo <flethuseo@gmail.com> wrote:

I built a script that does a job for me, and I'd like to call from time
to time, even when the script isn't running. Is there a way I can assign
a global hot key in ruby so that whenever I press the hotkey it launches
it.

Eric Christopherson wrote in post #956560:

You'd need to use something like AutoHotkey for that. I've never used
it with Ruby, but it could be done.

AutoHotkey would be more my area of knowledge. You might be interested
that AHK now has a DLL with COM support. This would make embedding AHK
in Ruby quite simple:

    require "WIN32OLE"

    code = "#NoTrayIcon\n" +
            "^m:: MsgBox, Hotkey created with AHK in Ruby"

    ahk = WIN32OLE.new("AutoHotkey.Script")
    ahk.AhkTextDll(code)

    puts "Press CTRL+M to display a Message Box with embedded AHK\n\n" +
         "Hit Enter to close the console & destroy the Hotkey ..."
    gets

If you want to know more, the AHK topic is here:
http://www.autohotkey.com/forum/topic43049.html

The actual DLL is part of the PACKAGE referenced here:

NOTE - you'd have to register the DLL using regsvr32.exe

···

--
Posted via http://www.ruby-forum.com/\.

Hi,
This is cool. I was wondering though.. is it preferable to copy the
AutoHotkey.dll file to some special location before registering it, or
does registering it mean that it actually copies it to some windows
directory. (Is there a specific windows directory for dlls?)

Ted

Jethrow .. wrote in post #956604:

···

Eric Christopherson wrote in post #956560:

You'd need to use something like AutoHotkey for that. I've never used
it with Ruby, but it could be done.

AutoHotkey would be more my area of knowledge. You might be interested
that AHK now has a DLL with COM support. This would make embedding AHK
in Ruby quite simple:

    require "WIN32OLE"

    code = "#NoTrayIcon\n" +
            "^m:: MsgBox, Hotkey created with AHK in Ruby"

    ahk = WIN32OLE.new("AutoHotkey.Script")
    ahk.AhkTextDll(code)

    puts "Press CTRL+M to display a Message Box with embedded AHK\n\n" +
         "Hit Enter to close the console & destroy the Hotkey ..."
    gets

If you want to know more, the AHK topic is here:
http://www.autohotkey.com/forum/topic43049.html

The actual DLL is part of the PACKAGE referenced here:
autohotkey.net - This website is for sale! - autohotkey Resources and Information.

NOTE - you'd have to register the DLL using regsvr32.exe (or you could
use the DLL directly w/o the COM interface)

--
Posted via http://www.ruby-forum.com/\.

Ted Flethuseo wrote in post #956795:

... does registering it mean that it actually copies it to some windows
directory. (Is there a specific windows directory for dlls?

Registering does not create a copy. Registering will make it so you can
create a COM object (WIN32OLE.new), but the DLL will remain wherever it
was when you registered it. Personally, I keep it in the same directory
as my AHK installation. However, many DLL files are located in the
Windows Directory.

On a side note, the maintainer of the DLL has been updating it regularly
recently. He provided a direct link for the Windows (32 bit) Unicode
version: autohotkey.net - This website is for sale! - autohotkey Resources and Information.

···

--
Posted via http://www.ruby-forum.com/\.

To practice a little bit, I made some simple scripts to demonstrate
using AutoHotkey with Ruby, and put them on GitHub. What I have so far
is at:

···

On Sun, Oct 24, 2010 at 11:34 PM, Jethrow .. <jethrow@gmx.com> wrote:

Ted Flethuseo wrote in post #956795:

... does registering it mean that it actually copies it to some windows
directory. (Is there a specific windows directory for dlls?

Registering does not create a copy. Registering will make it so you can
create a COM object (WIN32OLE.new), but the DLL will remain wherever it
was when you registered it. Personally, I keep it in the same directory
as my AHK installation. However, many DLL files are located in the
Windows Directory.

On a side note, the maintainer of the DLL has been updating it regularly
recently. He provided a direct link for the Windows (32 bit) Unicode
version: autohotkey.net - This website is for sale! - autohotkey Resources and Information.

Thanks Eric.
That will be useful for sure.

Ted

Eric Christopherson wrote in post #957129:

···

On Sun, Oct 24, 2010 at 11:34 PM, Jethrow .. <jethrow@gmx.com> wrote:

On a side note, the maintainer of the DLL has been updating it regularly
recently. He provided a direct link for the Windows (32 bit) Unicode
version: http://www.autohotkey.net/~HotKeyIt/AutoHotkey.dll

To practice a little bit, I made some simple scripts to demonstrate
using AutoHotkey with Ruby, and put them on GitHub. What I have so far
is at:

GitHub - echristopherson/ahk_drb_demo: Demo of using AutoHotkey with Ruby and DRb

--
Posted via http://www.ruby-forum.com/\.