Skip to content

Instantly share code, notes, and snippets.

@RoxasShadow
Last active December 20, 2015 09:09
Show Gist options
  • Select an option

  • Save RoxasShadow/6105601 to your computer and use it in GitHub Desktop.

Select an option

Save RoxasShadow/6105601 to your computer and use it in GitHub Desktop.
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define CENTER 0
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) {
HWND hwnd;
char *title;
// Get the window
if((hwnd = FindWindow("MediaPlayerClassicW", NULL)) == NULL) {
printf("MPC-HC not running.\n");
return 0;
}
// Get the title
title = (char*)malloc(sizeof(char)*1024);
GetWindowText(hwnd, title, 1024);
printf("%s%s\n", (strcmp(title, "Media Player Classic Home Cinema") == 0 ? "" : "Playing: "), title);
// Move the window to the center of the screen and set it in foreground
int x = CENTER == 1 ? GetSystemMetrics(0) / 2 - 100 : 0;
int y = CENTER == 1 ? GetSystemMetrics(1) / 2 - 100 : 0;
MoveWindow(hwnd, x, y, 100, 100, 1);
ShowWindowAsync(hwnd, SW_RESTORE);
SetForegroundWindow(hwnd);
//HWND btn = FindWindowEx(hwnd, NULL, "ToolbarWindow32", "");
//SendMessage(btn, BM_CLICK, 0, 0);
// dunno how to click pause button ;__;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment