Major plugin updates

This commit is contained in:
Lea Anthony
2024-04-14 21:41:33 +10:00
parent cf130a6e25
commit c7ed7e72d4
52 changed files with 1155 additions and 326 deletions
@@ -0,0 +1,34 @@
//go:build windows
package single_instance
import (
"github.com/wailsapp/wails/v3/pkg/w32"
"syscall"
)
type enumWindowsCallback func(hwnd syscall.Handle, lParam uintptr) uintptr
func enumWindowsProc(hwnd syscall.Handle, lParam uintptr) uintptr {
_, processID := w32.GetWindowThreadProcessId(uintptr(hwnd))
targetProcessID := uint32(lParam)
if uint32(processID) == targetProcessID {
// Bring the window forward
w32.SetForegroundWindow(w32.HWND(hwnd))
}
// Continue enumeration
return 1
}
func (p *Plugin) activeInstance(pid int) error {
// Get the window associated with the process ID.
targetProcessID := uint32(pid) // Replace with the desired process ID
w32.EnumWindows(
syscall.NewCallback(enumWindowsCallback(enumWindowsProc)),
uintptr(targetProcessID),
)
return nil
}