#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "dll.h"
typedef union {
struct {
unsigned int repeticion:16;
unsigned int scan:8;
unsigned int extendida:1;
unsigned int reservado:4;
unsigned int contexto:1;
unsigned int previo:1;
unsigned int transicion:1;
};
unsigned int lParam;
}keyData;
static HHOOK hookteclado;
static HINSTANCE hInstance;
DLLIMPORT LRESULT CALLBACK KeyboardProc(int code, WPARAM wParam, LPARAM lParam)
{
int tecla=(int)wParam;
keyData info_tecla;
info_tecla.lParam=lParam;
if(code>=0 && code!=HC_NOREMOVE)
{
//CTRL + ALT + 'hot key'
if(info_tecla.transicion==0 && info_tecla.contexto==1 && HIBYTE(GetKeyState(VK_CONTROL)))
SendMessage(FindWindowEx(NULL, NULL, "Winamp v1.x", NULL), WM_KEYDOWN, tecla, 0);
}
return CallNextHookEx(NULL, code, wParam, lParam);
}
DLLIMPORT void activa_hook()
{
hookteclado = SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,hInstance,0);
}
DLLIMPORT void desactiva_hook()
{
UnhookWindowsHookEx(hookteclado);
}
BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
{
switch(reason)
{
case DLL_PROCESS_ATTACH:
hInstance=hInst;
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
hInstance=hInst;
break;
case DLL_THREAD_DETACH:
break;
}
return TRUE;
}