Hello guys.

I'm having problems using sendinput.
When i run this code in my debugger when i call sendinput i get an error invalid parameter.
I'm not sure whats wrong here.
I've read Donkeys post but can't seem to figure this out.
Any help would be much appriated.
Thanks



; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    .486                       ; create 32 bit code
    .model flat, stdcall       ; 32 bit memory model
    option casemap :none       ; case sensitive

    include \masm32\include\windows.inc
    include \masm32\include\masm32.inc
    include \masm32\include\user32.inc
    include \masm32\include\kernel32.inc


    includelib \masm32\lib\masm32.lib
    includelib \masm32\lib\user32.lib
    includelib \masm32\lib\kernel32.lib


.data

    window_class db 'Valve001',0
    handle dd ?
    thread_id dd ?
   
.data?

    KEYBOARDINPUT struc
          dtype        DWORD ?
          wVk          WORD  ?
          wScan        WORD  ?
          dwFlags      DWORD ?
          time         DWORD ?
          dwExtraInfo  DWORD ?
     KEYBOARDINPUT ends

keys KEYBOARDINPUT <>
   
.code

start:

    invoke FindWindow,
    addr window_class,
    NULL

    mov handle,eax

    invoke GetWindowThreadProcessId,
    handle,
    thread_id
   
    mov thread_id,eax

    invoke SetForegroundWindow,
    handle

    mov ,1h
    mov ,41h
    mov ,41h
    mov ,0h
    mov ,0h
    mov ,0h
   
    invoke SendInput,
    1,
    OFFSET keys,                        ;pointer to an array of input structures
    SIZEOF KEYBOARDINPUT

invoke ExitProcess,NULL

end start
Posted on 2005-11-04 06:44:59 by gavin
Our structure is short 8 bytes-

KEYBOARDINPUT struc
dtype        DWORD ?
wVk          WORD  ?
wScan        WORD  ?
dwFlags      DWORD ?
time        DWORD ?
dwExtraInfo  DWORD ?
dummy1 db 8 dup (?)
KEYBOARDINPUT ends
Posted on 2005-11-04 14:05:04 by JimG
Hey Jimg your on here too l :)

Man you have been a great help to me.

But i wonder how did you find this out?

Thanks.
Posted on 2005-11-05 11:18:29 by gavin
It just occured to me when I was doing something else.  It's not suprising that even though microsoft requires you to pass the size of the structure, it only works with the exact size it wants.  This is not the only api that does stupid stuff like that.
Posted on 2005-11-05 14:03:55 by JimG