Features

Fehlermeldung beim mehrfachen Start (Error message when launching Cakedesk multiple times)

vor 2 JahrenAusstehend

Beim Start der App unter Windows erscheint eine kryptische Fehlermeldung, falls die App bereits läuft.

Mit einem kleinen PowerShell-Skript lässt sich das vermeiden:

```

# Cakedesk Launcher

Add-Type -AssemblyName System.Windows.Forms

$windowTitle = "Cakedesk"

$exePath = ".\Cakedesk.exe"

# Try to find the process by window title

$proc = Get-Process -ErrorAction SilentlyContinue |

Where-Object { $_.MainWindowTitle -eq $windowTitle } |

Select-Object -First 1

if ($proc) {

# Use P/Invoke to restore and focus the window

$signature = @'

[DllImport("user32.dll")]

public static extern bool SetForegroundWindow(IntPtr hWnd);

[DllImport("user32.dll")]

public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

'@

$type = Add-Type -MemberDefinition $signature -Name Win32ShowWindowAsync -Namespace Win32Functions -PassThru

$null = $type::ShowWindow($proc.MainWindowHandle, 9) # SW_RESTORE = 9

$null = $type::SetForegroundWindow($proc.MainWindowHandle)

} else {

# Start the application

Start-Process -FilePath $exePath -WindowStyle Normal

}

```

Zu Speichern unter `$HOME\AppData\Local\Programs\@cakedeskelectron\launcher.ps1`, Shortcut auf dem Desktop startet `powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File launcher.ps1`, Startverzeichnis ist Programmverzeichnis, „Fenster minimieren“.

Besteht da eine Chance, das einzubauen? 🙂

1 Kommentar

  1. Maxvor 2 Jahren

    Steffen Beyer Vielen Dank für deine rege Beteiligung und die konstruktiven Vorschläge. Auch ein super Feedback, das sich wahrscheinlich relativ easy umsetzen lässt :)