github.com/rajveermalviya/gamen@v0.1.2-0.20220930195403-9be15877c1aa/internal/win32/procs/procs.go (about)

     1  //go:build windows
     2  
     3  package procs
     4  
     5  import (
     6  	"runtime"
     7  	"syscall"
     8  
     9  	"golang.org/x/sys/windows"
    10  )
    11  
    12  var (
    13  	kernel32 = windows.NewLazySystemDLL("kernel32.dll")
    14  	user32   = windows.NewLazySystemDLL("user32.dll")
    15  
    16  	_GetModuleHandleW = kernel32.NewProc("GetModuleHandleW")
    17  
    18  	_PeekMessageW              = user32.NewProc("PeekMessageW")
    19  	_TranslateMessage          = user32.NewProc("TranslateMessage")
    20  	_DispatchMessageW          = user32.NewProc("DispatchMessageW")
    21  	_WaitMessage               = user32.NewProc("WaitMessage")
    22  	_MsgWaitForMultipleObjects = user32.NewProc("MsgWaitForMultipleObjects")
    23  	_PostMessageW              = user32.NewProc("PostMessageW")
    24  
    25  	_RegisterClassExW         = user32.NewProc("RegisterClassExW")
    26  	_CreateWindowExW          = user32.NewProc("CreateWindowExW")
    27  	_DestroyWindow            = user32.NewProc("DestroyWindow")
    28  	_DefWindowProcW           = user32.NewProc("DefWindowProcW")
    29  	_GetWindowLongW           = user32.NewProc("GetWindowLongW")
    30  	_SetWindowLongW           = user32.NewProc("SetWindowLongW")
    31  	_GetWindowLongPtrW        = user32.NewProc("GetWindowLongPtrW")
    32  	_SetWindowLongPtrW        = user32.NewProc("SetWindowLongPtrW")
    33  	_LoadCursorW              = user32.NewProc("LoadCursorW")
    34  	_SetCursor                = user32.NewProc("SetCursor")
    35  	_ShowCursor               = user32.NewProc("ShowCursor")
    36  	_TrackMouseEvent          = user32.NewProc("TrackMouseEvent")
    37  	_SetCapture               = user32.NewProc("SetCapture")
    38  	_ReleaseCapture           = user32.NewProc("ReleaseCapture")
    39  	_GetKeyboardLayout        = user32.NewProc("GetKeyboardLayout")
    40  	_ToUnicodeEx              = user32.NewProc("ToUnicodeEx")
    41  	_MapVirtualKeyW           = user32.NewProc("MapVirtualKeyW")
    42  	_GetKeyboardState         = user32.NewProc("GetKeyboardState")
    43  	_GetMenu                  = user32.NewProc("GetMenu")
    44  	_GetDpiForWindow          = user32.NewProc("GetDpiForWindow")
    45  	_GetClientRect            = user32.NewProc("GetClientRect")
    46  	_AdjustWindowRectExForDpi = user32.NewProc("AdjustWindowRectExForDpi")
    47  	_AdjustWindowRectEx       = user32.NewProc("AdjustWindowRectEx")
    48  	_SetWindowPos             = user32.NewProc("SetWindowPos")
    49  	_InvalidateRgn            = user32.NewProc("InvalidateRgn")
    50  	_ShowWindow               = user32.NewProc("ShowWindow")
    51  	_GetCursorPos             = user32.NewProc("GetCursorPos")
    52  	_SetWindowTextW           = user32.NewProc("SetWindowTextW")
    53  	_GetWindowPlacement       = user32.NewProc("GetWindowPlacement")
    54  	_SetWindowPlacement       = user32.NewProc("SetWindowPlacement")
    55  	_MonitorFromWindow        = user32.NewProc("MonitorFromWindow")
    56  	_GetMonitorInfoW          = user32.NewProc("GetMonitorInfoW")
    57  )
    58  
    59  func GetModuleHandleW() (r uintptr) {
    60  	r, _, _ = syscall.SyscallN(_GetModuleHandleW.Addr(), 0)
    61  	return
    62  }
    63  
    64  type POINT struct {
    65  	X, Y int32
    66  }
    67  
    68  type POINTS struct {
    69  	X, Y int16
    70  }
    71  
    72  type MSG struct {
    73  	HWND    uintptr
    74  	Message uint32
    75  	WParam  uintptr
    76  	LParam  uintptr
    77  	Time    uint32
    78  	PT      POINT
    79  }
    80  
    81  const (
    82  	PM_REMOVE = 1
    83  )
    84  
    85  func PeekMessageW(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg uintptr) bool {
    86  	r, _, _ := syscall.SyscallN(_PeekMessageW.Addr(), lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg)
    87  	return r != 0
    88  }
    89  
    90  func TranslateMessage(lpMsg uintptr) bool {
    91  	r, _, _ := syscall.SyscallN(_TranslateMessage.Addr(), lpMsg)
    92  	return r != 0
    93  }
    94  
    95  func DispatchMessageW(lpMsg uintptr) {
    96  	syscall.SyscallN(_DispatchMessageW.Addr(), lpMsg)
    97  }
    98  
    99  func WaitMessage() bool {
   100  	r, _, _ := syscall.SyscallN(_WaitMessage.Addr())
   101  	return r != 0
   102  }
   103  
   104  const (
   105  	QS_ALLEVENTS = 1215
   106  )
   107  
   108  func MsgWaitForMultipleObjects(nCount, pHandles, fWaitAll, dwMilliseconds, dwWakeMask uintptr) uintptr {
   109  	r, _, _ := syscall.SyscallN(_MsgWaitForMultipleObjects.Addr(), nCount, pHandles, fWaitAll, dwMilliseconds, dwWakeMask)
   110  	return r
   111  }
   112  
   113  func PostMessageW(hWnd, Msg, wParam, lParam uintptr) bool {
   114  	r, _, _ := syscall.SyscallN(_PostMessageW.Addr(), hWnd, Msg, wParam, lParam)
   115  	return r != 0
   116  }
   117  
   118  const (
   119  	CS_VREDRAW = 1
   120  	CS_HREDRAW = 2
   121  )
   122  
   123  type WNDCLASSEXW struct {
   124  	CbSize        uint32
   125  	Style         uint32
   126  	LpfnWndProc   uintptr
   127  	CbClsExtra    int32
   128  	CbWndExtra    int32
   129  	HInstance     uintptr
   130  	HIcon         uintptr
   131  	HCursor       uintptr
   132  	HbrBackground uintptr
   133  	LpszMenuName  *uint16
   134  	LpszClassName *uint16
   135  	HIconSm       uintptr
   136  }
   137  
   138  func RegisterClassExW(class uintptr) (r uintptr) {
   139  	r, _, _ = syscall.SyscallN(_RegisterClassExW.Addr(), class)
   140  	return
   141  }
   142  
   143  const (
   144  	WS_OVERLAPPED       = 0
   145  	WS_SIZEBOX          = 262144
   146  	WS_MAXIMIZEBOX      = 65536
   147  	WS_CAPTION          = 12582912
   148  	WS_MINIMIZEBOX      = 131072
   149  	WS_BORDER           = 8388608
   150  	WS_VISIBLE          = 268435456
   151  	WS_CLIPSIBLINGS     = 67108864
   152  	WS_CLIPCHILDREN     = 33554432
   153  	WS_SYSMENU          = 524288
   154  	WS_OVERLAPPEDWINDOW = 13565952
   155  )
   156  
   157  const (
   158  	WS_EX_LEFT       = 0
   159  	WS_EX_WINDOWEDGE = 256
   160  	WS_EX_APPWINDOW  = 262144
   161  )
   162  
   163  const (
   164  	CW_USEDEFAULT = ^uintptr(0) - 2147483647 // -2147483648
   165  )
   166  
   167  func CreateWindowExW(
   168  	dwExStyle,
   169  	lpClassName,
   170  	lpWindowName,
   171  	dwStyle,
   172  	X,
   173  	Y,
   174  	nWidth,
   175  	nHeight,
   176  	hWndParent,
   177  	hMenu,
   178  	hInstance,
   179  	lpParam uintptr,
   180  ) (r uintptr) {
   181  	r, _, _ = syscall.SyscallN(_CreateWindowExW.Addr(),
   182  		dwExStyle,
   183  		lpClassName,
   184  		lpWindowName,
   185  		dwStyle,
   186  		X,
   187  		Y,
   188  		nWidth,
   189  		nHeight,
   190  		hWndParent,
   191  		hMenu,
   192  		hInstance,
   193  		lpParam,
   194  	)
   195  	return
   196  }
   197  
   198  type CREATESTRUCTW struct {
   199  	LpCreateParams uintptr
   200  	HInstance      uintptr
   201  	HMenu          uintptr
   202  	HwndParent     uintptr
   203  	Cy             int32
   204  	Cx             int32
   205  	Y              int32
   206  	X              int32
   207  	Style          int32
   208  	LpszName       *uint16
   209  	LpszClass      *uint16
   210  	DwExStyle      uint32
   211  }
   212  
   213  const (
   214  	WM_CREATE         = 1
   215  	WM_NCCREATE       = 129
   216  	WM_CLOSE          = 16
   217  	WM_SIZE           = 5
   218  	WM_MOUSEMOVE      = 512
   219  	WM_MOUSELEAVE     = 675
   220  	WM_MOUSEWHEEL     = 522
   221  	WM_MOUSEHWHEEL    = 526
   222  	WM_NCLBUTTONDOWN  = 161
   223  	WM_LBUTTONDOWN    = 513
   224  	WM_LBUTTONUP      = 514
   225  	WM_RBUTTONDOWN    = 516
   226  	WM_RBUTTONUP      = 517
   227  	WM_MBUTTONDOWN    = 519
   228  	WM_MBUTTONUP      = 520
   229  	WM_XBUTTONDOWN    = 523
   230  	WM_XBUTTONUP      = 524
   231  	WM_CAPTURECHANGED = 533
   232  	WM_SETFOCUS       = 7
   233  	WM_KILLFOCUS      = 8
   234  	WM_SETCURSOR      = 32
   235  	WM_GETMINMAXINFO  = 36
   236  
   237  	WM_KEYDOWN    = 256
   238  	WM_SYSKEYDOWN = 260
   239  	WM_KEYUP      = 257
   240  	WM_SYSKEYUP   = 261
   241  
   242  	WM_CHAR    = 258
   243  	WM_SYSCHAR = 262
   244  )
   245  
   246  const (
   247  	HTCAPTION   = 2
   248  	WHEEL_DELTA = 120
   249  )
   250  
   251  func DefWindowProcW(hWnd, Msg, wParam, lParam uintptr) (r uintptr) {
   252  	r, _, _ = syscall.SyscallN(_DefWindowProcW.Addr(), hWnd, Msg, wParam, lParam)
   253  	return r
   254  }
   255  
   256  const GWL_STYLE = ^uintptr(0) - 15    // -16
   257  const GWL_EXSTYLE = ^uintptr(0) - 19  // -20
   258  const GWL_USERDATA = ^uintptr(0) - 20 // -21
   259  
   260  func GetWindowLong(hWnd, nIndex uintptr) uintptr {
   261  	switch runtime.GOARCH {
   262  	case "amd64", "arm64":
   263  		r, _, _ := syscall.SyscallN(_GetWindowLongPtrW.Addr(), hWnd, nIndex)
   264  		return r
   265  
   266  	case "386", "arm":
   267  		r, _, _ := syscall.SyscallN(_GetWindowLongW.Addr(), hWnd, nIndex)
   268  		return r
   269  	}
   270  
   271  	panic("unsupported GOARCH: " + runtime.GOARCH)
   272  }
   273  
   274  func SetWindowLong(hWnd, nIndex, dwNewLong uintptr) uintptr {
   275  	switch runtime.GOARCH {
   276  	case "amd64", "arm64":
   277  		r, _, _ := syscall.SyscallN(_SetWindowLongPtrW.Addr(), hWnd, nIndex, dwNewLong)
   278  		return r
   279  
   280  	case "386", "arm":
   281  		r, _, _ := syscall.SyscallN(_SetWindowLongW.Addr(), hWnd, nIndex, dwNewLong)
   282  		return r
   283  	}
   284  
   285  	panic("unsupported GOARCH: " + runtime.GOARCH)
   286  }
   287  
   288  const (
   289  	HTCLIENT        = 1
   290  	IDC_APPSTARTING = 32650
   291  	IDC_ARROW       = 32512
   292  	IDC_CROSS       = 32515
   293  	IDC_HAND        = 32649
   294  	IDC_HELP        = 32651
   295  	IDC_IBEAM       = 32513
   296  	IDC_ICON        = 32641
   297  	IDC_NO          = 32648
   298  	IDC_SIZE        = 32640
   299  	IDC_SIZEALL     = 32646
   300  	IDC_SIZENESW    = 32643
   301  	IDC_SIZENS      = 32645
   302  	IDC_SIZENWSE    = 32642
   303  	IDC_SIZEWE      = 32644
   304  	IDC_UPARROW     = 32516
   305  	IDC_WAIT        = 32514
   306  )
   307  
   308  func LoadCursorW(hInstance, lpCursorName uintptr) (r uintptr) {
   309  	r, _, _ = syscall.SyscallN(_LoadCursorW.Addr(), hInstance, lpCursorName)
   310  	return
   311  }
   312  
   313  func SetCursor(hcursor uintptr) (r uintptr) {
   314  	r, _, _ = syscall.SyscallN(_SetCursor.Addr(), hcursor)
   315  	return
   316  }
   317  
   318  func ShowCursor(bShow uintptr) uintptr {
   319  	r, _, _ := syscall.SyscallN(_ShowCursor.Addr(), bShow)
   320  	return r
   321  }
   322  
   323  const (
   324  	TME_LEAVE     = 2
   325  	HOVER_DEFAULT = 4294967295
   326  )
   327  
   328  type TRACKMOUSEEVENT struct {
   329  	CbSize      uint32
   330  	DwFlags     uint32
   331  	HwndTrack   uintptr
   332  	DwHoverTime uint32
   333  }
   334  
   335  func TrackMouseEvent(lpEventTrack uintptr) bool {
   336  	r, _, _ := syscall.SyscallN(_TrackMouseEvent.Addr(), lpEventTrack)
   337  	return r != 0
   338  }
   339  
   340  func SetCapture(hwnd uintptr) (r uintptr) {
   341  	r, _, _ = syscall.SyscallN(_SetCapture.Addr(), hwnd)
   342  	return
   343  }
   344  
   345  func ReleaseCapture() bool {
   346  	r, _, _ := syscall.SyscallN(_ReleaseCapture.Addr())
   347  	return r != 0
   348  }
   349  
   350  const (
   351  	VK_0                               = 48
   352  	VK_1                               = 49
   353  	VK_2                               = 50
   354  	VK_3                               = 51
   355  	VK_4                               = 52
   356  	VK_5                               = 53
   357  	VK_6                               = 54
   358  	VK_7                               = 55
   359  	VK_8                               = 56
   360  	VK_9                               = 57
   361  	VK_A                               = 65
   362  	VK_B                               = 66
   363  	VK_C                               = 67
   364  	VK_D                               = 68
   365  	VK_E                               = 69
   366  	VK_F                               = 70
   367  	VK_G                               = 71
   368  	VK_H                               = 72
   369  	VK_I                               = 73
   370  	VK_J                               = 74
   371  	VK_K                               = 75
   372  	VK_L                               = 76
   373  	VK_M                               = 77
   374  	VK_N                               = 78
   375  	VK_O                               = 79
   376  	VK_P                               = 80
   377  	VK_Q                               = 81
   378  	VK_R                               = 82
   379  	VK_S                               = 83
   380  	VK_T                               = 84
   381  	VK_U                               = 85
   382  	VK_V                               = 86
   383  	VK_W                               = 87
   384  	VK_X                               = 88
   385  	VK_Y                               = 89
   386  	VK_Z                               = 90
   387  	VK_LBUTTON                         = 1
   388  	VK_RBUTTON                         = 2
   389  	VK_CANCEL                          = 3
   390  	VK_MBUTTON                         = 4
   391  	VK_XBUTTON1                        = 5
   392  	VK_XBUTTON2                        = 6
   393  	VK_BACK                            = 8
   394  	VK_TAB                             = 9
   395  	VK_CLEAR                           = 12
   396  	VK_RETURN                          = 13
   397  	VK_SHIFT                           = 16
   398  	VK_CONTROL                         = 17
   399  	VK_MENU                            = 18
   400  	VK_PAUSE                           = 19
   401  	VK_CAPITAL                         = 20
   402  	VK_KANA                            = 21
   403  	VK_HANGEUL                         = 21
   404  	VK_HANGUL                          = 21
   405  	VK_IME_ON                          = 22
   406  	VK_JUNJA                           = 23
   407  	VK_FINAL                           = 24
   408  	VK_HANJA                           = 25
   409  	VK_KANJI                           = 25
   410  	VK_IME_OFF                         = 26
   411  	VK_ESCAPE                          = 27
   412  	VK_CONVERT                         = 28
   413  	VK_NONCONVERT                      = 29
   414  	VK_ACCEPT                          = 30
   415  	VK_MODECHANGE                      = 31
   416  	VK_SPACE                           = 32
   417  	VK_PRIOR                           = 33
   418  	VK_NEXT                            = 34
   419  	VK_END                             = 35
   420  	VK_HOME                            = 36
   421  	VK_LEFT                            = 37
   422  	VK_UP                              = 38
   423  	VK_RIGHT                           = 39
   424  	VK_DOWN                            = 40
   425  	VK_SELECT                          = 41
   426  	VK_PRINT                           = 42
   427  	VK_EXECUTE                         = 43
   428  	VK_SNAPSHOT                        = 44
   429  	VK_INSERT                          = 45
   430  	VK_DELETE                          = 46
   431  	VK_HELP                            = 47
   432  	VK_LWIN                            = 91
   433  	VK_RWIN                            = 92
   434  	VK_APPS                            = 93
   435  	VK_SLEEP                           = 95
   436  	VK_NUMPAD0                         = 96
   437  	VK_NUMPAD1                         = 97
   438  	VK_NUMPAD2                         = 98
   439  	VK_NUMPAD3                         = 99
   440  	VK_NUMPAD4                         = 100
   441  	VK_NUMPAD5                         = 101
   442  	VK_NUMPAD6                         = 102
   443  	VK_NUMPAD7                         = 103
   444  	VK_NUMPAD8                         = 104
   445  	VK_NUMPAD9                         = 105
   446  	VK_MULTIPLY                        = 106
   447  	VK_ADD                             = 107
   448  	VK_SEPARATOR                       = 108
   449  	VK_SUBTRACT                        = 109
   450  	VK_DECIMAL                         = 110
   451  	VK_DIVIDE                          = 111
   452  	VK_F1                              = 112
   453  	VK_F2                              = 113
   454  	VK_F3                              = 114
   455  	VK_F4                              = 115
   456  	VK_F5                              = 116
   457  	VK_F6                              = 117
   458  	VK_F7                              = 118
   459  	VK_F8                              = 119
   460  	VK_F9                              = 120
   461  	VK_F10                             = 121
   462  	VK_F11                             = 122
   463  	VK_F12                             = 123
   464  	VK_F13                             = 124
   465  	VK_F14                             = 125
   466  	VK_F15                             = 126
   467  	VK_F16                             = 127
   468  	VK_F17                             = 128
   469  	VK_F18                             = 129
   470  	VK_F19                             = 130
   471  	VK_F20                             = 131
   472  	VK_F21                             = 132
   473  	VK_F22                             = 133
   474  	VK_F23                             = 134
   475  	VK_F24                             = 135
   476  	VK_NAVIGATION_VIEW                 = 136
   477  	VK_NAVIGATION_MENU                 = 137
   478  	VK_NAVIGATION_UP                   = 138
   479  	VK_NAVIGATION_DOWN                 = 139
   480  	VK_NAVIGATION_LEFT                 = 140
   481  	VK_NAVIGATION_RIGHT                = 141
   482  	VK_NAVIGATION_ACCEPT               = 142
   483  	VK_NAVIGATION_CANCEL               = 143
   484  	VK_NUMLOCK                         = 144
   485  	VK_SCROLL                          = 145
   486  	VK_OEM_NEC_EQUAL                   = 146
   487  	VK_OEM_FJ_JISHO                    = 146
   488  	VK_OEM_FJ_MASSHOU                  = 147
   489  	VK_OEM_FJ_TOUROKU                  = 148
   490  	VK_OEM_FJ_LOYA                     = 149
   491  	VK_OEM_FJ_ROYA                     = 150
   492  	VK_LSHIFT                          = 160
   493  	VK_RSHIFT                          = 161
   494  	VK_LCONTROL                        = 162
   495  	VK_RCONTROL                        = 163
   496  	VK_LMENU                           = 164
   497  	VK_RMENU                           = 165
   498  	VK_BROWSER_BACK                    = 166
   499  	VK_BROWSER_FORWARD                 = 167
   500  	VK_BROWSER_REFRESH                 = 168
   501  	VK_BROWSER_STOP                    = 169
   502  	VK_BROWSER_SEARCH                  = 170
   503  	VK_BROWSER_FAVORITES               = 171
   504  	VK_BROWSER_HOME                    = 172
   505  	VK_VOLUME_MUTE                     = 173
   506  	VK_VOLUME_DOWN                     = 174
   507  	VK_VOLUME_UP                       = 175
   508  	VK_MEDIA_NEXT_TRACK                = 176
   509  	VK_MEDIA_PREV_TRACK                = 177
   510  	VK_MEDIA_STOP                      = 178
   511  	VK_MEDIA_PLAY_PAUSE                = 179
   512  	VK_LAUNCH_MAIL                     = 180
   513  	VK_LAUNCH_MEDIA_SELECT             = 181
   514  	VK_LAUNCH_APP1                     = 182
   515  	VK_LAUNCH_APP2                     = 183
   516  	VK_OEM_1                           = 186
   517  	VK_OEM_PLUS                        = 187
   518  	VK_OEM_COMMA                       = 188
   519  	VK_OEM_MINUS                       = 189
   520  	VK_OEM_PERIOD                      = 190
   521  	VK_OEM_2                           = 191
   522  	VK_OEM_3                           = 192
   523  	VK_GAMEPAD_A                       = 195
   524  	VK_GAMEPAD_B                       = 196
   525  	VK_GAMEPAD_X                       = 197
   526  	VK_GAMEPAD_Y                       = 198
   527  	VK_GAMEPAD_RIGHT_SHOULDER          = 199
   528  	VK_GAMEPAD_LEFT_SHOULDER           = 200
   529  	VK_GAMEPAD_LEFT_TRIGGER            = 201
   530  	VK_GAMEPAD_RIGHT_TRIGGER           = 202
   531  	VK_GAMEPAD_DPAD_UP                 = 203
   532  	VK_GAMEPAD_DPAD_DOWN               = 204
   533  	VK_GAMEPAD_DPAD_LEFT               = 205
   534  	VK_GAMEPAD_DPAD_RIGHT              = 206
   535  	VK_GAMEPAD_MENU                    = 207
   536  	VK_GAMEPAD_VIEW                    = 208
   537  	VK_GAMEPAD_LEFT_THUMBSTICK_BUTTON  = 209
   538  	VK_GAMEPAD_RIGHT_THUMBSTICK_BUTTON = 210
   539  	VK_GAMEPAD_LEFT_THUMBSTICK_UP      = 211
   540  	VK_GAMEPAD_LEFT_THUMBSTICK_DOWN    = 212
   541  	VK_GAMEPAD_LEFT_THUMBSTICK_RIGHT   = 213
   542  	VK_GAMEPAD_LEFT_THUMBSTICK_LEFT    = 214
   543  	VK_GAMEPAD_RIGHT_THUMBSTICK_UP     = 215
   544  	VK_GAMEPAD_RIGHT_THUMBSTICK_DOWN   = 216
   545  	VK_GAMEPAD_RIGHT_THUMBSTICK_RIGHT  = 217
   546  	VK_GAMEPAD_RIGHT_THUMBSTICK_LEFT   = 218
   547  	VK_OEM_4                           = 219
   548  	VK_OEM_5                           = 220
   549  	VK_OEM_6                           = 221
   550  	VK_OEM_7                           = 222
   551  	VK_OEM_8                           = 223
   552  	VK_OEM_AX                          = 225
   553  	VK_OEM_102                         = 226
   554  	VK_ICO_HELP                        = 227
   555  	VK_ICO_00                          = 228
   556  	VK_PROCESSKEY                      = 229
   557  	VK_ICO_CLEAR                       = 230
   558  	VK_PACKET                          = 231
   559  	VK_OEM_RESET                       = 233
   560  	VK_OEM_JUMP                        = 234
   561  	VK_OEM_PA1                         = 235
   562  	VK_OEM_PA2                         = 236
   563  	VK_OEM_PA3                         = 237
   564  	VK_OEM_WSCTRL                      = 238
   565  	VK_OEM_CUSEL                       = 239
   566  	VK_OEM_ATTN                        = 240
   567  	VK_OEM_FINISH                      = 241
   568  	VK_OEM_COPY                        = 242
   569  	VK_OEM_AUTO                        = 243
   570  	VK_OEM_ENLW                        = 244
   571  	VK_OEM_BACKTAB                     = 245
   572  	VK_ATTN                            = 246
   573  	VK_CRSEL                           = 247
   574  	VK_EXSEL                           = 248
   575  	VK_EREOF                           = 249
   576  	VK_PLAY                            = 250
   577  	VK_ZOOM                            = 251
   578  	VK_NONAME                          = 252
   579  	VK_PA1                             = 253
   580  	VK_OEM_CLEAR                       = 254
   581  	VK_ABNT_C1                         = 193
   582  	VK_ABNT_C2                         = 194
   583  	VK_DBE_ALPHANUMERIC                = 240
   584  	VK_DBE_CODEINPUT                   = 250
   585  	VK_DBE_DBCSCHAR                    = 244
   586  	VK_DBE_DETERMINESTRING             = 252
   587  	VK_DBE_ENTERDLGCONVERSIONMODE      = 253
   588  	VK_DBE_ENTERIMECONFIGMODE          = 248
   589  	VK_DBE_ENTERWORDREGISTERMODE       = 247
   590  	VK_DBE_FLUSHSTRING                 = 249
   591  	VK_DBE_HIRAGANA                    = 242
   592  	VK_DBE_KATAKANA                    = 241
   593  	VK_DBE_NOCODEINPUT                 = 251
   594  	VK_DBE_NOROMAN                     = 246
   595  	VK_DBE_ROMAN                       = 245
   596  	VK_DBE_SBCSCHAR                    = 243
   597  )
   598  
   599  func GetKeyboardLayout(idThread uintptr) uintptr {
   600  	r, _, _ := syscall.SyscallN(_GetKeyboardLayout.Addr(), idThread)
   601  	return r
   602  }
   603  
   604  func ToUnicodeEx(wVirtKey, wScanCode, lpKeyState, pwszBuff, cchBuff, wFlags, dwhkl uintptr) uintptr {
   605  	r, _, _ := syscall.SyscallN(_ToUnicodeEx.Addr(), wVirtKey, wScanCode, lpKeyState, pwszBuff, cchBuff, wFlags, dwhkl)
   606  	return r
   607  }
   608  
   609  const MAPVK_VK_TO_CHAR = 2
   610  const MAPVK_VSC_TO_VK_EX = 3
   611  
   612  func MapVirtualKeyW(uCode, uMapType uintptr) uintptr {
   613  	r, _, _ := syscall.SyscallN(_MapVirtualKeyW.Addr(), uCode, uMapType)
   614  	return r
   615  }
   616  
   617  func GetKeyboardState(lpKeyState uintptr) bool {
   618  	r, _, _ := syscall.SyscallN(_GetKeyboardState.Addr(), lpKeyState)
   619  	return r != 0
   620  }
   621  
   622  func DestroyWindow(hwnd uintptr) bool {
   623  	r, _, _ := syscall.SyscallN(_DestroyWindow.Addr(), hwnd)
   624  	return r != 0
   625  }
   626  
   627  type RECT struct {
   628  	Left   int32
   629  	Top    int32
   630  	Right  int32
   631  	Bottom int32
   632  }
   633  
   634  func GetClientRect(hWnd, lpRect uintptr) bool {
   635  	r, _, _ := syscall.SyscallN(_GetClientRect.Addr(), hWnd, lpRect)
   636  	return r != 0
   637  }
   638  
   639  func AdjustWindowRectEx(hwnd, style, styleEx, rect uintptr) bool {
   640  	menu, _, _ := syscall.SyscallN(_GetMenu.Addr(), hwnd)
   641  	if menu != 0 {
   642  		menu = 1
   643  	}
   644  
   645  	if _GetDpiForWindow.Find() == nil && _AdjustWindowRectExForDpi.Find() == nil {
   646  		dpi, _, _ := syscall.SyscallN(_GetDpiForWindow.Addr(), hwnd)
   647  		r, _, _ := syscall.SyscallN(_AdjustWindowRectExForDpi.Addr(), rect, style, menu, styleEx, dpi)
   648  		return r != 0
   649  	} else {
   650  		r, _, _ := syscall.SyscallN(_AdjustWindowRectEx.Addr(), rect, style, menu, styleEx)
   651  		return r != 0
   652  	}
   653  }
   654  
   655  const SWP_ASYNCWINDOWPOS = 16384
   656  const SWP_NOZORDER = 4
   657  const SWP_NOREPOSITION = 512
   658  const SWP_NOMOVE = 2
   659  const SWP_NOACTIVATE = 16
   660  const SWP_NOOWNERZORDER = 512
   661  const SWP_FRAMECHANGED = 32
   662  const SWP_NOSIZE = 1
   663  
   664  const HWND_TOP = 0
   665  
   666  func SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags uintptr) bool {
   667  	r, _, _ := syscall.SyscallN(_SetWindowPos.Addr(), hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags)
   668  	return r != 0
   669  }
   670  
   671  func InvalidateRgn(hwnd, hrng, berase uintptr) bool {
   672  	r, _, _ := syscall.SyscallN(_InvalidateRgn.Addr(), hwnd, hrng, berase)
   673  	return r != 0
   674  }
   675  
   676  type MINMAXINFO struct {
   677  	PtReserved     POINT
   678  	PtMaxSize      POINT
   679  	PtMaxPosition  POINT
   680  	PtMinTrackSize POINT
   681  	PtMaxTrackSize POINT
   682  }
   683  
   684  const (
   685  	SW_MAXIMIZE = 3
   686  	SW_MINIMIZE = 6
   687  	SW_RESTORE  = 9
   688  )
   689  
   690  const (
   691  	SIZE_MAXIMIZED = 2
   692  	SIZE_RESTORED  = 0
   693  )
   694  
   695  func ShowWindow(hWnd, nCmdShow uintptr) bool {
   696  	r, _, _ := syscall.SyscallN(_ShowWindow.Addr(), hWnd, nCmdShow)
   697  	return r != 0
   698  }
   699  
   700  func GetCursorPos(point uintptr) bool {
   701  	r, _, _ := syscall.SyscallN(_GetCursorPos.Addr(), point)
   702  	return r != 0
   703  }
   704  
   705  func SetWindowTextW(hwnd, lpstring uintptr) bool {
   706  	r, _, _ := syscall.SyscallN(_SetWindowTextW.Addr(), hwnd, lpstring)
   707  	return r != 0
   708  }
   709  
   710  type WINDOWPLACEMENT struct {
   711  	length           uint32
   712  	flags            uint32
   713  	showCmd          uint32
   714  	ptMinPosition    POINT
   715  	ptMaxPosition    POINT
   716  	rcNormalPosition RECT
   717  }
   718  
   719  func GetWindowPlacement(hWnd, lpwndpl uintptr) bool {
   720  	r, _, _ := syscall.SyscallN(_GetWindowPlacement.Addr(), hWnd, lpwndpl)
   721  	return r != 0
   722  }
   723  func SetWindowPlacement(hWnd, lpwndpl uintptr) bool {
   724  	r, _, _ := syscall.SyscallN(_SetWindowPlacement.Addr(), hWnd, lpwndpl)
   725  	return r != 0
   726  }
   727  
   728  func MonitorFromWindow(hwnd, dwFlags uintptr) uintptr {
   729  	r, _, _ := syscall.SyscallN(_MonitorFromWindow.Addr(), hwnd, dwFlags)
   730  	return r
   731  }
   732  
   733  type MONITORINFO struct {
   734  	CbSize    uint32
   735  	RcMonitor RECT
   736  	RcWork    RECT
   737  	DwFlags   uint32
   738  }
   739  
   740  const (
   741  	MONITOR_DEFAULTTOPRIMARY = 1
   742  )
   743  
   744  func GetMonitorInfoW(hMonitor, lpmi uintptr) bool {
   745  	r, _, _ := syscall.SyscallN(_GetMonitorInfoW.Addr(), hMonitor, lpmi)
   746  	return r != 0
   747  }