Hello,
I'm trying to bring to front the unity game when it is not the active window.
I've tried implenting a dll and later importing de "user32.dll" but is not working.
The code is something like this:
using System; using System.Collections.Generic; using System.Threading; using System.Runtime.InteropServices; using System.Diagnostics; using UnityEngine; using System.Collections;
public class AccesoDLL : MonoBehaviour {
[DllImport("SimpleDLL")]
private static extern byte cSum(byte b1, byte b2);
[DllImport("SimpleDLL")]
private static extern int MinimizarVentana(int u);
[DllImport("SimpleDLL")]
private static extern int MaximizarVentana(int u);
[DllImport("SimpleDLL")]
private static extern int GetWindowHandler();
[DllImport("user32.dll")]
[return: MarshalAs (UnmanagedType.Bool)]
private static extern bool SetForegroundWindow(int hWnd);
public int u;
void Awake() {
u = GetWindowHandler();
}
public void Minimizar () {
MinimizarVentana(u);
}
public void Maximizar () {
MaximizarVentana(u);
}
public void SetForegroundWindows(){
SetForegroundWindow(u);
}
}
The functions Maximizar and Minimizar are working on my own dll, but when I try yo use de API functions like SetForegroundWindow not work.
Does anybody know how to do this?
Thanks!