OSC to keystroke

Is there an app that lets you convert OSC messages into keystrokes?

Example:

When I press a button I want osc to spit out a keystroke to launch a program trough ahk

https://www.autohotkey.com/boards/viewtopic.php?style=17&t=89647&p=395982

1 Like

how do you install it ?

install ahk, compile a script from the examples folder, mess around a lot. Ask back here if you have issues, happy to help.

1 Like

ok, got it workign.

I used the example script to let ahk pop up a message box when I receive a osc message.

How to I replace that message box with a keystroke?

https://www.autohotkey.com/docs/Tutorial.htm#s3

Have fun!

1 Like

what part do i need to change to a output ? i already have a small ahk script that launches plugins when i press a button but how do i implement it in here ?

so replace the first messagebox line with

Send,^!x

and when you send an integer from o-s-c with the address /test1 then you'll get ctrl + alt + x

1 Like

What line are you referring to ?

; Load DLL and open network port for OSC (7001)
    DllCall("LoadLibrary", "Str", "OSC2AHK.dll", "Ptr")
    DllCall("OSC2AHK.dll\open", UInt, hWnd, UInt, 8000)

; Tell the DLL to post a system message with ID 0x1001 when a OSC message with address "/test1" and type Integer or Float is received.
DllCall("OSC2AHK.dll\addListener", AStr, "/test1", UInt, 0x1001, UInt, oscTypeInt+oscTypeFloat)
; Tell AHK to invoke the function msghandlerTest1 when a windows message with ID 0x1001 is received
OnMessage(0x1001, "msghandlerTest1")

; This function effectively is called for each OSC message as specified above
msghandlerTest1(oscType, data, msgID, hwnd) 
{
; Check which datatype we received (above we accepted Float and Int)
if (oscType = oscTypeInt) 
{
    ; Integers can be used "as is"
    msgbox,Got Integer: %data%
}
if (oscType = oscTypeFloat) 
{
    ; Floats have to be "reinterpreted"
    VarSetCapacity(buf, 4, 0)
    NumPut(data, buf)
    theFloat := NumGet(buf, "Float")

    msgbox,Got Float: %theFloat%
}
}

got it working thank you ! now i can launch plugins inside ableton on my tablet with AHK scripting

:+1:

Glad you got it sorted!

1 Like

i fucked up something but i don't know what, what is the reason why I can't get the box appear?

#NoEnv
; #Warn
SendMode Input
SetWorkingDir %A_ScriptDir%  ; Until here, this is the default script template
; Get handle to this running script instance
Gui +LastFound
hWnd := WinExist()

; just for convenience, you also could use the "magic numbers" directly
global oscTypeNone := 1
global oscTypeInt := 2
global oscTypeFloat := 4
global oscTypeString := 8
global oscTypeAll := 0xffffffff

; Load DLL and open network port for OSC (7001)
DllCall("LoadLibrary", "Str", "OSC2AHK.dll", "Ptr")
DllCall("OSC2AHK.dll\open", UInt, hWnd, UInt, 8000)

; Tell the DLL to post a system message with ID 0x1001 when a OSC message with address "/test1" and type Integer or Float is received.
DllCall("OSC2AHK.dll\addListener", AStr, "/test1", UInt, 0x1001, UInt, oscTypeInt+oscTypeFloat)
; Tell AHK to invoke the function msghandlerTest1 when a windows message with ID 0x1001 is received
OnMessage(0x1001, "msghandlerTest1")

; This function effectively is called for each OSC message as specified above
msghandlerTest1(oscType, data, msgID, hwnd) 
{
; Check which datatype we received (above we accepted Float and Int)
if (oscType = oscTypeInt) 
{
    ; Integers can be used "as is"
    msgbox,Got Integer: %data%
}
if (oscType = oscTypeFloat) 
{
    ; Floats have to be "reinterpreted"
    VarSetCapacity(buf, 4, 0)
    NumPut(data, buf)
    theFloat := NumGet(buf, "Float")

    msgbox,Got Float: %theFloat%
}
}

; Shutdown the script with Shift+ESC
+Esc::
ExitApp
indent preformatted text by 4 spaces