Simulate multimedia key presses in Delphi -


I should use multimedia keys (like play / pause, back / next track, rewards / forward, etc.) ) In Delphi, I can easily simulate the 'normal' key using the next code:

  keybd_event (VK_SPACE, 0, 0, 0); Keybd_event (VK_SPACE, 0, KEYEVENTF_KEYUP, 0);   

In addition, I have found a list of Mac / BREAK codes, but what should I do with them?

MSDN says:

  VOID keybd_event (BYTE bVk, // virtual key code byte bScan, // hardware scan code DWORD dwFlags, // flags different function options DWORD dwExtraInfo to specify / data associated with additional string;); BBCK - The virtual-key code specifies that the code must have a value in the range of 1 to 254. BScan specifies a hardware scan code for the key - DwFlags - A set of flag bits which specifies the different aspects of the function operation. An application can use any combination of the following predefined constant values ​​to set the flag: KEYEVENTF_EXTENDEDKEY - If specified, the scan code was first by the prefix byte with the value 0xE0 (224). If KEYEVENTF_KEYUP is specified, the key is being issued. If not specified, the key is disappointed DwExtraInfo - specifies an additional 32-bit value associated with the key stroke.   

I've found the scan code for the volume up:

code: E0, 32 break code: E0, F0, 32 < / Blockquote>

I tried:

  keybd_event (0, $ 32, KEYEVENTF_EXTENDEDKEY, 0); Keybd_event (0, $ 32, KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0);   

But with no luck (it should emulate E32 32, without F 0). Apart from this, MSDN says that Biwek should be [1..254], and I used 0 because I did not find anything suitable in the main code list.

This works for me in Delphi X3:

  Keybd_event (VK_VOLUME_UP {$ AF}, 0, 0, 0); Keybd_event (VK_VOLUME_UP, 0, keyEventFKKUUUP, 0);   

If these constants are not declared in your Delphi version,

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -