让MediaPlayer全屏

// 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;
}
 
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值