New action proposition: send API message
Posted: Tue Oct 10, 2017 1:29 am
A long time proposition, minor but powerful.
API messages are quite nice to achieve things. Usually API messages are used for advanced effects, yet for some tools it's the way how user could trigger the action.
The example would be MPC-HC. If you have it, check of keyboard shortcut option and look for the column ID. Sorry for promoting here other tools, but I think they nicely add up to themselves, I use them both. So here's the script in AutoHotKey (for interested people, it will be explained)
When I press backspace it sends message 907, with enter it sends 908. By looking at the ID column of the shortcut options, it gives us volume up/down. Why not just simulated keystrokes? Because it's something that is not the same for every instance, it's the setting that user can change. With such script, I can change keyboard shortcuts in the MPC-HC, but the script will still work, because it directly triggers action, not keys. And such thing would be perfect. I know it's a lot to do. I'm just proposing, I don't need it currently that much, but that would make XMBC more powerful.
For such message, three fields would be needed:
* two integers* for message (in the example it sends 273 [0x0111 is hexadecimal] which means 'trigger user action' and then the proper code for the action
* window where message should be sent (XMBC has already great window selector, with classes, regexpes and wow, so it's basically done)
* as far as I remember, technically it was one integer, just high and low part, but it's been like 15 years since I had to go for such low level of developing, thankfully Oh well, but it was kinda fun and it made me understand how things works
API messages are quite nice to achieve things. Usually API messages are used for advanced effects, yet for some tools it's the way how user could trigger the action.
The example would be MPC-HC. If you have it, check of keyboard shortcut option and look for the column ID. Sorry for promoting here other tools, but I think they nicely add up to themselves, I use them both. So here's the script in AutoHotKey (for interested people, it will be explained)
Code: Select all
#IfWinActive ahk_class MediaPlayerClassicW ; remove it to make keys global
MPCHC(msg)
{
SendMessage,0x0111,msg,,,ahk_class MediaPlayerClassicW
}
Backspace::MPCHC(907)
Enter::MPCHC(908)
For such message, three fields would be needed:
* two integers* for message (in the example it sends 273 [0x0111 is hexadecimal] which means 'trigger user action' and then the proper code for the action
* window where message should be sent (XMBC has already great window selector, with classes, regexpes and wow, so it's basically done)
* as far as I remember, technically it was one integer, just high and low part, but it's been like 15 years since I had to go for such low level of developing, thankfully Oh well, but it was kinda fun and it made me understand how things works