mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-23 01:39:17 +01:00
e8113bfdf1
Add delay to macros from one millisecond to 60 seconds, macros with delays only run once until pressed again. Without delays, the macro can be repeated while held down. Profiles and settings are now back inside the application folder to help portability. It will remain in appdata as previous versions if DS4Windows is in a admin folder, I may try to add a setting for location saving. Import profile option will automatically go to the appdata profile folder, auto profiles and settings will automatically copy over. Option to delete the appdata folder if not in use in the settings tab, this way it helps with cleanup. Another fix for auto profiles startup bug Better reading of autoprofile program path names Now only one instance of DS4Windows is possible, if another DS4Tool or DS4Windows that is not this version is started, this DS4Windows comes back into focus. UI fixes
65 lines
2.2 KiB
C#
65 lines
2.2 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
using System.Threading;
|
|
using System.Runtime.InteropServices;
|
|
using System.Diagnostics;
|
|
|
|
|
|
namespace ScpServer
|
|
{
|
|
static class Program
|
|
{
|
|
[DllImport("user32.dll")]
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
static extern bool SetForegroundWindow(IntPtr hWnd);
|
|
|
|
[DllImport("user32.dll")]
|
|
private static extern IntPtr GetForegroundWindow();
|
|
|
|
/// <summary>
|
|
/// The main entry point for the application.
|
|
/// </summary>
|
|
[STAThread]
|
|
static void Main()
|
|
{
|
|
System.Runtime.GCSettings.LatencyMode = System.Runtime.GCLatencyMode.LowLatency;
|
|
try
|
|
{
|
|
System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.High;
|
|
}
|
|
catch
|
|
{
|
|
// Ignore problems raising the priority.
|
|
}
|
|
bool createdNew = true;
|
|
using (Mutex mutex = new Mutex(true, "MyApplicationName", out createdNew))
|
|
{
|
|
if (createdNew)
|
|
{
|
|
Application.EnableVisualStyles();
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
Application.Run(new ScpForm());
|
|
}
|
|
else
|
|
{
|
|
Process current = Process.GetCurrentProcess();
|
|
foreach (Process process in Process.GetProcessesByName(current.ProcessName))
|
|
{
|
|
if (process.Id != current.Id)
|
|
{
|
|
SetForegroundWindow(process.MainWindowHandle);
|
|
if (GetForegroundWindow() != process.MainWindowHandle)
|
|
{
|
|
Application.EnableVisualStyles();
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
Application.Run(new Alreadyrunning());
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|