mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-19 14:23:55 +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
|
return pids, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActivePID active window by PID
|
// ActivePID active window by PID,
|
||||||
func ActivePID(pid int32) {
|
// If args[0] > 0 on the Windows platform via a window handle to active
|
||||||
C.active_PID(C.uintptr(pid))
|
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
|
// ActiveName active window by name
|
||||||
|
@ -85,7 +85,7 @@ void set_active(const MData win){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void active_PID(uintptr pid){
|
void active_PID(uintptr pid, uintptr isHwnd){
|
||||||
MData win;
|
MData win;
|
||||||
#if defined(IS_MACOSX)
|
#if defined(IS_MACOSX)
|
||||||
// Handle to a AXUIElementRef
|
// Handle to a AXUIElementRef
|
||||||
@ -94,7 +94,11 @@ void active_PID(uintptr pid){
|
|||||||
win.XWin = (Window)pid; // Handle to an X11 window
|
win.XWin = (Window)pid; // Handle to an X11 window
|
||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
// win.HWnd = (HWND)pid; // Handle to a window HWND
|
// 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
|
#endif
|
||||||
|
|
||||||
SetActive(win);
|
SetActive(win);
|
||||||
|
Loading…
Reference in New Issue
Block a user