Skip to content

Commit

Permalink
add get the HWND by PID support
Browse files Browse the repository at this point in the history
  • Loading branch information
vcaesar committed Jun 26, 2022
1 parent 1934220 commit ee25e57
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions robotgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ func getNumDisplays() int {
return int(C.get_num_displays())
}

// GetHwndByPId get the hwnd by pid
func GetHwndByPId(pid int) int {
return int(C.get_hwnd_by_pid(C.uintptr(pid)))
}

// SysScale get the sys scale
func SysScale(displayId ...int) float64 {
display := displayIdx(displayId...)
Expand Down
9 changes: 9 additions & 0 deletions screen/goScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ uint32_t get_num_displays() {
#endif
}

uintptr get_hwnd_by_pid(uintptr pid) {
#if defined(IS_WINDOWS)
HWND hwnd = GetHwndByPId(pid);
return (uintptr)hwnd;
#else
return 0;
#endif
}

void bitmap_dealloc(MMBitmapRef bitmap) {
if (bitmap != NULL) {
destroyMMBitmap(bitmap);
Expand Down

0 comments on commit ee25e57

Please sign in to comment.