using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
public class WindowMaxAndMin : MonoBehaviour
{
public static WindowMaxAndMin instance;
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);
[DllImport("user32.dll")]
static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll", EntryPoint = "FindWindow")]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
IntPtr ParenthWnd = FindWindow(null, "YJG-Intangible Cultural Heritage"); //build时候的项目名
const int SW_SHOWMINIMIZED = 2; //{最小化, 激活}
const int SW_SHOWMAXIMIZED = 3;//最大化
const int SW_SHOWRESTORE = 1;//还原
public string response;
public string oneselfURL;
private void Awake()
{
instance = this;
}
private void Start()
{
response = ConfigTest.dic["设置"]["softwareURL"];
oneselfURL = ConfigTest.dic["设置"]["oneselfURL"];
}
public void OnGetWindow()
{
}
public void OnMin()
{
if (response != null && !string.IsNullOrEmpty(oneselfURL))
{
string fileName = System.IO.Path.GetFileName(oneselfURL);
fileName = fileName.Split('.')[0];
Debug.Log(fileName);
OnClickMinimize(fileName);
}
}
public void OnMax()
{
if (response != null && !string.IsNullOrEmpty(response))
{
string fileName = System.IO.Path.GetFileName(response);
fileName = fileName.Split('.')[0];
Debug.Log(fileName);
OnClickMaximize(fileName);
}
}
public void OnClickMinimize(string _name)
{
ParenthWnd = FindWindow(null, _name);
//最小化
//Debug.Log("GetForegroundWindow = " + GetForegroundWindow() + " ParenthWnd = " + ParenthWnd);
// ShowWindow(GetForegroundWindow(), SW_SHOWMINIMIZED);
ShowWindow(ParenthWnd, SW_SHOWMINIMIZED);
//Invoke("OnClickMaximize", 5.0f) ;
}
public void OnClickMaximize(string _name)
{
ParenthWnd = FindWindow(null, _name);
//最大化
//ShowWindow(GetForegroundWindow(), SW_SHOWMAXIMIZED);
ShowWindow(ParenthWnd, SW_SHOWMAXIMIZED);
}
public void OnClickRestore()
{
//还原
ShowWindow(GetForegroundWindow(), SW_SHOWRESTORE);
}
}
12-26
07-13
1026
07-05
1528
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交