Old 08-28-2015, 09:25 AM   #1
TopDog
Banned
 
Join Date: Jul 2015
Posts: 17
Default Reaper Win32 SendMessage/SendKeys

I'm trying to interactively control reaper from an external app by simply simulating key presses. (this allows for some easier automation and coding in better/easier languages such as C# .net/wpf)

1. I use SendMessage, PostMessage, or SendWait(.net)(requires focus, so I don't really use it) to send the keys to reaper.

2. I have used spy++ to make sure the exact keystrokes and settings are sent by the app as they are when I use the keyboard directly.

3. Reaper does not respond to the modifier keys.

4. The is probably not an issue with reaper as I have read that it is, in general, a problem with windows.

5. Does anyone have any advice on how to get it to work?

6. If I allow reaper to handle the modifiers and my app just sends the "normal key" then it works. i.e., I have no problem getting reaper to respond to sending normal keys like a, b, c, 1, 2, 3.

e.g., Suppose I have an action in reaper defined as "ctrl-1"

If I have my app send the 1 and manually hold control then it will work. Of course, this won't work since it's no better than doing it by hand.

7. If I open actions/find shortcut, my app does send the control messages but always sends weird normal keys.

e.g., suppose my app sends Ctrl+Shift+1. In the "Find Shortcuts" reaper will display "Ctrl+Shift+[]" the [] never is what it is suppose to be.

Note though, again, spy++ is showing that I'm sending the right values in the right order with all the correct bit-fields set.



Essentially I send by using WM_KEYDOWN then WM_KEYUP. (I haven't tried WM_CHAR for normal keys, I guess that's the only thing left)


The confusing part is that it works partly for both "ends". I can send the modifiers and it's obvious reaper is getting them and I can send normal keys(which is what I'm doing now, but I have a limited number of normal key actions I can use and it's setting over my normal configuration). But I can't send both at the same time!!

Anyone know if this is even possible? Again, I know there are some issues with modifier keys that can't be resolved because of windows's flaws... but I'm not sure if that is the problem here since reaper is responding to them.
TopDog is offline   Reply With Quote
Old 08-28-2015, 11:40 AM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

If just running Reaper actions is enough, you should use WM_COMMAND messages. The actions window in Reaper shows you the currently valid command numbers.

But anyway...What's wrong with doing something like this with ReaScript in Python, Lua or EEL? You will be quite limited in what you can achieve by just sending Windows messages to Reaper anyway, so I am not sure what C#/.net would buy you here...
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 08-28-2015, 01:35 PM   #3
TopDog
Banned
 
Join Date: Jul 2015
Posts: 17
Default

Cool, I didn't you could do that!! What about custom actions? The command seems to be a guid?

How do you send a WM_COMMAND using SendMessage anyways?

SendMessage(reaper, hwnd, WM_COMMAND, reaperCommandID, 0)?
SendMessage(reaper, hwnd, WM_COMMAND, Low(reaperCommandID), High(reaperCommandID))?
TopDog is offline   Reply With Quote
Old 08-28-2015, 02:39 PM   #4
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by TopDog View Post
Cool, I didn't you could do that!! What about custom actions? The command seems to be a guid?

How do you send a WM_COMMAND using SendMessage anyways?

SendMessage(reaper, hwnd, WM_COMMAND, reaperCommandID, 0)?
SendMessage(reaper, hwnd, WM_COMMAND, Low(reaperCommandID), High(reaperCommandID))?
Unfortunately extension actions/custom actions/scripts will be difficult/impossible to call now from outside of Reaper. There is an Reaper API function to make a Windows message compatible number out of the GUIDs, but you can only call that from inside the Reaper process itself.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 08-28-2015, 03:30 PM   #5
TopDog
Banned
 
Join Date: Jul 2015
Posts: 17
Default

Well, that's not very good!
TopDog is offline   Reply With Quote
Old 08-31-2015, 12:07 PM   #6
TopDog
Banned
 
Join Date: Jul 2015
Posts: 17
Default

Quote:
Originally Posted by Xenakios View Post
Unfortunately extension actions/custom actions/scripts will be difficult/impossible to call now from outside of Reaper. There is an Reaper API function to make a Windows message compatible number out of the GUIDs, but you can only call that from inside the Reaper process itself.
Could one not simply make a C/C++ extension to reaper that make such api publicly available(to the outside world)? Seems like it shouldn't be too difficult to do?

It would be a better feature to be in sws rather than me hack something together. I would except something simple and direct(WM_COPYDATA, pipes or sockets... not com or other junk)... I suppose it should work on all OS's too. (although I'm not sure if reaper exposes it's message loop so either injecting a wndproc handler or simply providing a wrapper to some of the api would work)


Anyways, let me know if you guys are interesting in working it up... else I'll potentially do it myself when I get time. (right now I'm happy with what I've got but it's not very extensible)


(The main thing here is to expose a very simple and direct way to get at reaper's actions(custom or not) and not have to write the app as a reaper extension in the first place(which may work but ties my app directly to reaper))
I'm sure some decent solution can be had. If one could easily
TopDog is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:37 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.