wa_hotkeys.h 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef WA_HOTKEYS
  2. #define WA_HOTKEYS
  3. /*
  4. ** #define IPC_GEN_HOTKEYS_ADD xxxx // pass a genHotkeysAddStruct * struct in data
  5. **
  6. ** To get the IPC_GEN_HOTKEYS_ADD IPC number, you need to do this:
  7. **
  8. ** genhotkeys_add_ipc=SendMessage(winampWindow,WM_WA_IPC,(WPARAM)&"GenHotkeysAdd",IPC_REGISTER_WINAMP_IPCMESSAGE);
  9. **
  10. ** Then you can use:
  11. **
  12. ** PostMessage(winampWindow,WM_WA_IPC,(WPARAM)&myGenHotkeysAddStruct,genhotkeys_add_ipc);
  13. */
  14. //flags for the genHotkeysAddStruct struct
  15. #define HKF_BRING_TO_FRONT 0x1 // calls SetForegroundWindow before sending the message
  16. #define HKF_HWND_WPARAM 0x2 // sets wParam with Winamp's window handle
  17. #define HKF_COPY 0x4 // copies returned text to the clipboard (using CF_TEXT)
  18. #define HKF_PLPOS_WPARAM 0x8 // sets wParam with current pledit position
  19. #define HKF_ISPLAYING_WL 0x10 // sets wParam to genHotkeysAddStruct's wParam if playing, lParam if not
  20. // uses IPC_ISPLAYING to check if playing
  21. #define HKF_SHOWHIDE 0x20 // brings Winamp to front or minimizes Winamp if already at front
  22. #define HKF_NOSENDMSG 0x40 // don't send any message to the winamp window
  23. #define HKF_COPYW 0x80 // copies returned text to the clipboard (using CF_UNICODETEXT)
  24. #define HKF_UNICODE_NAME 0x100 // set this when the 'name' is passed as a unicode string
  25. #define HKF_DISABLED 0x80000000
  26. #include "WinDef.h"
  27. typedef struct {
  28. char *name; //name that will appear in the Global Hotkeys preferences panel
  29. DWORD flags; //one or more flags from above
  30. UINT uMsg; //message that will be sent to winamp's main window (must always be !=NULL)
  31. WPARAM wParam; //wParam that will be sent to winamp's main window
  32. LPARAM lParam; //lParam that will be sent to winamp's main window
  33. char *id; //unique string to identify this command - case insensitive
  34. HWND wnd; //set the HWND to send message (or 0 for main winamp window)
  35. int extended[6]; //for future extension - always set to zero!
  36. } genHotkeysAddStruct;
  37. /*
  38. ** Before calling this function you need to setup the genHotkeysAddStruct struct
  39. **
  40. ** genHotkeysAddStruct test_key = {0}; // this will make the compiler zero the struct for you
  41. ** // though you can do it manually if you want to as well
  42. **
  43. ** UINT test_ipc = 0; // this will hold the uMsg value to look for in the assigned window proc
  44. **
  45. ** // then call the function to register the hotkey
  46. ** AddGlobalHotkey(&test_key,"Playback: Test key","Test_key",&test_ipc);
  47. **
  48. ** void AddGlobalHotkey(genHotkeysAddStruct *hotkey, char* name, char* id, int* ipc){
  49. ** UINT genhotkeys_add_ipc = 0;
  50. ** hotkey->wnd = 0;
  51. ** hotkey->flags = 0;
  52. ** hotkey->name = name;
  53. ** hotkey->id = id;
  54. ** *ipc = hotkey->uMsg = SendMessage(winampWindow,WM_WA_IPC,(WPARAM)&hotkey->id,IPC_REGISTER_WINAMP_IPCMESSAGE);
  55. **
  56. ** genhotkeys_add_ipc=SendMessage(winampWindow,WM_WA_IPC,(WPARAM)&"GenHotkeysAdd",IPC_REGISTER_WINAMP_IPCMESSAGE);
  57. ** PostMessage(winampWindow,WM_WA_IPC,(WPARAM)hotkey,genhotkeys_add_ipc);
  58. ** }
  59. */
  60. /*
  61. ** This shows how to detect the registered hotkey message
  62. ** then it's upto you what you do
  63. **
  64. ** LRESULT CALLBACK WinampWnd(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
  65. ** int ret = 0;
  66. **
  67. ** // handles the hotkey for the option :o)
  68. ** if(uMsg == test_ipc){
  69. ** // here you can do things needed for the hotkey you registered
  70. ** }
  71. **
  72. ** // do stuff before the winamp proc has been called
  73. **
  74. ** ret = CallWindowProc(WinampProc,hwnd,uMsg,wParam,lParam);
  75. **
  76. ** // do other stuff after the winamp proc has been called
  77. ** // then return the value from CallWindowProc(..)
  78. ** return ret;
  79. ** }
  80. */
  81. #endif