global hotkeys in windows.

T

Ted Flethuseo

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.
 
E

Eric Christopherson

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.
 
J

Jethrow ..

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

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

Ted Flethuseo

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:
 
J

Jethrow ..

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

Eric Christopherson

Ted Flethuseo wrote in post #956795:

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

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
 
T

Ted Flethuseo

Thanks Eric.
That will be useful for sure.

Ted


Eric Christopherson wrote in post #957129:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,143
Messages
2,570,822
Members
47,368
Latest member
michaelsmithh

Latest Threads

Top