1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Runtime.InteropServices;
- using UnityEngine;
- using WindowsHandler;
- public class WindowMin : MonoBehaviour
- {
- [DllImport("user32.dll")]
- public static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);
- [DllImport("user32.dll", EntryPoint = "FindWindow")]
- private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
- [DllImport("user32.dll")]
- static extern IntPtr GetForegroundWindow();
- // Start is called before the first frame update
- void Start()
- {
- Process[] pros=Process.GetProcesses();
- for (var i = 0; i < pros.Length; i++)
- {
- if(pros[i].ProcessName.Contains("Explore")||pros[i].ProcessName.Contains("explore")){
- pros[i].Kill();
- }
- }
- IReadOnlyList<WindowInfo> list=WindowEnumerator.FindAll();
- /* string mm="";
- Tools.WriteTxt(Application.streamingAssetsPath+"/2.txt",mm);
- for (int i = 0; i < list.Count; i++)
- {
- mm+="\n"+list[i].Title;
- UnityEngine.Debug.Log(list[i].Title);
- }
- Tools.WriteTxt(Application.streamingAssetsPath+"/2.txt",mm);*/
-
- string str = Tools.LoadString(Application.streamingAssetsPath + "/3.txt");
-
- //User32API.GetHandleByProcessName(str);
- IntPtr a=FindWindow(null,str);
- if(a!=IntPtr.Zero){
- Application.Quit();
- }
- ShowWindow(a, 2);
-
- ShowWindow(GetForegroundWindow(), 2);
- // StartCoroutine(AA());
- }
- IEnumerator AA(){
- yield return new WaitForSeconds(1);
- Application.Quit();
- }
- // Update is called once per frame
- void Update()
- {
- }
- }
|