// written by prest0n
#include <stdio.h>
#include <windows.h>
////////////////////////////////////////////////////////////////////////
////////////////////////// configuration area //////////////////////////
////////////////////////////////////////////////////////////////////////
bool use_alt = TRUE; // require alt to be held down when using a hotkey?
#define volume_up 'A' // key to use for volume up
#define volume_down 'Z' // key to use for volume down
#define volume_mute 'C' // key to use for muting
#define next_song '2' // key to use for next song
#define prev_song '1' // key to use for previous song
#define pause_song '3' // key to use for play/pause
#define hotkey_toggle 'H' // the key to use to disable/enable the program
bool volume_sound_use = TRUE; // use a sound for changing volume?
#define volume_sound "dsfargeg" // if the above is true, what sound should be played
bool hotkey_sound_use = TRUE; // use a sound for toggling hotkeys?
#define hotkey_sound "C:\\Windows\\Media\\notify.wav" // if the above is true, what sound should be played
bool debug = FALSE; // debug mode anyone?
//////////////////////////////////////////////////////////////////////
///////////////////////// do not edit below //////////////////////////
//////////////////////////////////////////////////////////////////////
// for some reason, it wouldnt define these in winuser.h so i just copy pasted
#define VK_VOLUME_MUTE 0xAD
#define VK_VOLUME_DOWN 0xAE
#define VK_VOLUME_UP 0xAF
#define VK_MEDIA_NEXT_TRACK 0xB0
#define VK_MEDIA_PREV_TRACK 0xB1
#define VK_MEDIA_STOP 0xB2
#define VK_MEDIA_PLAY_PAUSE 0xB3
bool hotkey_enabled = TRUE;
// hehe..
#define KEYSTATE(vk) ((GetAsyncKeyState(vk) & 0x8000) ? TRUE : FALSE)
int main()
{
if (!debug) FreeConsole();
while(1)
{
if ((KEYSTATE(VK_LMENU) == TRUE) || (!use_alt))
{
if (hotkey_enabled == TRUE)
{
if (KEYSTATE(volume_up) == TRUE)
{
if (debug) printf("volume up\n");
keybd_event(VK_VOLUME_UP, 0xE9, 0, 0);
if (volume_sound_use) PlaySound(volume_sound, NULL, SND_ASYNC);
}
if (KEYSTATE(volume_down) == TRUE)
{
if (debug) printf("volume down\n");
keybd_event(VK_VOLUME_DOWN, 0xE9, 0, 0);
if (volume_sound_use) PlaySound(volume_sound, NULL, SND_ASYNC);
}
if (KEYSTATE(volume_mute) == TRUE)
{
if (debug) printf("volume mute\n");
keybd_event(VK_VOLUME_MUTE, 0xE9, 0, 0);
Sleep(500); // to prevent you from pressing it repeatedly *accidentally*
}
if (KEYSTATE(pause_song) == TRUE)
{
if (debug) printf("pause or play song\n");
keybd_event(VK_MEDIA_PLAY_PAUSE, 0xE9, 0, 0);
Sleep(500); // to prevent you from pressing it repeatedly *accidentally*
}
if (KEYSTATE(next_song) == TRUE)
{
if (debug) printf("next song\n");
keybd_event(VK_MEDIA_NEXT_TRACK, 0xE9, 0, 0);
Sleep(500); // to prevent you from pressing it repeatedly *accidentally*
}
if (KEYSTATE(prev_song) == TRUE)
{
if (debug) printf("previous song\n");
keybd_event(VK_MEDIA_PREV_TRACK, 0xE9, 0, 0);
Sleep(500); // to prevent you from pressing it repeatedly *accidentally*
}
}
if (KEYSTATE(hotkey_toggle) == TRUE)
{
if (debug) printf("hotkey toggled\n");
hotkey_enabled = !hotkey_enabled;
if (hotkey_sound_use) PlaySound(hotkey_sound, NULL, SND_ASYNC);
Sleep(500);
}
}
Sleep(100);
}
}