Old 04-18-2008, 04:53 AM   #1
Deric
Human being with feelings
 
Join Date: Mar 2007
Posts: 794
Default Virtual-Key Code support?

Hi,

Anyone know if VK-Key codes are (fully) supported in REAPER's API?

VK_SHIFT is shown as used in the MCU .cpp but as I'm not using an MCU I can't verify it works.

I've tried using a bunch of VK codes (should've tested just one first eh?) and can't get them to work.

For example:

VK_LBUTTON, VK_RBUTTON, VK_MENU, VK_CONTROL, VK_RETURN, VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN.

If VK codes aren't fully implemented (yet?) would it be possible to implement the above, at the least, please? These functions would be very useful for control surface support.

If they are implemented is there anything I need to #Include (or anything else?) to use them?

Anyone?

Thank you!
__________________
REAPER? Oh yes...
Deric is offline   Reply With Quote
Old 04-18-2008, 05:25 AM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,673
Default

They are defined somewhere in the MS Windows header files, let me take a look...To use them, you will be sending them with a SendMessage Windows API function into Reaper.
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 04-18-2008, 05:28 AM   #3
Deric
Human being with feelings
 
Join Date: Mar 2007
Posts: 794
Default

Hi Xenakios,

Thanks.

Yes I'm using Sendmessage(etc

Cheers!



Edit: i.e. SendMessage(g_hwnd,WM_COMMAND,VK_LBUTTON,0);
__________________
REAPER? Oh yes...
Deric is offline   Reply With Quote
Old 04-18-2008, 05:38 AM   #4
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,673
Default

Seems the virtual keycodes are defined in WINUSER.H

Of course, to actually use them (in combination with letter keys etc) seems, like usual with the win32 API stuff, more complicated than necessary, but I am sure you'll eventually find the correct method of doing it by googling 'sending keystrokes sendmessage' etc...
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 04-18-2008, 05:40 AM   #5
Deric
Human being with feelings
 
Join Date: Mar 2007
Posts: 794
Default

So I need to Include WINUSER.H?
__________________
REAPER? Oh yes...
Deric is offline   Reply With Quote
Old 04-18-2008, 05:43 AM   #6
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,673
Default

Yes, I think so...I could not find #include WINUSER.H in my own source codes, but it must have been included somewhere as I have succesfully used VK_CONTROL at one place in my code...
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 04-18-2008, 05:50 AM   #7
Deric
Human being with feelings
 
Join Date: Mar 2007
Posts: 794
Default

OK mate thanks, I'll try that - this is such a PITA for the 'casual user' to try and do good stuff without any supporting documentation...

Thank Xenakios
__________________
REAPER? Oh yes...
Deric is offline   Reply With Quote
Old 04-18-2008, 05:55 AM   #8
Deric
Human being with feelings
 
Join Date: Mar 2007
Posts: 794
Default

Just so you know - it's called WinUser.h

(i.e. Upper case 'W' and 'U')

I'll try it out now...

Thanks again!
__________________
REAPER? Oh yes...
Deric is offline   Reply With Quote
Old 04-18-2008, 06:03 AM   #9
Deric
Human being with feelings
 
Join Date: Mar 2007
Posts: 794
Default

Didn't work when I did this:

#include "WinUser.h"

I added this to csurf_mcu.cpp

It compiled OK but still the key does not function.

I'm adding it in the same place in the SendMessage command that I've added REAPER Command Identifiers to successfully.
__________________
REAPER? Oh yes...

Last edited by Deric; 04-18-2008 at 06:04 AM. Reason: Typo
Deric is offline   Reply With Quote
Old 04-18-2008, 06:12 AM   #10
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,673
Default

WM_COMMAND is not the correct message to send to the Reaper window when you need to send simulated keyboard presses, it's something like WM_KEYDOWN, and as I said to reliably send combinations of keys like CTRL+U is complicated, and I was not able to quickly find a conclusive solution to that from a Google search.
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 04-18-2008, 06:15 AM   #11
Deric
Human being with feelings
 
Join Date: Mar 2007
Posts: 794
Default

I see, sorry I misunderstood you.

OK, I'll try that and do (yet another, Google search...).

I'm not trying to send combinations, just single key-commands triggered from a MIDI message.

Thanks for the tip, I'll try it now.

__________________
REAPER? Oh yes...
Deric is offline   Reply With Quote
Old 04-18-2008, 09:32 AM   #12
Deric
Human being with feelings
 
Join Date: Mar 2007
Posts: 794
Default

I still can't get this to work...
__________________
REAPER? Oh yes...
Deric is offline   Reply With Quote
Old 05-09-2008, 03:58 AM   #13
Deric
Human being with feelings
 
Join Date: Mar 2007
Posts: 794
Default

Anyone able to help/guide/point me in the right direction to be able to send VK commands into REAPER please?

I've a useful list of such things as mouse-clicks, ALT/CTRL etc, but still can't seem to get these into REAPER.

What 'SendMessage'-type-of-command will I need to try to send a VK code?

Anybody? Please??

Cheers!

Deric.
__________________
REAPER? Oh yes...
Deric is offline   Reply With Quote
Old 05-09-2008, 06:50 PM   #14
robg
Human being with feelings
 
Join Date: Sep 2007
Location: Atascadero, CA
Posts: 305
Default

There was a really nice utility in VB6 called the API Text Viewer that you could use to look up constants & see which file they were declared in. Unfortunately, it doesn't look like it's in Visual Studio 2008

Probably the easiest way, if you know the constant/api name, etc. is to go to http://msdn.microsoft.com & just put it in the search box. The 1st result will almost always be what you're looking for, and it has a section like

Minimum DLL Version None
Header Declared in Winuser.h, include Windows.h
Minimum operating systems Windows 95, Windows NT 3.1

I know this doesn't help you resolve your "How to" problem, Deric, but I hope it points you in the right direction.
robg is offline   Reply With Quote
Old 05-10-2008, 08:18 AM   #15
sws
Code Monkey
 
sws's Avatar
 
Join Date: Sep 2007
Location: Madison, WI
Posts: 851
Default

Hey Deric,
As Xen said, you really can't send "complex" keystrokes into Reaper very easily. If you're trying to just call a command, use the Main_OnCommand() functionality.

Are you trying to use a button on the control surface as a shift/control/alt key for modifying mouse events? Then use the control surface class funtion IsKeyDown(). Reaper calls this function in your code everytime it needs to know if there are keys down. You return true if that key is pressed on your surface. In the MCU code it's like this:
Code:
    bool IsKeyDown(int key) 
    { 
      if (m_midiin && !m_is_mcuex)
      {
        if (key == VK_SHIFT) return !!(m_mackie_modifiers&1);
        if (key == VK_CONTROL) return !!(m_mackie_modifiers&4);
        if (key == VK_MENU) return !!(m_mackie_modifiers&8);
      }
VK_MENU is the "ALT" key.

Single keystrokes are easily sent with:
Code:
PostMessage(hwnd, WM_KEYDOWN, key, 0);
PostMessage(hwnd, WM_KEYUP, key, 0);
I can't find a way to make mouseclicks work, unfortunately.

Hope this helps!
sws is offline   Reply With Quote
Old 05-10-2008, 09:53 AM   #16
Deric
Human being with feelings
 
Join Date: Mar 2007
Posts: 794
Default

Hi SWS!

Yes I looked at the IsKeyDown stuff - but didn't understand how to use it...

What I want to do is this:

A key (on the control surface) is pressed - let's say that key sends a MIDI note '0x3A' (for example), I then want that key press to generate a VK command in to REAPER.

i.e. 'When you receive 0x3A, send mouse right-click' for example.

Can this be done with your example?

Thanks for replying!

Cheers

Deric
__________________
REAPER? Oh yes...
Deric is offline   Reply With Quote
Old 05-10-2008, 10:07 AM   #17
sws
Code Monkey
 
sws's Avatar
 
Join Date: Sep 2007
Location: Madison, WI
Posts: 851
Default

Deric,

I tried a couple things but I wasn't able to "insert" mouse clicks into reaper, sorry. The IsKeyDown is basically so you can use an alternate shift/control/alt key on your surface instead of the keyboard.
sws is offline   Reply With Quote
Old 05-10-2008, 10:11 AM   #18
Deric
Human being with feelings
 
Join Date: Mar 2007
Posts: 794
Default

Quote:
Originally Posted by sws View Post
...The IsKeyDown is basically so you can use an alternate shift/control/alt key on your surface instead of the keyboard.
Hi SWS,

I really don't know what I'm talking about here but... The MCU has CTRL, ALT, and SHIFT keys built into its surface (under the 'Modifiers' section).

I think the code (pasted from the MCU map) is 'simply' checking whether that specific VK code has been 'received' from the surface... no?

i.e. I don't think it's (the code) 'generating' an ALT/CTRL/etc

Deric.

Edit: i.e. I don't think IsKeyDown is 'translating' commands.
__________________
REAPER? Oh yes...

Last edited by Deric; 05-10-2008 at 10:16 AM. Reason: Clarity
Deric is offline   Reply With Quote
Old 05-10-2008, 10:39 AM   #19
sws
Code Monkey
 
sws's Avatar
 
Join Date: Sep 2007
Location: Madison, WI
Posts: 851
Default

Yeah, Reaper uses IsKeyDown to "ask" if the control surface has a shift/control/alt key pressed.
sws 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 09:05 AM.


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