Created
October 29, 2021 00:09
-
-
Save kaecy/7dff9e5909a6d2bfee91025ab693b145 to your computer and use it in GitHub Desktop.
lame foobar2000 remote controller.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdio.h" | |
#include "windows.h" | |
void sendContrlKey(int vKeyCode) { | |
INPUT inputs[4]; | |
ZeroMemory(inputs, sizeof(inputs)); | |
inputs[0].type = INPUT_KEYBOARD; | |
inputs[0].ki.wVk = VK_CONTROL; | |
inputs[1].type = INPUT_KEYBOARD; | |
inputs[1].ki.wVk = vKeyCode; | |
inputs[2].type = INPUT_KEYBOARD; | |
inputs[2].ki.wVk = VK_CONTROL; | |
inputs[2].ki.dwFlags = KEYEVENTF_KEYUP; | |
inputs[3].type = INPUT_KEYBOARD; | |
inputs[3].ki.wVk = vKeyCode; | |
inputs[3].ki.dwFlags = KEYEVENTF_KEYUP; | |
SendInput(4, inputs, sizeof(INPUT)); | |
} | |
void sendSingleKey(int vKeyCode) { | |
INPUT inputs[2]; | |
ZeroMemory(inputs, sizeof(inputs)); | |
inputs[0].type = INPUT_KEYBOARD; | |
inputs[0].ki.wVk = vKeyCode; | |
inputs[1].type = INPUT_KEYBOARD; | |
inputs[1].ki.wVk = vKeyCode; | |
inputs[1].ki.dwFlags = KEYEVENTF_KEYUP; | |
SendInput(2, inputs, sizeof(INPUT)); | |
} | |
void printSong() { | |
char title[512]; | |
HWND playerWindow; | |
playerWindow = FindWindow("{97E27FAA-C0B3-4b8e-A693-ED7881E99FC1}", 0); | |
GetWindowText(playerWindow, title, 512); | |
printf("%s\n", title); | |
} | |
void playSong() { | |
sendSingleKey(VK_MEDIA_PLAY_PAUSE); | |
Sleep(500); | |
printSong(); | |
} | |
void nextSong() { | |
sendSingleKey(VK_MEDIA_NEXT_TRACK); | |
Sleep(500); | |
printSong(); | |
} | |
void prevSong() { | |
sendSingleKey(VK_MEDIA_PREV_TRACK); | |
Sleep(500); | |
printSong(); | |
} | |
int main(int argc, char * argv[]) { | |
if (argc > 1) { | |
if (strcmp("play", argv[1]) == 0) { | |
playSong(); | |
} | |
else if (strcmp("next", argv[1]) == 0) { | |
nextSong(); | |
} | |
else if (strcmp("prev", argv[1]) == 0) { | |
prevSong(); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment