From c4e7fbb392e27cbfa009cf42e911be15cfd4a2eb Mon Sep 17 00:00:00 2001 From: vcaesar Date: Tue, 28 Aug 2018 09:16:25 -0400 Subject: [PATCH] update set handle by pid and add get handle mdata by pid --- robotgo.go | 12 +++++++++++- window/window.h | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/robotgo.go b/robotgo.go index 240a325..b7ec703 100644 --- a/robotgo.go +++ b/robotgo.go @@ -1382,7 +1382,17 @@ func SetHandle(hwnd int) { } // SetHandlePid set the window handle by pid -func SetHandlePid(pid int32, args ...int32) C.MData { +func SetHandlePid(pid int32, args ...int32) { + var isHwnd int32 + if len(args) > 0 { + isHwnd = args[0] + } + + C.set_handle_pid_mData(C.uintptr(pid), C.uintptr(isHwnd)) +} + +// GetHandPid get handle mdata by pid +func GetHandPid(pid int32, args ...int32) C.MData { var isHwnd int32 if len(args) > 0 { isHwnd = args[0] diff --git a/window/window.h b/window/window.h index 6bf1c86..c9ae6be 100644 --- a/window/window.h +++ b/window/window.h @@ -69,6 +69,11 @@ MData set_handle_pid(uintptr pid, uintptr isHwnd){ return win; } +void set_handle_pid_mData(uintptr pid, uintptr isHwnd){ + MData win = set_handle_pid(pid, isHwnd); + mData = win; +} + bool IsValid(){ initWindow(initHandle); if (!IsAxEnabled(true)) {