mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 06:33:56 +00:00
update activePid allow Windows via hwnd
This commit is contained in:
parent
bec5c1e9c3
commit
5957e315c9
12
robotgo.go
12
robotgo.go
@ -1457,9 +1457,15 @@ func FindIds(name string) ([]int32, error) {
|
||||
return pids, err
|
||||
}
|
||||
|
||||
// ActivePID active window by PID
|
||||
func ActivePID(pid int32) {
|
||||
C.active_PID(C.uintptr(pid))
|
||||
// ActivePID active window by PID,
|
||||
// If args[0] > 0 on the Windows platform via a window handle to active
|
||||
func ActivePID(pid int32, args ...int) {
|
||||
var hwnd int
|
||||
if len(args) > 0 {
|
||||
hwnd = args[0]
|
||||
}
|
||||
|
||||
C.active_PID(C.uintptr(pid), C.uintptr(hwnd))
|
||||
}
|
||||
|
||||
// ActiveName active window by name
|
||||
|
@ -85,7 +85,7 @@ void set_active(const MData win){
|
||||
}
|
||||
#endif
|
||||
|
||||
void active_PID(uintptr pid){
|
||||
void active_PID(uintptr pid, uintptr isHwnd){
|
||||
MData win;
|
||||
#if defined(IS_MACOSX)
|
||||
// Handle to a AXUIElementRef
|
||||
@ -94,7 +94,11 @@ void active_PID(uintptr pid){
|
||||
win.XWin = (Window)pid; // Handle to an X11 window
|
||||
#elif defined(IS_WINDOWS)
|
||||
// win.HWnd = (HWND)pid; // Handle to a window HWND
|
||||
win.HWnd = GetHwndByPId(pid);
|
||||
if (isHwnd == 0) {
|
||||
win.HWnd = GetHwndByPId(pid);
|
||||
} else {
|
||||
win.HWnd = (HWND)pid;
|
||||
}
|
||||
#endif
|
||||
|
||||
SetActive(win);
|
||||
|
Loading…
Reference in New Issue
Block a user