Kaixxx Posted December 12, 2022 Share Posted December 12, 2022 Hi I am new to the forum but have used AutoIt many years ago. Now I returned to it and got stuck with a problem that I thought would be simple: I want to react to WM_GESTURE messages (pinch/zoom on touch screen) in another program. Background: I have a windows tablet that I no longer use and a USB-oscilloscope (OWON VDS1022) that I rarely use because it is so much hassle to set it up. Now I want to combine both into a compact tablet-oscilloscope. But the app for the oscilloscope was not written with touch in mind. So I need to add some simple features, one of which is the pinch/zoom gesture. I can control the app from AutoIt via hotkeys that change the time base of the waveform, which is basically a zooming function. All I need to know is when somebody performs a pinch/zoom gesture over the applications window. Is there a way to intercept the WM_GESTURE message in this app from AutoIt? I found a nice example for pinch/zoom in your own GUI (see below). Is there a way to adapt this? Thanks a lot! expandcollapse popup; Original code by LawrenceDon & GtaSpider #include <StructureConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <StaticConstants.au3> #RequireAdmin Global $iMemo, $hLab ;Global Const $WM_GESTURE = 0x119 Global Const $GID_BEGIN = 0x01 Global Const $GID_END = 0x02 Global Const $GID_ZOOM = 0x03 Local $hGUI Global $old_ullArg = 0 Global $iFontSize = 9 Global Const $tagPOINTS = "struct;short X;short Y;endstruct" Global Const $tagGESTUREINFO = "UINT cbSize; DWORD dwFlags; DWORD dwID; HWND hwndTarget;" & $tagPOINTS & ";DWORD dwInstanceID; DWORD dwSequenceID; UINT64 ullArgumengs; UINT cbExtraArgs" _Main() Func _Main() $hGUI = GUICreate("WM_GESTURE", 1080, 640) $hLab = GUICtrlCreateLabel("TEST",320,0,760,640,$SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetFont(-1,$iFontSize) GUIRegisterMsg($WM_GESTURE, "WM_GESTURE") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Exit EndFunc ;==>_Main Func WM_GESTURE($hWnd, $Msg, $wParam, $lParam) $GesInfo = DllStructCreate($tagGESTUREINFO) DllStructSetData($GesInfo, "cbSize", DllStructGetSize($GesInfo)) $pGesInfo = DllStructGetPtr($GesInfo) DllCall("User32.dll", "BOOL", "GetGestureInfo", "HANDLE", $lParam, "struct*", $pGesInfo) Local $dwID = DllStructGetData($GesInfo, "dwID") Local $ptsLocX = DllStructGetData($GesInfo, "X") Local $ptsLocY = DllStructGetData($GesInfo, "Y") Local $ullArg = DllStructGetData($GesInfo, "ullArgumengs") Switch $dwID Case $GID_BEGIN, $GID_END ;Reset old_ullArg when event begins/ends $old_ullArg = 0 Case $GID_ZOOM ;only start the process if old_ullArg set before If $old_ullArg > 0 Then ;if old_ullArg is smaller than new ullArg then start the zoom out process (font smaller) If $old_ullArg > $ullArg Then $iFontSize -= 2 If $iFontSize < 1 Then $iFontSize = 1 GUICtrlSetFont($hLab,$iFontSize) Else $iFontSize += 2 GUICtrlSetFont($hLab,$iFontSize) EndIf EndIf $old_ullArg = $ullArg EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY ; Original code by LawrenceDon & GtaSpider #include <StructureConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <StaticConstants.au3> #RequireAdmin Global $iMemo, $hLab ;Global Const $WM_GESTURE = 0x119 Global Const $GID_BEGIN = 0x01 Global Const $GID_END = 0x02 Global Const $GID_ZOOM = 0x03 Local $hGUI Global $old_ullArg = 0 Global $iFontSize = 9 Global Const $tagPOINTS = "struct;short X;short Y;endstruct" Global Const $tagGESTUREINFO = "UINT cbSize; DWORD dwFlags; DWORD dwID; HWND hwndTarget;" & $tagPOINTS & ";DWORD dwInstanceID; DWORD dwSequenceID; UINT64 ullArgumengs; UINT cbExtraArgs" _Main() Func _Main() $hGUI = GUICreate("WM_GESTURE", 1080, 640) $hLab = GUICtrlCreateLabel("TEST",320,0,760,640,$SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetFont(-1,$iFontSize) GUIRegisterMsg($WM_GESTURE, "WM_GESTURE") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Exit EndFunc ;==>_Main Func WM_GESTURE($hWnd, $Msg, $wParam, $lParam) $GesInfo = DllStructCreate($tagGESTUREINFO) DllStructSetData($GesInfo, "cbSize", DllStructGetSize($GesInfo)) $pGesInfo = DllStructGetPtr($GesInfo) DllCall("User32.dll", "BOOL", "GetGestureInfo", "HANDLE", $lParam, "struct*", $pGesInfo) Local $dwID = DllStructGetData($GesInfo, "dwID") Local $ptsLocX = DllStructGetData($GesInfo, "X") Local $ptsLocY = DllStructGetData($GesInfo, "Y") Local $ullArg = DllStructGetData($GesInfo, "ullArgumengs") Switch $dwID Case $GID_BEGIN, $GID_END ;Reset old_ullArg when event begins/ends $old_ullArg = 0 Case $GID_ZOOM ;only start the process if old_ullArg set before If $old_ullArg > 0 Then ;if old_ullArg is smaller than new ullArg then start the zoom out process (font smaller) If $old_ullArg > $ullArg Then $iFontSize -= 2 If $iFontSize < 1 Then $iFontSize = 1 GUICtrlSetFont($hLab,$iFontSize) Else $iFontSize += 2 GUICtrlSetFont($hLab,$iFontSize) EndIf EndIf $old_ullArg = $ullArg EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Link to comment Share on other sites More sharing options...
Kaixxx Posted December 15, 2022 Author Share Posted December 15, 2022 Hmm, let me rephrase my question a little bit simpler: AutoIt can react to mouse movements and clicks anywhere on the screen, right? I want basically the same for touch gestures. Is this possible? I would be thankful for any hint in the right direction. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now