Skip to content

Instantly share code, notes, and snippets.

@AlexeyGy
Last active September 18, 2020 12:47
Show Gist options
  • Save AlexeyGy/377338a60998e636092b2509faf96ac3 to your computer and use it in GitHub Desktop.
Save AlexeyGy/377338a60998e636092b2509faf96ac3 to your computer and use it in GitHub Desktop.
// MSG see https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-msg
type MSG struct {
HWND uintptr
UINT uintptr
WPARAM int16
LPARAM int64
DWORD int32
POINT struct{ X, Y int64 }
}
func main() {
user32 := syscall.MustLoadDLL("user32")
defer user32.Release()
registerHotkeys(user32)
getmsg := user32.MustFindProc("GetMessageW")
sendInputProc := user32.MustFindProc("SendInput")
for {
var msg = &MSG{}
getmsg.Call(uintptr(unsafe.Pointer(msg)), 0, 0, 0, 1)
// Registered id is in the WPARAM field:
if id := msg.WPARAM; id != 0 {
fmt.Println("Hotkey pressed:", HOTKEYS[id])
PrintCharacters(sendInputProc, strings.ToUpper(time.Now().Format("2006-01-02")))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment