Categorygithub.com/stephen-fox/user32util
modulepackage
0.3.1
Repository: https://github.com/stephen-fox/user32util.git
Documentation: pkg.go.dev

# README

user32util

GoDoc

Package user32util provides helper functionality for working with Windows' user32 library.

APIs

The library offers several helper functions for working with user32.

Many of these functions require that you first load the user32 DLL:

user32, err := user32util.LoadUser32DLL()
if err != nil {
	// Error handling.
}

Input listeners

  • NewLowLevelMouseListener() - Starts a listener that reports on mouse input
  • NewLowLevelKeyboardListener() - Starts a listener that reports on keyboard input

Send input

  • SendKeydbInput() - Sends a single keyboard input
  • SendMouseInput() - Sends a single mouse input
  • SendInput() - Send input implements the SendInput() Windows system call
  • SendHardwareInput() - Sends a single hardware input

Examples

The following examples can be found in the examples/ directory:

  • moveandclickmouse - Moves the mouse and then left clicks on the new position. Takes inputs as command line arguments in x,y format. E.g., example 1221,244 460,892. Coordinates can be printed by running: example print
  • readkeyboard - Reads keyboard presses and prints them to stderr
  • readmouse - Reads mouse inputs and prints them to stderr
  • sendinput - Sends keyboard or mouse inputs to Windows

Special thanks

This library is influenced by jimmycliff obonyo's work in this GitHub gist: https://gist.github.com/obonyojimmy/52d836a1b31e2fc914d19a81bd2e0a1b

Thank you for documenting your work, jimmycliff.

# Packages

No description provided by the author

# Functions

LoadUser32DLL loads the user32 DLL into memory.
NewLowLevelKeyboardListener instantiates a new keyboard input listener using the LowLevelKeyboardProc Windows hook.
NewLowLevelMouseListener instantiates a new mouse input listener using the LowLevelMouseProc Windows hook.
No idea if this works.
SendInput is a hacky implementation of SendInput that works around the lack of union support.
Wrapper for SendInput() that sends a single KeybdInput.
Wrapper for SendInput() that sends a single MouseInput.
SetCursorPos sets the mouse cursor position.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
Various KeybdInput dwFlags.
Various KeybdInput dwFlags.
Various KeybdInput dwFlags.
Various KeybdInput dwFlags.
Various MouseInput dwFlags.
Various MouseInput dwFlags.
Various MouseInput dwFlags.
Various MouseInput dwFlags.
Various MouseInput dwFlags.
Various MouseInput dwFlags.
Various MouseInput dwFlags.
Various MouseInput dwFlags.
Various MouseInput dwFlags.
Various MouseInput dwFlags.
Various MouseInput dwFlags.
Various MouseInput dwFlags.
Various MouseInput dwFlags.
Various MouseInput dwFlags.
LowLevelKeyboardEvent wParam flags.
LowLevelKeyboardEvent wParam flags.
LowLevelKeyboardEvent wParam flags.
LowLevelMouseEvent wParam flags.
LowLevelMouseEvent wParam flags.
LowLevelMouseEvent wParam flags.
LowLevelMouseEvent wParam flags.
LowLevelMouseEvent wParam flags.
Other mouse related message types (unsure where they are used, but they appear in the 'mouseData' field documentation).
Other mouse related message types (unsure where they are used, but they appear in the 'mouseData' field documentation).
Other mouse related message types (unsure where they are used, but they appear in the 'mouseData' field documentation).
LowLevelMouseEvent wParam flags.
LowLevelMouseEvent wParam flags.
LowLevelKeyboardEvent wParam flags.
Other mouse related message types (unsure where they are used, but they appear in the 'mouseData' field documentation).
Other mouse related message types (unsure where they are used, but they appear in the 'mouseData' field documentation).
Other mouse related message types (unsure where they are used, but they appear in the 'mouseData' field documentation).

# Structs

From the Windows API documentation: Contains information about a simulated message generated by an input device other than a keyboard or mouse.
From the Windows API documentation: Contains information about a low-level keyboard input event.
From the Windows API documentation: Contains information about a simulated keyboard event.
LowLevelKeyboardEvent represents a single keyboard event.
LowLevelKeyboardEventListener represents an instance of the LowLevelKeyboardProc Windows hook.
No description provided by the author
LowLevelMouseEventListener represents an instance of the LowLevelMouseProc Windows hook.
From the Windows API documentation: Contains information about a simulated mouse event.
From the Windows API documentation: Contains message information from a thread's message queue.
From the Windows API documentation: Contains information about a low-level mouse input event.
From the Windows API documentation: The POINT structure defines the x- and y- coordinates of a point.
User32DLL represents the user32 DLL, mapping several of its procedures to this struct's fields.

# Type aliases

KeyboardButtonAction is an alias for the values contained in the wParam field fo LowLevelKeyboardEvent.
MouseButtonAction is an alias for the values contained in the wParam field fo LowLevelKeyboardEvent.
No description provided by the author
No description provided by the author