Related links: https://docs.microsoft.com/es-es/windows/win32/api/winuser/ns-winuser-input and https://docs.microsoft.com/es-es/windows/win32/api/winuser/ns-winuser-mouseinput
This is my code:
Code: Select all
/*
typedef struct tagINPUT {
DWORD type;
union {
MOUSEINPUT mi;
KEYBDINPUT ki;
HARDWAREINPUT hi;
} DUMMYUNIONNAME;
} INPUT, *PINPUT, *LPINPUT;
*/
/*
typedef struct tagMOUSEINPUT {
LONG dx;
LONG dy;
DWORD mouseData;
DWORD dwFlags;
DWORD time;
ULONG_PTR dwExtraInfo;
} MOUSEINPUT, *PMOUSEINPUT, *LPMOUSEINPUT;
*/
f1::
mouseInput := Struct("DWORD type, LONG dx, LONG dy, DWORD mouseData, DWORD dwFlags, DWORD time, ULONG_PTR dwExtraInfo")
mouseInput.type := 0
mouseInput.dx := 0
mouseInput.dy := 0
mouseInput.mouseData := 0
mouseInput.dwFlags := 0x0002
mouseInput.time := 0
mouseInput.dwExtraInfo := 0
msgbox % NumGet(mouseInput , 20, "UINT")
DllCall("SendInput", "UInt", 1, "Ptr", &mouseInput, "Int", sizeof(mouseInput))
sleep, 200
mouseInput.dwFlags := 0x0004
DllCall("SendInput", "UInt", 1, "Ptr", &mouseInput, "Int", sizeof(mouseInput))
return
f2::
structSize := A_PtrSize + 4*4 + A_PtrSize*2
VarSetCapacity( mouseinput, structSize, 0 )
NumPut( 0x0002, mouseinput, A_PtrSize + 4*3, "UInt" ) ; MOUSEEVENTF_LEFTDOWN = 0x0002
DllCall("SendInput", "UInt", 1, "Ptr", &mouseinput, "Int", structSize )
sleep 200
NumPut( 0x0004, mouseinput, A_PtrSize + 4*3, "UInt" ) ; MOUSEEVENTF_LEFTUP = 0x0004
DllCall("SendInput", "UInt", 1, "Ptr", &mouseinput, "Int", structSize )
return
On the f1 I get only 32 bytes, 8 bytes less than the NumPut option.
Questions
- When I did sizeOf("LONG") it outputs 4 bytes. Isn't it supposed to be 8 bytes?
- Even If I change the LONG to PTR to make them be 8 bytes, I still get a different size and the NumGet still outputs a blank value, and ofc the dllcall doesn't work.
- What am I doing wrong?