Loading ...
Sorry, an error occurred while loading the content.
 

Mouse Events using SendInput API

Expand Messages
  • gjbilik
    Hi again! Has anyone out there used the SendInput API to send mouse events to the input queue? I m trying and get an error I don t understand. The error I get
    Message 1 of 3 , Oct 1, 2005
      Hi again!

      Has anyone out there used the SendInput API to send mouse events to
      the input queue? I'm trying and get an error I don't understand.
      The error I get is a runtime error: Key is missing. That sounds like
      a response to SendInput for a keyboard event. Which by the way works
      fine in my program.

      Here is the code I am using to set up the mouse structure and then
      call the API

      '
      'Define the mouse input structure
      '
      struct mseInp,_
      type as ulong,_
      dx as ulong,_ 'x coord
      dy as ulong,_ 'y coord
      msdata as word,_
      dwFlags as ulong,_
      time as ulong,_
      dwExtra as ulong,_
      pad1 as char[7]

      mseInp.type.struct=0
      mseInp.msdata.struct=0
      mseInp.dwExtra.struct=0



      'GUIThreadinfo is returned from the GetGUIThreadInfo API call
      mseInp.dx.struct=GUIThreadinfo.x.struct
      mseInp.dy.struct=GUIThreadinfo.y.struct
      mseInp.dwflags.struct=32768
      call sendmouse 'put mouse at previous spot



      '
      'Sub sendmouse sends commands to mouse input queue
      '
      sub sendmouse

      cbSize=14
      cInputs=1
      calldll #user32,"SendInput",_
      cInputs as ulong,_
      mseInp as struct,_
      cbSize as long,_
      result as long

      end sub

      Any help will be greatly appreciated.

      Thanks.

      Greg
    • gjbilik
      Hi again! I ve seen some of the error of my ways. I ve changed the cbSize to 28 which is the size of an Input structure. I was a little confused about that.
      Message 2 of 3 , Oct 1, 2005
        Hi again!

        I've seen some of the error of my ways. I've changed the cbSize to
        28 which is the size of an Input structure. I was a little confused
        about that. I've also changed the pad characters to 4 and then 0.
        However, in all three instances I get the same error as stated below.

        Thanks again for any help.

        Greg
        --- In libertybasic@yahoogroups.com, "gjbilik" <gjbilik@y...> wrote:
        > Hi again!
        >
        > Has anyone out there used the SendInput API to send mouse events to
        > the input queue? I'm trying and get an error I don't understand.
        > The error I get is a runtime error: Key is missing. That sounds
        like
        > a response to SendInput for a keyboard event. Which by the way
        works
        > fine in my program.
        >
        > Here is the code I am using to set up the mouse structure and then
        > call the API
        >
        > '
        > 'Define the mouse input structure
        > '
        > struct mseInp,_
        > type as ulong,_
        > dx as ulong,_ 'x coord
        > dy as ulong,_ 'y coord
        > msdata as word,_
        > dwFlags as ulong,_
        > time as ulong,_
        > dwExtra as ulong,_
        > pad1 as char[7]
        >
        > mseInp.type.struct=0
        > mseInp.msdata.struct=0
        > mseInp.dwExtra.struct=0
        >
        >
        >
        > 'GUIThreadinfo is returned from the GetGUIThreadInfo API call
        > mseInp.dx.struct=GUIThreadinfo.x.struct
        > mseInp.dy.struct=GUIThreadinfo.y.struct
        > mseInp.dwflags.struct=32768
        > call sendmouse 'put mouse at previous spot
        >
        >
        >
        > '
        > 'Sub sendmouse sends commands to mouse input queue
        > '
        > sub sendmouse
        >
        > cbSize=14
        > cInputs=1
        > calldll #user32,"SendInput",_
        > cInputs as ulong,_
        > mseInp as struct,_
        > cbSize as long,_
        > result as long
        >
        > end sub
        >
        > Any help will be greatly appreciated.
        >
        > Thanks.
        >
        > Greg
      • gjbilik
        Hi again! Last message in this thread. I figured out my stupid mistake. in the code below where I set the value of mseInp.dwflags.struct=32768 the F must be
        Message 3 of 3 , Oct 1, 2005
          Hi again!

          Last message in this thread. I figured out my stupid mistake. in the
          code below where I set the value of mseInp.dwflags.struct=32768 the F
          must be capitalized just like I did it in the structure definition.

          By the way, to get the code to work you also have to set cbSize=28
          and remove the pad parameter from the structure definition.

          I guess by sending these emails to the group I had to think and
          really look at what I was doing.

          Thanks for the opportunity to think this one out for myself.

          Greg

          --- In libertybasic@yahoogroups.com, "gjbilik" <gjbilik@y...> wrote:
          > Hi again!
          >
          > I've seen some of the error of my ways. I've changed the cbSize to
          > 28 which is the size of an Input structure. I was a little
          confused
          > about that. I've also changed the pad characters to 4 and then 0.
          > However, in all three instances I get the same error as stated
          below.
          >
          > Thanks again for any help.
          >
          > Greg
          > --- In libertybasic@yahoogroups.com, "gjbilik" <gjbilik@y...> wrote:
          > > Hi again!
          > >
          > > Has anyone out there used the SendInput API to send mouse events
          to
          > > the input queue? I'm trying and get an error I don't
          understand.
          > > The error I get is a runtime error: Key is missing. That sounds
          > like
          > > a response to SendInput for a keyboard event. Which by the way
          > works
          > > fine in my program.
          > >
          > > Here is the code I am using to set up the mouse structure and
          then
          > > call the API
          > >
          > > '
          > > 'Define the mouse input structure
          > > '
          > > struct mseInp,_
          > > type as ulong,_
          > > dx as ulong,_ 'x coord
          > > dy as ulong,_ 'y coord
          > > msdata as word,_
          > > dwFlags as ulong,_
          > > time as ulong,_
          > > dwExtra as ulong,_
          > > pad1 as char[7]
          > >
          > > mseInp.type.struct=0
          > > mseInp.msdata.struct=0
          > > mseInp.dwExtra.struct=0
          > >
          > >
          > >
          > > 'GUIThreadinfo is returned from the GetGUIThreadInfo API call
          > > mseInp.dx.struct=GUIThreadinfo.x.struct
          > > mseInp.dy.struct=GUIThreadinfo.y.struct
          > > mseInp.dwflags.struct=32768
          > > call sendmouse 'put mouse at previous
          spot
          > >
          > >
          > >
          > > '
          > > 'Sub sendmouse sends commands to mouse input queue
          > > '
          > > sub sendmouse
          > >
          > > cbSize=14
          > > cInputs=1
          > > calldll #user32,"SendInput",_
          > > cInputs as ulong,_
          > > mseInp as struct,_
          > > cbSize as long,_
          > > result as long
          > >
          > > end sub
          > >
          > > Any help will be greatly appreciated.
          > >
          > > Thanks.
          > >
          > > Greg
        Your message has been successfully submitted and would be delivered to recipients shortly.