so maybe this will save someone time in the future.
the tricks were that you need to register it as a touch window with windows API RegisterTouchWindow(handle, 0) and the onmessage code for WM_Touch is 0x240
EDIT: Added GetTouchInfo for X, Y, etc.
Code: Select all
SysGet, swidth, 16
SysGet, sheight, 17
gui, add, button, gguiclose, EXIT
gui, add, text, w300 h300 vthetext,
gui, show, w%swidth% h%sheight%, Touchscreen Test
WinGet, thishwnd, ID, Touchscreen Test
registerResult := dllcall("User32.dll\RegisterTouchWindow", Int, thishwnd, Int, 0)
msgbox, DLLCall error level is %errorlevel% (0 = success)
msgbox, Register Touch Window DllCall result is %registerResult% (nonzero = success)
OnMessage(0x240,"Touching") ;WM_TOUCH
return
Touching(wparam, lparam, msg, hwnd)
{
global
GetTouchInfo(wParam, lParam)
}
GetTouchInfo(wParam, lParam)
{
global
Static TI_Size := (4 * 8) + (A_PtrSize * 2) ; Size of TOUCHINPUT
Static OffX := 0
, OffY := OffX + 4
, OffSource := OffY + 4
, OffID := OffSource + A_PtrSize
, OffFlags := OffID + 4
, OffMask := OffFlags + 4
, OffTime := OffMask + 4
, OffExtraInfo := OffTime + 4
, OffContactW := OffExtraInfo + A_PtrSize
, OffContactH := OffContactW + 4
TI_Count := wParam & 0xFFFF ; The low-order word contains the number of touch points associated with this message.
VarSetCapacity(TI_Array, TI_SIze * TI_Count, 0)
If DllCall("User32.dll\GetTouchInputInfo", "Ptr", lParam
, "UInt", TI_Count
, "Ptr", &TI_Array
, "Int", TI_Size
, "UInt") {
TI_Addr := &TI_Array
Loop, % TI_Count {
Msg := "TOUCHINPUT " . A_Index . " of " .TI_COunt
setformat, float, 0.0
Msg .= "`nX: " . NumGet(TI_Addr + 0, OffX, "UInt")/100
Msg .= "`nY: " . NumGet(TI_Addr + 0, OffY, "UInt")/100
Msg .= "`nSource: " . NumGet(TI_Addr + 0, OffSource, "UPtr")
Msg .= "`nID: " . NumGet(TI_Addr + 0, OffID, "UInt")
Msg .= "`nFlags: " . NumGet(TI_Addr + 0, OffFlags, "UInt")
Msg .= "`nMask: " . NumGet(TI_Addr + 0, OffMask, "UInt")
Msg .= "`nTime: " . NumGet(TI_Addr + 0, OffTime, "UInt")
Msg .= "`nExtraInfo: " . NumGet(TI_Addr + 0, OffExtraInfo, "UPtr")
Msg .= "`nContactW: " . NumGet(TI_Addr + 0, OffContactW, "UInt")
Msg .= "`nContactH: " . NumGet(TI_Addr + 0, OffContactH, "UInt")
guicontrol, text, thetext, %msg%
TI_Addr += TI_Size
}
}
}
GuiClose:
ExitApp