[sys] windows: add window handle related system calls

64 views
Skip to first unread message

Gerrit Bot (Gerrit)

unread,
Apr 8, 2022, 10:48:17 AM4/8/22
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gerrit Bot has uploaded this change for review.

View Change

windows: add window handle related system calls

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enumwindows
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enumchildwindows
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclassnamew
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdesktopwindow
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getforegroundwindow
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-iswindow
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-iswindowunicode
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-iswindowvisible
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getguithreadinfo

Change-Id: I21fbf47e1f459e86503e0e876b44cf47c98b2aa0
GitHub-Last-Rev: 85a24fdb73c9771e044cd8576be231eb1efd0461
GitHub-Pull-Request: golang/sys#122
---
M windows/syscall_windows.go
M windows/types_windows.go
M windows/zsyscall_windows.go
3 files changed, 118 insertions(+), 0 deletions(-)

diff --git a/windows/syscall_windows.go b/windows/syscall_windows.go
index ce3075c..fb4ba8d 100644
--- a/windows/syscall_windows.go
+++ b/windows/syscall_windows.go
@@ -364,6 +364,15 @@
//sys SetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error)
//sys GetActiveProcessorCount(groupNumber uint16) (ret uint32)
//sys GetMaximumProcessorCount(groupNumber uint16) (ret uint32)
+//sys EnumWindows(enumFunc uintptr, param unsafe.Pointer) (err error) = user32.EnumWindows
+//sys EnumChildWindows(hwnd HWND, enumFunc uintptr, param unsafe.Pointer) = user32.EnumChildWindows
+//sys GetClassName(hwnd HWND, className *uint16, maxCount int32) (copied int32, err error) = user32.GetClassNameW
+//sys GetDesktopWindow() (hwnd HWND) = user32.GetDesktopWindow
+//sys GetForegroundWindow() (hwnd HWND) = user32.GetForegroundWindow
+//sys IsWindow(hwnd HWND) (isWindow bool) = user32.IsWindow
+//sys IsWindowUnicode(hwnd HWND) (isUnicode bool) = user32.IsWindowUnicode
+//sys IsWindowVisible(hwnd HWND) (isVisible bool) = user32.IsWindowVisible
+//sys GetGUIThreadInfo(thread uint32, info *GUIThreadInfo) (err error) = user32.GetGUIThreadInfo

// Volume Management Functions
//sys DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) = DefineDosDeviceW
diff --git a/windows/types_windows.go b/windows/types_windows.go
index e19471c..5f4721f 100644
--- a/windows/types_windows.go
+++ b/windows/types_windows.go
@@ -3174,3 +3174,22 @@
}

const ALL_PROCESSOR_GROUPS = 0xFFFF
+
+type Rect struct {
+ Left int32
+ Top int32
+ Right int32
+ Bottom int32
+}
+
+type GUIThreadInfo struct {
+ Size uint32
+ Flags uint32
+ Active HWND
+ Focus HWND
+ Capture HWND
+ MenuOwner HWND
+ MoveSize HWND
+ CaretHandle HWND
+ CaretRect Rect
+}
diff --git a/windows/zsyscall_windows.go b/windows/zsyscall_windows.go
index 68f52c1..bc5ad27 100644
--- a/windows/zsyscall_windows.go
+++ b/windows/zsyscall_windows.go
@@ -442,9 +442,18 @@
procCommandLineToArgvW = modshell32.NewProc("CommandLineToArgvW")
procSHGetKnownFolderPath = modshell32.NewProc("SHGetKnownFolderPath")
procShellExecuteW = modshell32.NewProc("ShellExecuteW")
+ procEnumChildWindows = moduser32.NewProc("EnumChildWindows")
+ procEnumWindows = moduser32.NewProc("EnumWindows")
procExitWindowsEx = moduser32.NewProc("ExitWindowsEx")
+ procGetClassNameW = moduser32.NewProc("GetClassNameW")
+ procGetDesktopWindow = moduser32.NewProc("GetDesktopWindow")
+ procGetForegroundWindow = moduser32.NewProc("GetForegroundWindow")
+ procGetGUIThreadInfo = moduser32.NewProc("GetGUIThreadInfo")
procGetShellWindow = moduser32.NewProc("GetShellWindow")
procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId")
+ procIsWindow = moduser32.NewProc("IsWindow")
+ procIsWindowUnicode = moduser32.NewProc("IsWindowUnicode")
+ procIsWindowVisible = moduser32.NewProc("IsWindowVisible")
procMessageBoxW = moduser32.NewProc("MessageBoxW")
procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock")
procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock")
@@ -3784,6 +3793,19 @@
return
}

+func EnumChildWindows(hwnd HWND, enumFunc uintptr, param unsafe.Pointer) {
+ syscall.Syscall(procEnumChildWindows.Addr(), 3, uintptr(hwnd), uintptr(enumFunc), uintptr(param))
+ return
+}
+
+func EnumWindows(enumFunc uintptr, param unsafe.Pointer) (err error) {
+ r1, _, e1 := syscall.Syscall(procEnumWindows.Addr(), 2, uintptr(enumFunc), uintptr(param), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
func ExitWindowsEx(flags uint32, reason uint32) (err error) {
r1, _, e1 := syscall.Syscall(procExitWindowsEx.Addr(), 2, uintptr(flags), uintptr(reason), 0)
if r1 == 0 {
@@ -3792,6 +3814,35 @@
return
}

+func GetClassName(hwnd HWND, className *uint16, maxCount int32) (copied int32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetClassNameW.Addr(), 3, uintptr(hwnd), uintptr(unsafe.Pointer(className)), uintptr(maxCount))
+ copied = int32(r0)
+ if copied == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetDesktopWindow() (hwnd HWND) {
+ r0, _, _ := syscall.Syscall(procGetDesktopWindow.Addr(), 0, 0, 0, 0)
+ hwnd = HWND(r0)
+ return
+}
+
+func GetForegroundWindow() (hwnd HWND) {
+ r0, _, _ := syscall.Syscall(procGetForegroundWindow.Addr(), 0, 0, 0, 0)
+ hwnd = HWND(r0)
+ return
+}
+
+func GetGUIThreadInfo(thread uint32, info *GUIThreadInfo) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetGUIThreadInfo.Addr(), 2, uintptr(thread), uintptr(unsafe.Pointer(info)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
func GetShellWindow() (shellWindow HWND) {
r0, _, _ := syscall.Syscall(procGetShellWindow.Addr(), 0, 0, 0, 0)
shellWindow = HWND(r0)
@@ -3807,6 +3858,24 @@
return
}

+func IsWindow(hwnd HWND) (isWindow bool) {
+ r0, _, _ := syscall.Syscall(procIsWindow.Addr(), 1, uintptr(hwnd), 0, 0)
+ isWindow = r0 != 0
+ return
+}
+
+func IsWindowUnicode(hwnd HWND) (isUnicode bool) {
+ r0, _, _ := syscall.Syscall(procIsWindowUnicode.Addr(), 1, uintptr(hwnd), 0, 0)
+ isUnicode = r0 != 0
+ return
+}
+
+func IsWindowVisible(hwnd HWND) (isVisible bool) {
+ r0, _, _ := syscall.Syscall(procIsWindowVisible.Addr(), 1, uintptr(hwnd), 0, 0)
+ isVisible = r0 != 0
+ return
+}
+
func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) {
r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0)
ret = int32(r0)

To view, visit change 399134. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: sys
Gerrit-Branch: master
Gerrit-Change-Id: I21fbf47e1f459e86503e0e876b44cf47c98b2aa0
Gerrit-Change-Number: 399134
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-MessageType: newchange

Gopher Robot (Gerrit)

unread,
Apr 8, 2022, 10:48:29 AM4/8/22
to Gerrit Bot, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Congratulations on opening your first change. Thank you for your contribution!

Next steps:
A maintainer will review your change and provide feedback. See
https://go.dev/doc/contribute#review for more info and tips to get your
patch through code review.

Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.

During May-July and Nov-Jan the Go project is in a code freeze, during which
little code gets reviewed or merged. If a reviewer responds with a comment like
R=go1.11 or adds a tag like "wait-release", it means that this CL will be
reviewed as part of the next development cycle. See https://go.dev/s/release
for more details.

View Change

    To view, visit change 399134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: sys
    Gerrit-Branch: master
    Gerrit-Change-Id: I21fbf47e1f459e86503e0e876b44cf47c98b2aa0
    Gerrit-Change-Number: 399134
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Comment-Date: Fri, 08 Apr 2022 14:48:27 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: No
    Gerrit-MessageType: comment

    Alex Brainman (Gerrit)

    unread,
    Sep 11, 2022, 3:51:16 AM9/11/22
    to Gerrit Bot, Michael Lelli, goph...@pubsubhelper.golang.org, Brad Fitzpatrick, Gopher Robot, golang-co...@googlegroups.com

    Patch set 1:Run-TryBot +1

    View Change

    1 comment:

    • Patchset:

      • Patch Set #1:

        Thank you for your contribution.

        LGTM once try-bots are happy.

        Alex

    To view, visit change 399134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: sys
    Gerrit-Branch: master
    Gerrit-Change-Id: I21fbf47e1f459e86503e0e876b44cf47c98b2aa0
    Gerrit-Change-Number: 399134
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
    Gerrit-CC: Brad Fitzpatrick <brad...@golang.org>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Comment-Date: Sun, 11 Sep 2022 07:51:09 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Alex Brainman (Gerrit)

    unread,
    Sep 11, 2022, 3:54:48 AM9/11/22
    to Gerrit Bot, Michael Lelli, goph...@pubsubhelper.golang.org, Gopher Robot, Brad Fitzpatrick, golang-co...@googlegroups.com

    View Change

    1 comment:

    To view, visit change 399134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: sys
    Gerrit-Branch: master
    Gerrit-Change-Id: I21fbf47e1f459e86503e0e876b44cf47c98b2aa0
    Gerrit-Change-Number: 399134
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
    Gerrit-CC: Brad Fitzpatrick <brad...@golang.org>
    Gerrit-Comment-Date: Sun, 11 Sep 2022 07:54:41 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Gopher Robot <go...@golang.org>
    Gerrit-MessageType: comment

    Gerrit Bot (Gerrit)

    unread,
    Sep 12, 2022, 6:13:57 PM9/12/22
    to Michael Lelli, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Attention is currently required from: Alex Brainman.

    Gerrit Bot uploaded patch set #2 to this change.

    View Change

    The following approvals got outdated and were removed: Run-TryBot+1 by Alex Brainman, TryBot-Result-1 by Gopher Robot

    GitHub-Last-Rev: 242b79ffb8cbfe7b3359e35379fa3227a70fc0f1

    GitHub-Pull-Request: golang/sys#122
    ---
    M windows/syscall_windows.go
    M windows/types_windows.go
    M windows/zsyscall_windows.go
    3 files changed, 118 insertions(+), 0 deletions(-)

    To view, visit change 399134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: sys
    Gerrit-Branch: master
    Gerrit-Change-Id: I21fbf47e1f459e86503e0e876b44cf47c98b2aa0
    Gerrit-Change-Number: 399134
    Gerrit-PatchSet: 2
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
    Gerrit-CC: Brad Fitzpatrick <brad...@golang.org>
    Gerrit-CC: Michael Lelli <michae...@steelseries.com>
    Gerrit-Attention: Alex Brainman <alex.b...@gmail.com>
    Gerrit-MessageType: newpatchset

    Michael Lelli (Gerrit)

    unread,
    Sep 12, 2022, 10:45:12 PM9/12/22
    to Gerrit Bot, goph...@pubsubhelper.golang.org, Gopher Robot, Alex Brainman, Brad Fitzpatrick, golang-co...@googlegroups.com

    Attention is currently required from: Alex Brainman.

    View Change

    2 comments:

    • Patchset:

      • Patch Set #1:

        Please rebasse on current tip. Hopefully that will fix try-bots. […]

        Ack

    • Patchset:

    To view, visit change 399134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: sys
    Gerrit-Branch: master
    Gerrit-Change-Id: I21fbf47e1f459e86503e0e876b44cf47c98b2aa0
    Gerrit-Change-Number: 399134
    Gerrit-PatchSet: 2
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
    Gerrit-CC: Brad Fitzpatrick <brad...@golang.org>
    Gerrit-CC: Michael Lelli <michae...@steelseries.com>
    Gerrit-Attention: Alex Brainman <alex.b...@gmail.com>
    Gerrit-Comment-Date: Mon, 12 Sep 2022 22:16:25 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Alex Brainman <alex.b...@gmail.com>

    Alex Brainman (Gerrit)

    unread,
    Sep 13, 2022, 5:13:12 AM9/13/22
    to Gerrit Bot, Michael Lelli, goph...@pubsubhelper.golang.org, Gopher Robot, Brad Fitzpatrick, golang-co...@googlegroups.com

    Patch set 2:Run-TryBot +1

    View Change

    1 comment:

    • Patchset:

      • Patch Set #2:

        Thanks for rebasing.

        Let's see what try-bots say now.

        Alex

    To view, visit change 399134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: sys
    Gerrit-Branch: master
    Gerrit-Change-Id: I21fbf47e1f459e86503e0e876b44cf47c98b2aa0
    Gerrit-Change-Number: 399134
    Gerrit-PatchSet: 2
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
    Gerrit-CC: Brad Fitzpatrick <brad...@golang.org>
    Gerrit-CC: Michael Lelli <michae...@steelseries.com>
    Gerrit-Comment-Date: Tue, 13 Sep 2022 09:13:06 +0000

    Alex Brainman (Gerrit)

    unread,
    Sep 13, 2022, 5:16:17 AM9/13/22
    to Gerrit Bot, Michael Lelli, goph...@pubsubhelper.golang.org, Gopher Robot, Brad Fitzpatrick, golang-co...@googlegroups.com

    Patch set 2:Auto-Submit +1Code-Review +2

    View Change

    1 comment:

    • Patchset:

      • Patch Set #2:

        LGTM.

        Now I need to find 2 Googlers to approve your change before it can be submitted. I will do that.

        Alex

    To view, visit change 399134. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: sys
    Gerrit-Branch: master
    Gerrit-Change-Id: I21fbf47e1f459e86503e0e876b44cf47c98b2aa0
    Gerrit-Change-Number: 399134
    Gerrit-PatchSet: 2
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
    Gerrit-CC: Brad Fitzpatrick <brad...@golang.org>
    Gerrit-CC: Michael Lelli <michae...@steelseries.com>
    Gerrit-Comment-Date: Tue, 13 Sep 2022 09:16:12 +0000

    Benny Siegert (Gerrit)

    unread,
    Sep 13, 2022, 5:54:36 AM9/13/22
    to Gerrit Bot, Michael Lelli, goph...@pubsubhelper.golang.org, Benny Siegert, Alex Brainman, Gopher Robot, Brad Fitzpatrick, golang-co...@googlegroups.com

    Patch set 2:Code-Review +1

    View Change

      To view, visit change 399134. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: sys
      Gerrit-Branch: master
      Gerrit-Change-Id: I21fbf47e1f459e86503e0e876b44cf47c98b2aa0
      Gerrit-Change-Number: 399134
      Gerrit-PatchSet: 2
      Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
      Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
      Gerrit-Reviewer: Benny Siegert <bsie...@gmail.com>
      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
      Gerrit-CC: Brad Fitzpatrick <brad...@golang.org>
      Gerrit-CC: Michael Lelli <michae...@steelseries.com>
      Gerrit-Comment-Date: Tue, 13 Sep 2022 09:54:29 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      Gerrit-MessageType: comment

      Than McIntosh (Gerrit)

      unread,
      Sep 13, 2022, 8:03:12 AM9/13/22
      to Gerrit Bot, Michael Lelli, goph...@pubsubhelper.golang.org, Benny Siegert, Alex Brainman, Gopher Robot, Brad Fitzpatrick, golang-co...@googlegroups.com

      Patch set 2:Code-Review +2

      View Change

        To view, visit change 399134. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: sys
        Gerrit-Branch: master
        Gerrit-Change-Id: I21fbf47e1f459e86503e0e876b44cf47c98b2aa0
        Gerrit-Change-Number: 399134
        Gerrit-PatchSet: 2
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
        Gerrit-Reviewer: Benny Siegert <bsie...@gmail.com>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Than McIntosh <th...@google.com>
        Gerrit-CC: Brad Fitzpatrick <brad...@golang.org>
        Gerrit-CC: Michael Lelli <michae...@steelseries.com>
        Gerrit-Comment-Date: Tue, 13 Sep 2022 12:03:07 +0000

        Gopher Robot (Gerrit)

        unread,
        Sep 13, 2022, 8:03:25 AM9/13/22
        to Gerrit Bot, Michael Lelli, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Than McIntosh, Benny Siegert, Alex Brainman, Brad Fitzpatrick, golang-co...@googlegroups.com

        Gopher Robot submitted this change.

        View Change


        Approvals: Alex Brainman: Looks good to me, approved; Run TryBots; Automatically submit change Gopher Robot: TryBots succeeded Benny Siegert: Looks good to me, but someone else must approve Than McIntosh: Looks good to me, approved
        Reviewed-on: https://go-review.googlesource.com/c/sys/+/399134
        Auto-Submit: Alex Brainman <alex.b...@gmail.com>
        Reviewed-by: Benny Siegert <bsie...@gmail.com>
        Reviewed-by: Than McIntosh <th...@google.com>
        Reviewed-by: Alex Brainman <alex.b...@gmail.com>
        Run-TryBot: Alex Brainman <alex.b...@gmail.com>
        TryBot-Result: Gopher Robot <go...@golang.org>

        ---
        M windows/syscall_windows.go
        M windows/types_windows.go
        M windows/zsyscall_windows.go
        3 files changed, 125 insertions(+), 0 deletions(-)

        diff --git a/windows/syscall_windows.go b/windows/syscall_windows.go
        index e279138..996cc53 100644

        --- a/windows/syscall_windows.go
        +++ b/windows/syscall_windows.go
        @@ -364,6 +364,15 @@
        //sys SetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error)
        //sys GetActiveProcessorCount(groupNumber uint16) (ret uint32)
        //sys GetMaximumProcessorCount(groupNumber uint16) (ret uint32)
        +//sys EnumWindows(enumFunc uintptr, param unsafe.Pointer) (err error) = user32.EnumWindows
        +//sys EnumChildWindows(hwnd HWND, enumFunc uintptr, param unsafe.Pointer) = user32.EnumChildWindows
        +//sys GetClassName(hwnd HWND, className *uint16, maxCount int32) (copied int32, err error) = user32.GetClassNameW
        +//sys GetDesktopWindow() (hwnd HWND) = user32.GetDesktopWindow
        +//sys GetForegroundWindow() (hwnd HWND) = user32.GetForegroundWindow
        +//sys IsWindow(hwnd HWND) (isWindow bool) = user32.IsWindow
        +//sys IsWindowUnicode(hwnd HWND) (isUnicode bool) = user32.IsWindowUnicode
        +//sys IsWindowVisible(hwnd HWND) (isVisible bool) = user32.IsWindowVisible
        +//sys GetGUIThreadInfo(thread uint32, info *GUIThreadInfo) (err error) = user32.GetGUIThreadInfo

        // Volume Management Functions
        //sys DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) = DefineDosDeviceW
        diff --git a/windows/types_windows.go b/windows/types_windows.go
        index f9eaca5..ef489f5 100644
        --- a/windows/types_windows.go
        +++ b/windows/types_windows.go
        @@ -3213,3 +3213,22 @@

        }

        const ALL_PROCESSOR_GROUPS = 0xFFFF
        +
        +type Rect struct {
        + Left int32
        + Top int32
        + Right int32
        + Bottom int32
        +}
        +
        +type GUIThreadInfo struct {
        + Size uint32
        + Flags uint32
        + Active HWND
        + Focus HWND
        + Capture HWND
        + MenuOwner HWND
        + MoveSize HWND
        + CaretHandle HWND
        + CaretRect Rect
        +}
        diff --git a/windows/zsyscall_windows.go b/windows/zsyscall_windows.go
        index 52d4742..6c6f27b 100644
        --- a/windows/zsyscall_windows.go
        +++ b/windows/zsyscall_windows.go
        @@ -444,9 +444,18 @@

        procCommandLineToArgvW = modshell32.NewProc("CommandLineToArgvW")
        procSHGetKnownFolderPath = modshell32.NewProc("SHGetKnownFolderPath")
        procShellExecuteW = modshell32.NewProc("ShellExecuteW")
        + procEnumChildWindows = moduser32.NewProc("EnumChildWindows")
        + procEnumWindows = moduser32.NewProc("EnumWindows")
        procExitWindowsEx = moduser32.NewProc("ExitWindowsEx")
        + procGetClassNameW = moduser32.NewProc("GetClassNameW")
        + procGetDesktopWindow = moduser32.NewProc("GetDesktopWindow")
        + procGetForegroundWindow = moduser32.NewProc("GetForegroundWindow")
        + procGetGUIThreadInfo = moduser32.NewProc("GetGUIThreadInfo")
        procGetShellWindow = moduser32.NewProc("GetShellWindow")
        procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId")
        + procIsWindow = moduser32.NewProc("IsWindow")
        + procIsWindowUnicode = moduser32.NewProc("IsWindowUnicode")
        + procIsWindowVisible = moduser32.NewProc("IsWindowVisible")
        procMessageBoxW = moduser32.NewProc("MessageBoxW")
        procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock")
        procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock")
        @@ -3802,6 +3811,19 @@

        return
        }

        +func EnumChildWindows(hwnd HWND, enumFunc uintptr, param unsafe.Pointer) {
        + syscall.Syscall(procEnumChildWindows.Addr(), 3, uintptr(hwnd), uintptr(enumFunc), uintptr(param))
        + return
        +}
        +
        +func EnumWindows(enumFunc uintptr, param unsafe.Pointer) (err error) {
        + r1, _, e1 := syscall.Syscall(procEnumWindows.Addr(), 2, uintptr(enumFunc), uintptr(param), 0)
        + if r1 == 0 {
        + err = errnoErr(e1)
        + }
        + return
        +}
        +
        func ExitWindowsEx(flags uint32, reason uint32) (err error) {
        r1, _, e1 := syscall.Syscall(procExitWindowsEx.Addr(), 2, uintptr(flags), uintptr(reason), 0)
        if r1 == 0 {
        @@ -3810,6 +3832,35 @@
        @@ -3825,6 +3876,24 @@

        return
        }

        +func IsWindow(hwnd HWND) (isWindow bool) {
        + r0, _, _ := syscall.Syscall(procIsWindow.Addr(), 1, uintptr(hwnd), 0, 0)
        + isWindow = r0 != 0
        + return
        +}
        +
        +func IsWindowUnicode(hwnd HWND) (isUnicode bool) {
        + r0, _, _ := syscall.Syscall(procIsWindowUnicode.Addr(), 1, uintptr(hwnd), 0, 0)
        + isUnicode = r0 != 0
        + return
        +}
        +
        +func IsWindowVisible(hwnd HWND) (isVisible bool) {
        + r0, _, _ := syscall.Syscall(procIsWindowVisible.Addr(), 1, uintptr(hwnd), 0, 0)
        + isVisible = r0 != 0
        + return
        +}
        +
        func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) {
        r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0)
        ret = int32(r0)

        To view, visit change 399134. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: sys
        Gerrit-Branch: master
        Gerrit-Change-Id: I21fbf47e1f459e86503e0e876b44cf47c98b2aa0
        Gerrit-Change-Number: 399134
        Gerrit-PatchSet: 3
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
        Gerrit-Reviewer: Benny Siegert <bsie...@gmail.com>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Than McIntosh <th...@google.com>
        Gerrit-CC: Brad Fitzpatrick <brad...@golang.org>
        Gerrit-CC: Michael Lelli <michae...@steelseries.com>
        Gerrit-MessageType: merged

        Alex Brainman (Gerrit)

        unread,
        Sep 13, 2022, 5:07:11 PM9/13/22
        to Gerrit Bot, Gopher Robot, Michael Lelli, goph...@pubsubhelper.golang.org, Than McIntosh, Benny Siegert, Brad Fitzpatrick, golang-co...@googlegroups.com

        View Change

        1 comment:

        • Patchset:

        To view, visit change 399134. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: sys
        Gerrit-Branch: master
        Gerrit-Change-Id: I21fbf47e1f459e86503e0e876b44cf47c98b2aa0
        Gerrit-Change-Number: 399134
        Gerrit-PatchSet: 3
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Alex Brainman <alex.b...@gmail.com>
        Gerrit-Reviewer: Benny Siegert <bsie...@gmail.com>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Than McIntosh <th...@google.com>
        Gerrit-CC: Brad Fitzpatrick <brad...@golang.org>
        Gerrit-CC: Michael Lelli <michae...@steelseries.com>
        Gerrit-Comment-Date: Tue, 13 Sep 2022 21:07:04 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Gerrit-MessageType: comment
        Reply all
        Reply to author
        Forward
        0 new messages