// MediaPlayer.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <Windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
//print_window();
int ret;
//name:"Windows Media Player"
//1、找到WMP Skin Host类名窗口
HWND hWnd = FindWindow("WMP Skin Host",NULL);
HWND child = NULL;
char szClassName[256] ={0};
if (hWnd != NULL)
{
printf("find 1 = 0x%x\n",hWnd);
BOOL find = FALSE;
//2、找到带有子窗口名WMP Plugin UI Host的窗口句柄为child
do
{
child = FindWindowEx(hWnd, child, NULL, NULL);
GetClassName(child,szClassName,256);
if (child)
{
printf("szClassName = %s\n",szClassName);
if ( strcmp(szClassName,"WMP Plugin UI Host") == 0)
{
printf("find it\n");
break;
}
}
else
{
HWND hNextWnd = GetNextWindow(hWnd,GW_HWNDNEXT);
if (hWnd != NULL)
{
printf("find next wind =0x%x\n",hNextWnd);
}
else
{
printf("not find next wind \n");
}
hWnd = hNextWnd;
}
} while (1);
//system("pause");
ret = SendMessage(hWnd,WM_SYSCOMMAND,SC_MAXIMIZE,0);
ret = SendMessage(child,WM_SYSCOMMAND,SC_MAXIMIZE,0);
//3、child == WMP Plugin UI Host
HWND hVideoWnd = NULL;
do
{
hVideoWnd = FindWindowEx(child, hVideoWnd, NULL, NULL);
if (hVideoWnd)
{
GetClassName(hVideoWnd,szClassName,256);
printf("szClassName = %s\n",szClassName);
//if (strcmp(szClassName,"EVRVideoHandler") == 0)
{
SendMessage(hVideoWnd,WM_SYSCOMMAND,SC_MAXIMIZE,0);
SendMessage(hVideoWnd, WM_SYSKEYDOWN, VK_RETURN,1<<29);
//双击全屏
SendMessage(hVideoWnd, WM_LBUTTONDBLCLK, 0, 0);
//SendMessage(hVideoWnd,)
}
child = hVideoWnd;
printf("child 0x%x\n",child);
hVideoWnd = NULL;
}
else
{
printf("not find windowsEx\n");
break;
}
} while (1);
//system("pause");
//EnumChildWindows(hWnd, EnumChildProc, NULL);
//WMP Plugin UI Host
//EVRVideoHandler
}
else
{
printf("not find Windows Media Player!\n");
}
//ret = SendMessage(hWnd, WM_SYSKEYDOWN, VK_RETURN,1<<29);
//system("pause");
return 0;
}
}
让MediaPlayer全屏
最新推荐文章于 2022-09-12 18:23:46 发布