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.

On Sat, Oct 23, 2010 at 9:11 AM, Ted F. [email protected]
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.

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

Eric C. 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:
http://www.autohotkey.net/~HotKeyIt/AutoHotkey/

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

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 C. 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:
http://www.autohotkey.net/~HotKeyIt/AutoHotkey/

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

Ted F. 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: http://www.autohotkey.net/~HotKeyIt/AutoHotkey.dll

On Sun, Oct 24, 2010 at 11:34 PM, Jethrow … [email protected] 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:

http://github.com/echristopherson/ahk_drb_demo

Thanks Eric.
That will be useful for sure.

Ted

Eric C. wrote in post #957129:

On Sun, Oct 24, 2010 at 11:34 PM, Jethrow … [email protected] 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:

http://github.com/echristopherson/ahk_drb_demo

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs