• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Multimedia Keyboard Without Multimedia Keys.

EvulMastah

๏̯͡๏﴿
Premium User
Joined
Aug 19, 2007
Messages
4,941
Solutions
11
Reaction score
352
Chojrak and myself created this hook for you (and us) to be able to change songs while in-game or w/e.

Its abilities? (Every key has to be assisted with left or right alt, eg. Left Alt + M)
  • Volume Up/Down (Up/Down arrow)
  • Play Next/Previous Song (Right/Left arrow)
  • (Un)Mute sound (M)
  • Play/Pause/Stop (P/P/L)
  • Hiding/Showing the console (K)
  • Self shut-down, d'oh (ESCAPE)
Main.cpp:
Code:
#include <windows.h>
#include "main.h"
#include <iostream>

int main(int argc, char *argv[])
{
    if(HWND hWnd = FindWindow(NULL, WINDOW_TITLE))
    {
        MessageBox(hWnd, "Application is already running!", "Error", MB_ICONERROR | MB_OK );
        exit(1);
    }

    system("title " WINDOW_TITLE);

    int key = NULL;
    std::string action = "";
    bool hiden = false;

    while(true)
    {
        if((GetAsyncKeyState(VK_LMENU) || GetAsyncKeyState(VK_RMENU)))
        {
            if(GetAsyncKeyState(VOLUME_UP))
            {
                key = VK_VOLUME_UP;
                action = "volume up";
            }
            else if(GetAsyncKeyState(VOLUME_DOWN))
            {
                key = VK_VOLUME_DOWN;
                action = "volume down";
            }
            else if(GetAsyncKeyState(PREV_TRACK))
            {
                key = VK_MEDIA_PREV_TRACK;
                action = "previous track";
            }
            else if(GetAsyncKeyState(NEXT_TRACK))
            {
                key = VK_MEDIA_NEXT_TRACK;
                action = "next track";
            }
            else if(GetAsyncKeyState(MEDIA_MUTE))
            {
                key = VK_VOLUME_MUTE;
                action = "(un)mute";
            }
            else if(GetAsyncKeyState(MEDIA_PP))
            {
                key = VK_MEDIA_PLAY_PAUSE;
                action = "play/pause";
            }
            else if(GetAsyncKeyState(MEDIA_STOP))
            {
                key = VK_MEDIA_STOP;
                action = "media stop";
            }
            else if(GetAsyncKeyState(SHOW_HIDE))
            {
                hide(hiden);
                hiden = hiden ? false : true;
            }
            else if(GetAsyncKeyState(SHUTDOWN))
                shutdown();

            if(key)
            {
                keybd_event(key, 0, 0, 0);
                std::cout << "Action: " << action << std::endl;
                Sleep(200);
                keybd_event(key, 0, KEYEVENTF_KEYUP, 0);
                key = NULL;
                action = "";
            }
        }

        Sleep(200);
    }
}

void hide(bool hiden)
{
    if(HWND hWnd = FindWindow(NULL, WINDOW_TITLE))
    {
        std::cout << "Action: " << (hiden ? "show" : "hide") << std::endl;
        ShowWindow(hWnd, (hiden ? SW_SHOW : SW_HIDE));
    }
}

void shutdown()
{
    std::cout << "Action: shutdown" << std::endl;
    Sleep(100);
    exit(1);
}
Main.h:
Code:
/* Volume Keys */
#define VK_VOLUME_UP    0xAF
#define VK_VOLUME_DOWN  0xAE
#define VK_VOLUME_MUTE  0xAD
/* Media Keys */
#define VK_MEDIA_NEXT_TRACK 0xB0
#define VK_MEDIA_PREV_TRACK 0xB1
#define VK_MEDIA_STOP       0xB2
#define VK_MEDIA_PLAY_PAUSE 0xB3
/* Other Keys */
#define VK_KEY_M    0x4D
#define VK_KEY_L    0x4C
#define VK_KEY_P    0x50
#define VK_KEY_K    0x4B
/* Navigation Keys */
#define VOLUME_UP   VK_UP
#define VOLUME_DOWN VK_DOWN
#define NEXT_TRACK  VK_RIGHT
#define PREV_TRACK  VK_LEFT
#define MEDIA_MUTE  VK_KEY_M
#define MEDIA_STOP  VK_KEY_L
#define MEDIA_PP    VK_KEY_P
#define SHOW_HIDE   VK_KEY_K
#define SHUTDOWN    VK_ESCAPE
/* misc */
#define WINDOW_TITLE "Multimedia Keyboard"

void hide(bool hiden);
void shutdown();

Compiled version in attachements.

Should it be in Programming Resources?
 

Attachments

Last edited:
Awesome work m8's! But it would we awesome if you could add it in tray like elf said :D
 
Back
Top