Jump to content

DLLCall - create C array of structs?


 Share

Recommended Posts

Hi folks,

Preamble: I just came from a 2015 (edit: not 2016) topic about simulating multitouch (tl;dr: desktop, trying to get consistent UI zooms for recording; multitouch is smooth and arbitrary level, mouse scrollwheel goes in steps - smooth is better, actual manual touch input with my butterfingers is all over the place).  I can confirm all the other code is working - i.e. I can do a tap, tap and hold, tap-and-drag.  But pinch-to-zoom actually requires more than the single touch.  I know that in InitializeTouchInjection I'll have to set the size to 2 and all that - but sending touch inputs consecutively doesn't seem to work (regardless of size)  Which means I'm pretty sure I have to send the two touches simultaneously.

The MS TechNet sample code has this bit:

POINTER_TOUCH_INFO contact[2];
InitializeTouchInjection(2, TOUCH_FEEDBACK_DEFAULT);
memset(&contact[0], 0, sizeof(POINTER_TOUCH_INFO));
memset(&contact[1], 0, sizeof(POINTER_TOUCH_INFO));

Followed by passing it to the function:

InjectTouchInput(2, contact);

What should I be doing in AutoIt to achieve that same 'contact' variable?

Is it just a new struct with size,entire-touch1-struct-here,size,entire-touch2-struct-here ?

If so, is there a way to take two existing structs, with data set, and combine them in the necessary way, or should I set up a new struct as above, and then set its data from there (similar to what's done in

I'm sure this has been answered before, but 'combine structs', 'concatenate structs', 'array of structs' hasn't proven fruitful

Thread I came from:

TechNet article: https://social.technet.microsoft.com/wiki/contents/articles/6460.simulating-touch-input-in-windows-8-using-touch-injection-api.aspx?PageIndex=2#Simulating_Tap

Edited by kamiquasi
Link to comment
Share on other sites

Quote

Is it just a new struct with size,entire-touch1-struct-here,size,entire-touch2-struct-here ?

Yes.

Quote

If so, is there a way to take two existing structs, with data set, and combine them in the necessary way, or should I set up a new struct as above, and then set its data from there (similar to what's done in

You could do something like this:

#include <Memory.au3>

Local $tStruct1=DllStructCreate("int;int;")
DllStructSetData($tStruct1,1,10)
DllStructSetData($tStruct1,2,20)
Local $tStruct2=DllStructCreate("int;int;")
DllStructSetData($tStruct2,1,30)
DllStructSetData($tStruct2,2,40)

Local $tStructArray=DllStructCreate("int;int;int;int;");with size $tStruct1+$tStruct2

_MemMoveMemory($tStruct1,$tStructArray,DllStructGetSize($tStruct1)) ;copy $tStruct1 to new structure
_MemMoveMemory($tStruct2,DllStructGetPtr($tStructArray)+DllStructGetSize($tStruct1),DllStructGetSize($tStruct2)) ;append $tStruct2

ConsoleWrite(DllStructGetData($tStructArray,1) & @CRLF)
ConsoleWrite(DllStructGetData($tStructArray,2) & @CRLF)
ConsoleWrite(DllStructGetData($tStructArray,3) & @CRLF)
ConsoleWrite(DllStructGetData($tStructArray,4) & @CRLF)


;or

Local $tStructArray=DllStructCreate("int;int;int;int;");with size $tStruct1+$tStruct2
Local $tStruct1=DllStructCreate("int;int;",DllStructGetPtr($tStructArray))
DllStructSetData($tStruct1,1,100)
DllStructSetData($tStruct1,2,200)
Local $tStruct2=DllStructCreate("int;int;",DllStructGetPtr($tStructArray)+DllStructGetSize($tStruct1))
DllStructSetData($tStruct2,1,300)
DllStructSetData($tStruct2,2,400)

ConsoleWrite(DllStructGetData($tStructArray,1) & @CRLF)
ConsoleWrite(DllStructGetData($tStructArray,2) & @CRLF)
ConsoleWrite(DllStructGetData($tStructArray,3) & @CRLF)
ConsoleWrite(DllStructGetData($tStructArray,4) & @CRLF)

Saludos

Link to comment
Share on other sites

@Danyfirex

Thank you!  I ended up using the first method in a quick test.  It's holidays and I don't have access to the software, but I can confirm that both touch points are registered on my home device, and pinch-to-zoom is working on e.g. Google Maps through a browser, Photoshop, and Maya - which makes it exceedingly likely to work in general :)

Thanks again - I'll be sure to add to that other topic.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...