Handle+mouse_event

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Abhishek

    Handle+mouse_event

    Hi,

    how do I pass the handle of a control to the win32 api mouse_event. so
    that it will create the click event on that application only even if there
    is any other window in front of it. I dont what to set focus. I just want
    the click event to happen in that window directly.

    Regards
    Abhishek


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Handle+mouse_ev ent

    Abhishek,

    The Handle property on the control will return the handle that you are
    looking for.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Abhishek" <shake@activele ment.comwrote in message
    news:eY6xruzrGH A.5032@TK2MSFTN GP02.phx.gbl...
    Hi,
    >
    how do I pass the handle of a control to the win32 api mouse_event. so
    that it will create the click event on that application only even if there
    is any other window in front of it. I dont what to set focus. I just want
    the click event to happen in that window directly.
    >
    Regards
    Abhishek
    >

    Comment

    • Dave Sexton

      #3
      Re: Handle+mouse_ev ent

      Hi Abhishek,

      Are you trying to send mouse input to a different process? You'll have to obtain the window handle by enumerating the windows in
      the process and view the text and type to find the specific control. There a Win32 API functions that you can use such as
      EnumWindows and EnumChildWindow s.

      To simulate a click in your own application obtain the handle of the control from the Control.Handle property.

      In either case after you retrieve the handle pass it to the external SendMessage Win32 API function along with WM_LBUTTONUP.

      (Note that a few controls in the framework have a PerformClick method, which will alleviate the need for interop if you can use
      them.)

      --
      Dave Sexton

      "Abhishek" <shake@activele ment.comwrote in message news:eY6xruzrGH A.5032@TK2MSFTN GP02.phx.gbl...
      Hi,
      >
      how do I pass the handle of a control to the win32 api mouse_event. so that it will create the click event on that application
      only even if there is any other window in front of it. I dont what to set focus. I just want the click event to happen in that
      window directly.
      >
      Regards
      Abhishek
      >

      Comment

      • Dave Sexton

        #4
        Re: Handle+mouse_ev ent

        Hi Abhiishek,

        Try sending WM_LBUTTONDOWN and then WM_LBUTTONUP and specify the control's handle using the Control.Handle property. I doubt this
        will work cross-process but you could try to obtain the handle to a window in another application using the EnumWindows or
        EnumChildWindow s Win32 API functions.

        private void SimulateClick(C ontrol ctrl)
        {
        if (ctrl == null)
        throw new ArgumentNullExc eption("ctrl");

        int x = 8, y = 8;
        int point = x + (y << 16);

        SendMessage(ctr l.Handle, WM_LBUTTONDOWN, 0, point);
        SendMessage(ctr l.Handle, WM_LBUTTONUP, 0, point));
        }

        private const uint WM_LBUTTONUP = 0x0202, WM_LBUTTONDOWN = 0x0201;

        [DllImport("user 32.dll")]
        public static extern int SendMessage(Int Ptr hwnd, uint msg, int wparam, int lparam);


        --
        Dave Sexton

        "Abhishek" <shake@activele ment.comwrote in message news:eY6xruzrGH A.5032@TK2MSFTN GP02.phx.gbl...
        Hi,
        >
        how do I pass the handle of a control to the win32 api mouse_event. so that it will create the click event on that application
        only even if there is any other window in front of it. I dont what to set focus. I just want the click event to happen in that
        window directly.
        >
        Regards
        Abhishek
        >

        Comment

        • Abhishek

          #5
          Re: Handle+mouse_ev ent

          Hi All

          Getting the handle of the contol is not the problem. if I have a game
          running then the mouse event does not function (with mouse_event). the
          sendmessage is not working at all, the application gets focus but the click
          event is not happening.

          SendMessage(axW ebBrowser1.Hand le, WM_LBUTTONDOWN, 0, point);
          SendMessage(axW ebBrowser1.Hand le, WM_LBUTTONUP, 0, point);


          This is the mouse_event
          mouse_event(MOU SEEVENTF_LEFTDO WN, 0, 0, 0, new System.IntPtr(0 ));
          mouse_event(MOU SEEVENTF_LEFTUP , 0, 0, 0, new System.IntPtr(0 ));

          regards
          Abhishek

          "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
          news:Of$zhN6rGH A.3964@TK2MSFTN GP04.phx.gbl...
          Hi Abhiishek,
          >
          Try sending WM_LBUTTONDOWN and then WM_LBUTTONUP and specify the control's
          handle using the Control.Handle property. I doubt this will work
          cross-process but you could try to obtain the handle to a window in
          another application using the EnumWindows or EnumChildWindow s Win32 API
          functions.
          >
          private void SimulateClick(C ontrol ctrl)
          {
          if (ctrl == null)
          throw new ArgumentNullExc eption("ctrl");
          >
          int x = 8, y = 8;
          int point = x + (y << 16);
          >
          SendMessage(ctr l.Handle, WM_LBUTTONDOWN, 0, point);
          SendMessage(ctr l.Handle, WM_LBUTTONUP, 0, point));
          }
          >
          private const uint WM_LBUTTONUP = 0x0202, WM_LBUTTONDOWN = 0x0201;
          >
          [DllImport("user 32.dll")]
          public static extern int SendMessage(Int Ptr hwnd, uint msg, int wparam,
          int lparam);
          >
          >
          --
          Dave Sexton
          >
          "Abhishek" <shake@activele ment.comwrote in message
          news:eY6xruzrGH A.5032@TK2MSFTN GP02.phx.gbl...
          >Hi,
          >>
          > how do I pass the handle of a control to the win32 api mouse_event. so
          >that it will create the click event on that application only even if
          >there is any other window in front of it. I dont what to set focus. I
          >just want the click event to happen in that window directly.
          >>
          >Regards
          >Abhishek
          >>
          >
          >

          Comment

          • Dave Sexton

            #6
            Re: Handle+mouse_ev ent

            Hi Abhishek,

            Is your 'game' by any chance tying up the UI Thread? You'd have to call Application.DoE vents() in that case to allow the Control
            some time to process your mouse notifications, however a better program architecture would be more appropriate.

            Actually, after reviewing your post a second time I'm not so sure I fully understand the situation.

            Do you have two applications running simultaneously and you are attempting to get one application to send a mouse notification to
            the other? If so, are both apps managed code?
            Do you have a single, managed application with two visible Forms and you are attempting to send a mouse notification to a control on
            the unfocused Form?

            Please clarify. I'd like to help if I can.

            --
            Dave Sexton

            "Abhishek" <shake@activele ment.comwrote in message news:eaQE8v7rGH A.356@TK2MSFTNG P05.phx.gbl...
            Hi All
            >
            Getting the handle of the contol is not the problem. if I have a game running then the mouse event does not function (with
            mouse_event). the sendmessage is not working at all, the application gets focus but the click event is not happening.
            >
            SendMessage(axW ebBrowser1.Hand le, WM_LBUTTONDOWN, 0, point);
            SendMessage(axW ebBrowser1.Hand le, WM_LBUTTONUP, 0, point);
            >
            >
            This is the mouse_event
            mouse_event(MOU SEEVENTF_LEFTDO WN, 0, 0, 0, new System.IntPtr(0 ));
            mouse_event(MOU SEEVENTF_LEFTUP , 0, 0, 0, new System.IntPtr(0 ));
            >
            regards
            Abhishek
            >
            "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message news:Of$zhN6rGH A.3964@TK2MSFTN GP04.phx.gbl...
            >Hi Abhiishek,
            >>
            >Try sending WM_LBUTTONDOWN and then WM_LBUTTONUP and specify the control's handle using the Control.Handle property. I doubt
            >this will work cross-process but you could try to obtain the handle to a window in another application using the EnumWindows or
            >EnumChildWindo ws Win32 API functions.
            >>
            >private void SimulateClick(C ontrol ctrl)
            >{
            >if (ctrl == null)
            > throw new ArgumentNullExc eption("ctrl");
            >>
            >int x = 8, y = 8;
            >int point = x + (y << 16);
            >>
            >SendMessage(ct rl.Handle, WM_LBUTTONDOWN, 0, point);
            >SendMessage(ct rl.Handle, WM_LBUTTONUP, 0, point));
            >}
            >>
            >private const uint WM_LBUTTONUP = 0x0202, WM_LBUTTONDOWN = 0x0201;
            >>
            >[DllImport("user 32.dll")]
            >public static extern int SendMessage(Int Ptr hwnd, uint msg, int wparam, int lparam);
            >>
            >>
            >--
            >Dave Sexton
            >>
            >"Abhishek" <shake@activele ment.comwrote in message news:eY6xruzrGH A.5032@TK2MSFTN GP02.phx.gbl...
            >>Hi,
            >>>
            >> how do I pass the handle of a control to the win32 api mouse_event. so that it will create the click event on that
            >>application only even if there is any other window in front of it. I dont what to set focus. I just want the click event to
            >>happen in that window directly.
            >>>
            >>Regards
            >>Abhishek
            >>>
            >>
            >>
            >
            >

            Comment

            • Abhishek

              #7
              Re: Handle+mouse_ev ent

              Hi Dave,

              i am trying to create a ingame brower window. for this my dll is creating
              bmp's of the embedded browser which present on a win form. This DLL is
              loaded by my proxy directx 9 dll which is called by the game. this give me
              real time render. I can watch youtube video's in game without a single
              frameskip. the next step for me is the recreate a ingame click on a location
              x, y in my browser. so that the navigation happens seamlessly. they are both
              one below each other in placement(start x and y for both ingame and out of
              game is 0,0 for now).
              below are the two functions that should be able to handle this. the
              mouse_event work perfectly when the browser is visible on screen.but
              otherwise it down not. which is why i wanted to know if you can pass the
              handle of the browser like in SendMessage so that the click happens in that.

              In sendmessage the form becomes formost but no click happens.
              private const int MOUSEEVENTF_LEF TDOWN = 0x2;
              private const int MOUSEEVENTF_LEF TUP = 0x4;
              private const uint WM_LBUTTONUP = 0x202, WM_LBUTTONDOWN = 0x201;

              public unsafe void createleftclick () {
              int x = 8, y = 8;
              int point = x + (y << 16);
              SetCursorPos(8, 8);
              SendMessage(axW ebBrowser1.Hand le, WM_LBUTTONDOWN, 0, point);
              SendMessage(axW ebBrowser1.Hand le, WM_LBUTTONUP, 0, point);
              SendMessage(axW ebBrowser1.Hand le, WM_LBUTTONDOWN, 0, point);
              SendMessage(axW ebBrowser1.Hand le, WM_LBUTTONUP, 0, point);
              }

              public void SendClick(int px, int py)
              {
              SetCursorPos(25 , 25);
              mouse_event(MOU SEEVENTF_LEFTDO WN, 0, 0, 0, new System.IntPtr(0 ));
              mouse_event(MOU SEEVENTF_LEFTUP , 0, 0, 0, new System.IntPtr(0 ));
              }

              My directx dll will just call the function directly
              Regards
              Abhishek

              "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
              news:%237duRj8r GHA.696@TK2MSFT NGP02.phx.gbl.. .
              Hi Abhishek,
              >
              Is your 'game' by any chance tying up the UI Thread? You'd have to call
              Application.DoE vents() in that case to allow the Control some time to
              process your mouse notifications, however a better program architecture
              would be more appropriate.
              >
              Actually, after reviewing your post a second time I'm not so sure I fully
              understand the situation.
              >
              Do you have two applications running simultaneously and you are attempting
              to get one application to send a mouse notification to the other? If so,
              are both apps managed code?
              Do you have a single, managed application with two visible Forms and you
              are attempting to send a mouse notification to a control on the unfocused
              Form?
              >
              Please clarify. I'd like to help if I can.
              >
              --
              Dave Sexton
              >
              "Abhishek" <shake@activele ment.comwrote in message
              news:eaQE8v7rGH A.356@TK2MSFTNG P05.phx.gbl...
              >Hi All
              >>
              >Getting the handle of the contol is not the problem. if I have a game
              >running then the mouse event does not function (with mouse_event). the
              >sendmessage is not working at all, the application gets focus but the
              >click event is not happening.
              >>
              >SendMessage(ax WebBrowser1.Han dle, WM_LBUTTONDOWN, 0, point);
              >SendMessage(ax WebBrowser1.Han dle, WM_LBUTTONUP, 0, point);
              >>
              >>
              >This is the mouse_event
              >mouse_event(MO USEEVENTF_LEFTD OWN, 0, 0, 0, new System.IntPtr(0 ));
              >mouse_event(MO USEEVENTF_LEFTU P, 0, 0, 0, new System.IntPtr(0 ));
              >>
              >regards
              >Abhishek
              >>
              >"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
              >news:Of$zhN6rG HA.3964@TK2MSFT NGP04.phx.gbl.. .
              >>Hi Abhiishek,
              >>>
              >>Try sending WM_LBUTTONDOWN and then WM_LBUTTONUP and specify the
              >>control's handle using the Control.Handle property. I doubt this will
              >>work cross-process but you could try to obtain the handle to a window in
              >>another application using the EnumWindows or EnumChildWindow s Win32 API
              >>functions.
              >>>
              >>private void SimulateClick(C ontrol ctrl)
              >>{
              >>if (ctrl == null)
              >> throw new ArgumentNullExc eption("ctrl");
              >>>
              >>int x = 8, y = 8;
              >>int point = x + (y << 16);
              >>>
              >>SendMessage(c trl.Handle, WM_LBUTTONDOWN, 0, point);
              >>SendMessage(c trl.Handle, WM_LBUTTONUP, 0, point));
              >>}
              >>>
              >>private const uint WM_LBUTTONUP = 0x0202, WM_LBUTTONDOWN = 0x0201;
              >>>
              >>[DllImport("user 32.dll")]
              >>public static extern int SendMessage(Int Ptr hwnd, uint msg, int wparam,
              >>int lparam);
              >>>
              >>>
              >>--
              >>Dave Sexton
              >>>
              >>"Abhishek" <shake@activele ment.comwrote in message
              >>news:eY6xruzr GHA.5032@TK2MSF TNGP02.phx.gbl. ..
              >>>Hi,
              >>>>
              >>> how do I pass the handle of a control to the win32 api mouse_event.
              >>>so that it will create the click event on that application only even if
              >>>there is any other window in front of it. I dont what to set focus. I
              >>>just want the click event to happen in that window directly.
              >>>>
              >>>Regards
              >>>Abhishek
              >>>>
              >>>
              >>>
              >>
              >>
              >
              >

              Comment

              • Abhishek

                #8
                Re: Handle+mouse_ev ent

                I added

                rt1 = SendMessage(thi s.Handle, WM_CLOSE, 0, 0);
                the application is closing but the click is not happening
                I just cant understand why

                Regards
                Abhishek

                "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                news:%237duRj8r GHA.696@TK2MSFT NGP02.phx.gbl.. .
                Hi Abhishek,
                >
                Is your 'game' by any chance tying up the UI Thread? You'd have to call
                Application.DoE vents() in that case to allow the Control some time to
                process your mouse notifications, however a better program architecture
                would be more appropriate.
                >
                Actually, after reviewing your post a second time I'm not so sure I fully
                understand the situation.
                >
                Do you have two applications running simultaneously and you are attempting
                to get one application to send a mouse notification to the other? If so,
                are both apps managed code?
                Do you have a single, managed application with two visible Forms and you
                are attempting to send a mouse notification to a control on the unfocused
                Form?
                >
                Please clarify. I'd like to help if I can.
                >
                --
                Dave Sexton
                >
                "Abhishek" <shake@activele ment.comwrote in message
                news:eaQE8v7rGH A.356@TK2MSFTNG P05.phx.gbl...
                >Hi All
                >>
                >Getting the handle of the contol is not the problem. if I have a game
                >running then the mouse event does not function (with mouse_event). the
                >sendmessage is not working at all, the application gets focus but the
                >click event is not happening.
                >>
                >SendMessage(ax WebBrowser1.Han dle, WM_LBUTTONDOWN, 0, point);
                >SendMessage(ax WebBrowser1.Han dle, WM_LBUTTONUP, 0, point);
                >>
                >>
                >This is the mouse_event
                >mouse_event(MO USEEVENTF_LEFTD OWN, 0, 0, 0, new System.IntPtr(0 ));
                >mouse_event(MO USEEVENTF_LEFTU P, 0, 0, 0, new System.IntPtr(0 ));
                >>
                >regards
                >Abhishek
                >>
                >"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                >news:Of$zhN6rG HA.3964@TK2MSFT NGP04.phx.gbl.. .
                >>Hi Abhiishek,
                >>>
                >>Try sending WM_LBUTTONDOWN and then WM_LBUTTONUP and specify the
                >>control's handle using the Control.Handle property. I doubt this will
                >>work cross-process but you could try to obtain the handle to a window in
                >>another application using the EnumWindows or EnumChildWindow s Win32 API
                >>functions.
                >>>
                >>private void SimulateClick(C ontrol ctrl)
                >>{
                >>if (ctrl == null)
                >> throw new ArgumentNullExc eption("ctrl");
                >>>
                >>int x = 8, y = 8;
                >>int point = x + (y << 16);
                >>>
                >>SendMessage(c trl.Handle, WM_LBUTTONDOWN, 0, point);
                >>SendMessage(c trl.Handle, WM_LBUTTONUP, 0, point));
                >>}
                >>>
                >>private const uint WM_LBUTTONUP = 0x0202, WM_LBUTTONDOWN = 0x0201;
                >>>
                >>[DllImport("user 32.dll")]
                >>public static extern int SendMessage(Int Ptr hwnd, uint msg, int wparam,
                >>int lparam);
                >>>
                >>>
                >>--
                >>Dave Sexton
                >>>
                >>"Abhishek" <shake@activele ment.comwrote in message
                >>news:eY6xruzr GHA.5032@TK2MSF TNGP02.phx.gbl. ..
                >>>Hi,
                >>>>
                >>> how do I pass the handle of a control to the win32 api mouse_event.
                >>>so that it will create the click event on that application only even if
                >>>there is any other window in front of it. I dont what to set focus. I
                >>>just want the click event to happen in that window directly.
                >>>>
                >>>Regards
                >>>Abhishek
                >>>>
                >>>
                >>>
                >>
                >>
                >
                >

                Comment

                • Dave Sexton

                  #9
                  Re: Handle+mouse_ev ent

                  Hi abhishek,

                  Interesting idea but I have no idea what the browser is doing with your messages. Since it is a browser, after all, why not just
                  call ExecScript and perform a click in the actual browser using something like the following:

                  <script language="JavaS cript">
                  function performClick(x, y) {
                  obj = document.elemen tFromPoint(x, y);
                  if (obj.click)
                  obj.click();"
                  }
                  </script>

                  MSDN object.click() method reference:


                  If you are using the 2.0 framework's WebBrowser control:

                  browser.Documen t.InvokeScript( "performCli ck", x, y);

                  For the ActiveX browser use the ExecScript method from IHTMLWindow2 to call the function.

                  --
                  Dave Sexton

                  "Abhishek" <shake@activele ment.comwrote in message news:uTCMbR9rGH A.3412@TK2MSFTN GP05.phx.gbl...
                  Hi Dave,
                  >
                  i am trying to create a ingame brower window. for this my dll is creating bmp's of the embedded browser which present on a win
                  form. This DLL is loaded by my proxy directx 9 dll which is called by the game. this give me real time render. I can watch youtube
                  video's in game without a single frameskip. the next step for me is the recreate a ingame click on a location x, y in my browser.
                  so that the navigation happens seamlessly. they are both one below each other in placement(start x and y for both ingame and out
                  of game is 0,0 for now).
                  below are the two functions that should be able to handle this. the mouse_event work perfectly when the browser is visible on
                  screen.but otherwise it down not. which is why i wanted to know if you can pass the handle of the browser like in SendMessage so
                  that the click happens in that.
                  >
                  In sendmessage the form becomes formost but no click happens.
                  private const int MOUSEEVENTF_LEF TDOWN = 0x2;
                  private const int MOUSEEVENTF_LEF TUP = 0x4;
                  private const uint WM_LBUTTONUP = 0x202, WM_LBUTTONDOWN = 0x201;
                  >
                  public unsafe void createleftclick () {
                  int x = 8, y = 8;
                  int point = x + (y << 16);
                  SetCursorPos(8, 8);
                  SendMessage(axW ebBrowser1.Hand le, WM_LBUTTONDOWN, 0, point);
                  SendMessage(axW ebBrowser1.Hand le, WM_LBUTTONUP, 0, point);
                  SendMessage(axW ebBrowser1.Hand le, WM_LBUTTONDOWN, 0, point);
                  SendMessage(axW ebBrowser1.Hand le, WM_LBUTTONUP, 0, point);
                  }
                  >
                  public void SendClick(int px, int py)
                  {
                  SetCursorPos(25 , 25);
                  mouse_event(MOU SEEVENTF_LEFTDO WN, 0, 0, 0, new System.IntPtr(0 ));
                  mouse_event(MOU SEEVENTF_LEFTUP , 0, 0, 0, new System.IntPtr(0 ));
                  }
                  >
                  My directx dll will just call the function directly
                  Regards
                  Abhishek
                  >
                  "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message news:%237duRj8r GHA.696@TK2MSFT NGP02.phx.gbl.. .
                  >Hi Abhishek,
                  >>
                  >Is your 'game' by any chance tying up the UI Thread? You'd have to call Application.DoE vents() in that case to allow the Control
                  >some time to process your mouse notifications, however a better program architecture would be more appropriate.
                  >>
                  >Actually, after reviewing your post a second time I'm not so sure I fully understand the situation.
                  >>
                  >Do you have two applications running simultaneously and you are attempting to get one application to send a mouse notification to
                  >the other? If so, are both apps managed code?
                  >Do you have a single, managed application with two visible Forms and you are attempting to send a mouse notification to a control
                  >on the unfocused Form?
                  >>
                  >Please clarify. I'd like to help if I can.
                  >>
                  >--
                  >Dave Sexton
                  >>
                  >"Abhishek" <shake@activele ment.comwrote in message news:eaQE8v7rGH A.356@TK2MSFTNG P05.phx.gbl...
                  >>Hi All
                  >>>
                  >>Getting the handle of the contol is not the problem. if I have a game running then the mouse event does not function (with
                  >>mouse_event ). the sendmessage is not working at all, the application gets focus but the click event is not happening.
                  >>>
                  >>SendMessage(a xWebBrowser1.Ha ndle, WM_LBUTTONDOWN, 0, point);
                  >>SendMessage(a xWebBrowser1.Ha ndle, WM_LBUTTONUP, 0, point);
                  >>>
                  >>>
                  >>This is the mouse_event
                  >>mouse_event(M OUSEEVENTF_LEFT DOWN, 0, 0, 0, new System.IntPtr(0 ));
                  >>mouse_event(M OUSEEVENTF_LEFT UP, 0, 0, 0, new System.IntPtr(0 ));
                  >>>
                  >>regards
                  >>Abhishek
                  >>>
                  >>"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message news:Of$zhN6rGH A.3964@TK2MSFTN GP04.phx.gbl...
                  >>>Hi Abhiishek,
                  >>>>
                  >>>Try sending WM_LBUTTONDOWN and then WM_LBUTTONUP and specify the control's handle using the Control.Handle property. I doubt
                  >>>this will work cross-process but you could try to obtain the handle to a window in another application using the EnumWindows or
                  >>>EnumChildWin dows Win32 API functions.
                  >>>>
                  >>>private void SimulateClick(C ontrol ctrl)
                  >>>{
                  >>>if (ctrl == null)
                  >>> throw new ArgumentNullExc eption("ctrl");
                  >>>>
                  >>>int x = 8, y = 8;
                  >>>int point = x + (y << 16);
                  >>>>
                  >>>SendMessage( ctrl.Handle, WM_LBUTTONDOWN, 0, point);
                  >>>SendMessage( ctrl.Handle, WM_LBUTTONUP, 0, point));
                  >>>}
                  >>>>
                  >>>private const uint WM_LBUTTONUP = 0x0202, WM_LBUTTONDOWN = 0x0201;
                  >>>>
                  >>>[DllImport("user 32.dll")]
                  >>>public static extern int SendMessage(Int Ptr hwnd, uint msg, int wparam, int lparam);
                  >>>>
                  >>>>
                  >>>--
                  >>>Dave Sexton
                  >>>>
                  >>>"Abhishek" <shake@activele ment.comwrote in message news:eY6xruzrGH A.5032@TK2MSFTN GP02.phx.gbl...
                  >>>>Hi,
                  >>>>>
                  >>>> how do I pass the handle of a control to the win32 api mouse_event. so that it will create the click event on that
                  >>>>applicati on only even if there is any other window in front of it. I dont what to set focus. I just want the click event to
                  >>>>happen in that window directly.
                  >>>>>
                  >>>>Regards
                  >>>>Abhishek
                  >>>>>
                  >>>>
                  >>>>
                  >>>
                  >>>
                  >>
                  >>
                  >
                  >

                  Comment

                  • Dave Sexton

                    #10
                    Re: Handle+mouse_ev ent

                    Hi Abhishek,

                    Does SendMessage return 0 when you send WM_LBUTTONDOWN or UP?

                    Either way, I think your out of luck with this approach (see my other post) but if it's non-zero that would indicate an error and
                    you should go from there.

                    --
                    Dave Sexton

                    "Abhishek" <shake@activele ment.comwrote in message news:e$VVXU$rGH A.3676@TK2MSFTN GP03.phx.gbl...
                    >I added
                    >
                    rt1 = SendMessage(thi s.Handle, WM_CLOSE, 0, 0);
                    the application is closing but the click is not happening
                    I just cant understand why
                    >
                    Regards
                    Abhishek
                    >
                    "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message news:%237duRj8r GHA.696@TK2MSFT NGP02.phx.gbl.. .
                    >Hi Abhishek,
                    >>
                    >Is your 'game' by any chance tying up the UI Thread? You'd have to call Application.DoE vents() in that case to allow the Control
                    >some time to process your mouse notifications, however a better program architecture would be more appropriate.
                    >>
                    >Actually, after reviewing your post a second time I'm not so sure I fully understand the situation.
                    >>
                    >Do you have two applications running simultaneously and you are attempting to get one application to send a mouse notification to
                    >the other? If so, are both apps managed code?
                    >Do you have a single, managed application with two visible Forms and you are attempting to send a mouse notification to a control
                    >on the unfocused Form?
                    >>
                    >Please clarify. I'd like to help if I can.
                    >>
                    >--
                    >Dave Sexton
                    >>
                    >"Abhishek" <shake@activele ment.comwrote in message news:eaQE8v7rGH A.356@TK2MSFTNG P05.phx.gbl...
                    >>Hi All
                    >>>
                    >>Getting the handle of the contol is not the problem. if I have a game running then the mouse event does not function (with
                    >>mouse_event ). the sendmessage is not working at all, the application gets focus but the click event is not happening.
                    >>>
                    >>SendMessage(a xWebBrowser1.Ha ndle, WM_LBUTTONDOWN, 0, point);
                    >>SendMessage(a xWebBrowser1.Ha ndle, WM_LBUTTONUP, 0, point);
                    >>>
                    >>>
                    >>This is the mouse_event
                    >>mouse_event(M OUSEEVENTF_LEFT DOWN, 0, 0, 0, new System.IntPtr(0 ));
                    >>mouse_event(M OUSEEVENTF_LEFT UP, 0, 0, 0, new System.IntPtr(0 ));
                    >>>
                    >>regards
                    >>Abhishek
                    >>>
                    >>"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message news:Of$zhN6rGH A.3964@TK2MSFTN GP04.phx.gbl...
                    >>>Hi Abhiishek,
                    >>>>
                    >>>Try sending WM_LBUTTONDOWN and then WM_LBUTTONUP and specify the control's handle using the Control.Handle property. I doubt
                    >>>this will work cross-process but you could try to obtain the handle to a window in another application using the EnumWindows or
                    >>>EnumChildWin dows Win32 API functions.
                    >>>>
                    >>>private void SimulateClick(C ontrol ctrl)
                    >>>{
                    >>>if (ctrl == null)
                    >>> throw new ArgumentNullExc eption("ctrl");
                    >>>>
                    >>>int x = 8, y = 8;
                    >>>int point = x + (y << 16);
                    >>>>
                    >>>SendMessage( ctrl.Handle, WM_LBUTTONDOWN, 0, point);
                    >>>SendMessage( ctrl.Handle, WM_LBUTTONUP, 0, point));
                    >>>}
                    >>>>
                    >>>private const uint WM_LBUTTONUP = 0x0202, WM_LBUTTONDOWN = 0x0201;
                    >>>>
                    >>>[DllImport("user 32.dll")]
                    >>>public static extern int SendMessage(Int Ptr hwnd, uint msg, int wparam, int lparam);
                    >>>>
                    >>>>
                    >>>--
                    >>>Dave Sexton
                    >>>>
                    >>>"Abhishek" <shake@activele ment.comwrote in message news:eY6xruzrGH A.5032@TK2MSFTN GP02.phx.gbl...
                    >>>>Hi,
                    >>>>>
                    >>>> how do I pass the handle of a control to the win32 api mouse_event. so that it will create the click event on that
                    >>>>applicati on only even if there is any other window in front of it. I dont what to set focus. I just want the click event to
                    >>>>happen in that window directly.
                    >>>>>
                    >>>>Regards
                    >>>>Abhishek
                    >>>>>
                    >>>>
                    >>>>
                    >>>
                    >>>
                    >>
                    >>
                    >
                    >

                    Comment

                    • Abhishek

                      #11
                      Re: Handle+mouse_ev ent

                      its is returning zero!


                      "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                      news:en4NokBsGH A.3412@TK2MSFTN GP05.phx.gbl...
                      Hi Abhishek,
                      >
                      Does SendMessage return 0 when you send WM_LBUTTONDOWN or UP?
                      >
                      Either way, I think your out of luck with this approach (see my other
                      post) but if it's non-zero that would indicate an error and you should go
                      from there.
                      >
                      --
                      Dave Sexton
                      >
                      "Abhishek" <shake@activele ment.comwrote in message
                      news:e$VVXU$rGH A.3676@TK2MSFTN GP03.phx.gbl...
                      >>I added
                      >>
                      >rt1 = SendMessage(thi s.Handle, WM_CLOSE, 0, 0);
                      >the application is closing but the click is not happening
                      >I just cant understand why
                      >>
                      >Regards
                      >Abhishek
                      >>
                      >"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                      >news:%237duRj8 rGHA.696@TK2MSF TNGP02.phx.gbl. ..
                      >>Hi Abhishek,
                      >>>
                      >>Is your 'game' by any chance tying up the UI Thread? You'd have to call
                      >>Application.D oEvents() in that case to allow the Control some time to
                      >>process your mouse notifications, however a better program architecture
                      >>would be more appropriate.
                      >>>
                      >>Actually, after reviewing your post a second time I'm not so sure I
                      >>fully understand the situation.
                      >>>
                      >>Do you have two applications running simultaneously and you are
                      >>attempting to get one application to send a mouse notification to the
                      >>other? If so, are both apps managed code?
                      >>Do you have a single, managed application with two visible Forms and you
                      >>are attempting to send a mouse notification to a control on the
                      >>unfocused Form?
                      >>>
                      >>Please clarify. I'd like to help if I can.
                      >>>
                      >>--
                      >>Dave Sexton
                      >>>
                      >>"Abhishek" <shake@activele ment.comwrote in message
                      >>news:eaQE8v7r GHA.356@TK2MSFT NGP05.phx.gbl.. .
                      >>>Hi All
                      >>>>
                      >>>Getting the handle of the contol is not the problem. if I have a game
                      >>>running then the mouse event does not function (with mouse_event). the
                      >>>sendmessag e is not working at all, the application gets focus but the
                      >>>click event is not happening.
                      >>>>
                      >>>SendMessage( axWebBrowser1.H andle, WM_LBUTTONDOWN, 0, point);
                      >>>SendMessage( axWebBrowser1.H andle, WM_LBUTTONUP, 0, point);
                      >>>>
                      >>>>
                      >>>This is the mouse_event
                      >>>mouse_event( MOUSEEVENTF_LEF TDOWN, 0, 0, 0, new System.IntPtr(0 ));
                      >>>mouse_event( MOUSEEVENTF_LEF TUP, 0, 0, 0, new System.IntPtr(0 ));
                      >>>>
                      >>>regards
                      >>>Abhishek
                      >>>>
                      >>>"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                      >>>news:Of$zhN6 rGHA.3964@TK2MS FTNGP04.phx.gbl ...
                      >>>>Hi Abhiishek,
                      >>>>>
                      >>>>Try sending WM_LBUTTONDOWN and then WM_LBUTTONUP and specify the
                      >>>>control's handle using the Control.Handle property. I doubt this will
                      >>>>work cross-process but you could try to obtain the handle to a window
                      >>>>in another application using the EnumWindows or EnumChildWindow s Win32
                      >>>>API functions.
                      >>>>>
                      >>>>private void SimulateClick(C ontrol ctrl)
                      >>>>{
                      >>>>if (ctrl == null)
                      >>>> throw new ArgumentNullExc eption("ctrl");
                      >>>>>
                      >>>>int x = 8, y = 8;
                      >>>>int point = x + (y << 16);
                      >>>>>
                      >>>>SendMessage (ctrl.Handle, WM_LBUTTONDOWN, 0, point);
                      >>>>SendMessage (ctrl.Handle, WM_LBUTTONUP, 0, point));
                      >>>>}
                      >>>>>
                      >>>>private const uint WM_LBUTTONUP = 0x0202, WM_LBUTTONDOWN = 0x0201;
                      >>>>>
                      >>>>[DllImport("user 32.dll")]
                      >>>>public static extern int SendMessage(Int Ptr hwnd, uint msg, int
                      >>>>wparam, int lparam);
                      >>>>>
                      >>>>>
                      >>>>--
                      >>>>Dave Sexton
                      >>>>>
                      >>>>"Abhishek " <shake@activele ment.comwrote in message
                      >>>>news:eY6xru zrGHA.5032@TK2M SFTNGP02.phx.gb l...
                      >>>>>Hi,
                      >>>>>>
                      >>>>> how do I pass the handle of a control to the win32 api
                      >>>>>mouse_even t. so that it will create the click event on that
                      >>>>>applicatio n only even if there is any other window in front of it. I
                      >>>>>dont what to set focus. I just want the click event to happen in that
                      >>>>>window directly.
                      >>>>>>
                      >>>>>Regards
                      >>>>>Abhishek
                      >>>>>>
                      >>>>>
                      >>>>>
                      >>>>
                      >>>>
                      >>>
                      >>>
                      >>
                      >>
                      >
                      >

                      Comment

                      • Abhishek

                        #12
                        Re: Handle+mouse_ev ent

                        cant use the script :(

                        Since this will just create a event on a link. bit of there is flash open
                        then? I will get the object of the flash and the click will not happen on
                        the button that is in the flash. also mouseovers and other stuff will not
                        happen. I need to create actual in game browser with all the bell and
                        whistles there is also the issue of scrollbars that need to be dragged

                        so my best bet is to use something like sendmessage, which is returning
                        zero. maybe there is a click happening just not at 30,30 the point i am
                        sending the cursor to.

                        regards
                        Abhishek

                        "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                        news:en4NokBsGH A.3412@TK2MSFTN GP05.phx.gbl...
                        Hi Abhishek,
                        >
                        Does SendMessage return 0 when you send WM_LBUTTONDOWN or UP?
                        >
                        Either way, I think your out of luck with this approach (see my other
                        post) but if it's non-zero that would indicate an error and you should go
                        from there.
                        >
                        --
                        Dave Sexton
                        >
                        "Abhishek" <shake@activele ment.comwrote in message
                        news:e$VVXU$rGH A.3676@TK2MSFTN GP03.phx.gbl...
                        >>I added
                        >>
                        >rt1 = SendMessage(thi s.Handle, WM_CLOSE, 0, 0);
                        >the application is closing but the click is not happening
                        >I just cant understand why
                        >>
                        >Regards
                        >Abhishek
                        >>
                        >"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                        >news:%237duRj8 rGHA.696@TK2MSF TNGP02.phx.gbl. ..
                        >>Hi Abhishek,
                        >>>
                        >>Is your 'game' by any chance tying up the UI Thread? You'd have to call
                        >>Application.D oEvents() in that case to allow the Control some time to
                        >>process your mouse notifications, however a better program architecture
                        >>would be more appropriate.
                        >>>
                        >>Actually, after reviewing your post a second time I'm not so sure I
                        >>fully understand the situation.
                        >>>
                        >>Do you have two applications running simultaneously and you are
                        >>attempting to get one application to send a mouse notification to the
                        >>other? If so, are both apps managed code?
                        >>Do you have a single, managed application with two visible Forms and you
                        >>are attempting to send a mouse notification to a control on the
                        >>unfocused Form?
                        >>>
                        >>Please clarify. I'd like to help if I can.
                        >>>
                        >>--
                        >>Dave Sexton
                        >>>
                        >>"Abhishek" <shake@activele ment.comwrote in message
                        >>news:eaQE8v7r GHA.356@TK2MSFT NGP05.phx.gbl.. .
                        >>>Hi All
                        >>>>
                        >>>Getting the handle of the contol is not the problem. if I have a game
                        >>>running then the mouse event does not function (with mouse_event). the
                        >>>sendmessag e is not working at all, the application gets focus but the
                        >>>click event is not happening.
                        >>>>
                        >>>SendMessage( axWebBrowser1.H andle, WM_LBUTTONDOWN, 0, point);
                        >>>SendMessage( axWebBrowser1.H andle, WM_LBUTTONUP, 0, point);
                        >>>>
                        >>>>
                        >>>This is the mouse_event
                        >>>mouse_event( MOUSEEVENTF_LEF TDOWN, 0, 0, 0, new System.IntPtr(0 ));
                        >>>mouse_event( MOUSEEVENTF_LEF TUP, 0, 0, 0, new System.IntPtr(0 ));
                        >>>>
                        >>>regards
                        >>>Abhishek
                        >>>>
                        >>>"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                        >>>news:Of$zhN6 rGHA.3964@TK2MS FTNGP04.phx.gbl ...
                        >>>>Hi Abhiishek,
                        >>>>>
                        >>>>Try sending WM_LBUTTONDOWN and then WM_LBUTTONUP and specify the
                        >>>>control's handle using the Control.Handle property. I doubt this will
                        >>>>work cross-process but you could try to obtain the handle to a window
                        >>>>in another application using the EnumWindows or EnumChildWindow s Win32
                        >>>>API functions.
                        >>>>>
                        >>>>private void SimulateClick(C ontrol ctrl)
                        >>>>{
                        >>>>if (ctrl == null)
                        >>>> throw new ArgumentNullExc eption("ctrl");
                        >>>>>
                        >>>>int x = 8, y = 8;
                        >>>>int point = x + (y << 16);
                        >>>>>
                        >>>>SendMessage (ctrl.Handle, WM_LBUTTONDOWN, 0, point);
                        >>>>SendMessage (ctrl.Handle, WM_LBUTTONUP, 0, point));
                        >>>>}
                        >>>>>
                        >>>>private const uint WM_LBUTTONUP = 0x0202, WM_LBUTTONDOWN = 0x0201;
                        >>>>>
                        >>>>[DllImport("user 32.dll")]
                        >>>>public static extern int SendMessage(Int Ptr hwnd, uint msg, int
                        >>>>wparam, int lparam);
                        >>>>>
                        >>>>>
                        >>>>--
                        >>>>Dave Sexton
                        >>>>>
                        >>>>"Abhishek " <shake@activele ment.comwrote in message
                        >>>>news:eY6xru zrGHA.5032@TK2M SFTNGP02.phx.gb l...
                        >>>>>Hi,
                        >>>>>>
                        >>>>> how do I pass the handle of a control to the win32 api
                        >>>>>mouse_even t. so that it will create the click event on that
                        >>>>>applicatio n only even if there is any other window in front of it. I
                        >>>>>dont what to set focus. I just want the click event to happen in that
                        >>>>>window directly.
                        >>>>>>
                        >>>>>Regards
                        >>>>>Abhishek
                        >>>>>>
                        >>>>>
                        >>>>>
                        >>>>
                        >>>>
                        >>>
                        >>>
                        >>
                        >>
                        >
                        >

                        Comment

                        • Dave Sexton

                          #13
                          Re: Handle+mouse_ev ent

                          Hi Abhishek,

                          Well you still might be able to use scripting if the Flash object model supports simulating a mouse click at a certain point. Check
                          if Flash also supports raising a mouse over event and scrolling from script while your at it.
                          so my best bet is to use something like sendmessage, which is returning zero. maybe there is a click happening just not at 30,30
                          the point i am sending the cursor to.
                          You must send the point to the SendMessage function. It doesn't matter where the cursor is actually located on the screen for
                          SendMessage with WM_LBUTTONDOWN.

                          To verify that SendMessage is working, since it is after all returning zero, why don't you replace the browser with a Button and in
                          a Click event handler show a MessageBox. Try to click the button with SendMessage. If it works then I suspect the problem is with
                          the browser and script might be your only option.

                          --
                          Dave Sexton

                          "Abhishek" <shake@activele ment.comwrote in message news:OTlV3yXsGH A.356@TK2MSFTNG P05.phx.gbl...
                          cant use the script :(
                          >
                          Since this will just create a event on a link. bit of there is flash open then? I will get the object of the flash and the click
                          will not happen on the button that is in the flash. also mouseovers and other stuff will not happen. I need to create actual in
                          game browser with all the bell and whistles there is also the issue of scrollbars that need to be dragged
                          >
                          so my best bet is to use something like sendmessage, which is returning zero. maybe there is a click happening just not at 30,30
                          the point i am sending the cursor to.
                          >
                          regards
                          Abhishek
                          >
                          "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message news:en4NokBsGH A.3412@TK2MSFTN GP05.phx.gbl...
                          >Hi Abhishek,
                          >>
                          >Does SendMessage return 0 when you send WM_LBUTTONDOWN or UP?
                          >>
                          >Either way, I think your out of luck with this approach (see my other post) but if it's non-zero that would indicate an error and
                          >you should go from there.
                          >>
                          >--
                          >Dave Sexton
                          >>
                          >"Abhishek" <shake@activele ment.comwrote in message news:e$VVXU$rGH A.3676@TK2MSFTN GP03.phx.gbl...
                          >>>I added
                          >>>
                          >>rt1 = SendMessage(thi s.Handle, WM_CLOSE, 0, 0);
                          >>the application is closing but the click is not happening
                          >>I just cant understand why
                          >>>
                          >>Regards
                          >>Abhishek
                          >>>
                          >>"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message news:%237duRj8r GHA.696@TK2MSFT NGP02.phx.gbl.. .
                          >>>Hi Abhishek,
                          >>>>
                          >>>Is your 'game' by any chance tying up the UI Thread? You'd have to call Application.DoE vents() in that case to allow the
                          >>>Control some time to process your mouse notifications, however a better program architecture would be more appropriate.
                          >>>>
                          >>>Actually, after reviewing your post a second time I'm not so sure I fully understand the situation.
                          >>>>
                          >>>Do you have two applications running simultaneously and you are attempting to get one application to send a mouse notification
                          >>>to the other? If so, are both apps managed code?
                          >>>Do you have a single, managed application with two visible Forms and you are attempting to send a mouse notification to a
                          >>>control on the unfocused Form?
                          >>>>
                          >>>Please clarify. I'd like to help if I can.
                          >>>>
                          >>>--
                          >>>Dave Sexton
                          >>>>
                          >>>"Abhishek" <shake@activele ment.comwrote in message news:eaQE8v7rGH A.356@TK2MSFTNG P05.phx.gbl...
                          >>>>Hi All
                          >>>>>
                          >>>>Getting the handle of the contol is not the problem. if I have a game running then the mouse event does not function (with
                          >>>>mouse_event ). the sendmessage is not working at all, the application gets focus but the click event is not happening.
                          >>>>>
                          >>>>SendMessage (axWebBrowser1. Handle, WM_LBUTTONDOWN, 0, point);
                          >>>>SendMessage (axWebBrowser1. Handle, WM_LBUTTONUP, 0, point);
                          >>>>>
                          >>>>>
                          >>>>This is the mouse_event
                          >>>>mouse_event (MOUSEEVENTF_LE FTDOWN, 0, 0, 0, new System.IntPtr(0 ));
                          >>>>mouse_event (MOUSEEVENTF_LE FTUP, 0, 0, 0, new System.IntPtr(0 ));
                          >>>>>
                          >>>>regards
                          >>>>Abhishek
                          >>>>>
                          >>>>"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message news:Of$zhN6rGH A.3964@TK2MSFTN GP04.phx.gbl...
                          >>>>>Hi Abhiishek,
                          >>>>>>
                          >>>>>Try sending WM_LBUTTONDOWN and then WM_LBUTTONUP and specify the control's handle using the Control.Handle property. I doubt
                          >>>>>this will work cross-process but you could try to obtain the handle to a window in another application using the EnumWindows
                          >>>>>or EnumChildWindow s Win32 API functions.
                          >>>>>>
                          >>>>>private void SimulateClick(C ontrol ctrl)
                          >>>>>{
                          >>>>>if (ctrl == null)
                          >>>>> throw new ArgumentNullExc eption("ctrl");
                          >>>>>>
                          >>>>>int x = 8, y = 8;
                          >>>>>int point = x + (y << 16);
                          >>>>>>
                          >>>>>SendMessag e(ctrl.Handle, WM_LBUTTONDOWN, 0, point);
                          >>>>>SendMessag e(ctrl.Handle, WM_LBUTTONUP, 0, point));
                          >>>>>}
                          >>>>>>
                          >>>>>private const uint WM_LBUTTONUP = 0x0202, WM_LBUTTONDOWN = 0x0201;
                          >>>>>>
                          >>>>>[DllImport("user 32.dll")]
                          >>>>>public static extern int SendMessage(Int Ptr hwnd, uint msg, int wparam, int lparam);
                          >>>>>>
                          >>>>>>
                          >>>>>--
                          >>>>>Dave Sexton
                          >>>>>>
                          >>>>>"Abhishe k" <shake@activele ment.comwrote in message news:eY6xruzrGH A.5032@TK2MSFTN GP02.phx.gbl...
                          >>>>>>Hi,
                          >>>>>>>
                          >>>>>> how do I pass the handle of a control to the win32 api mouse_event. so that it will create the click event on that
                          >>>>>>applicati on only even if there is any other window in front of it. I dont what to set focus. I just want the click event to
                          >>>>>>happen in that window directly.
                          >>>>>>>
                          >>>>>>Regards
                          >>>>>>Abhishe k
                          >>>>>>>
                          >>>>>>
                          >>>>>>
                          >>>>>
                          >>>>>
                          >>>>
                          >>>>
                          >>>
                          >>>
                          >>
                          >>
                          >
                          >

                          Comment

                          • Abhishek

                            #14
                            Re: Handle+mouse_ev ent

                            Hi Dave

                            Thanks for all the help finally got it working.
                            the issue was not with sendmessage. the issue was the since the browser was
                            a activex control the normal browsername.han dle did not work here. I had to
                            first use getwindow and GetClassName to find out the handle and then use
                            that in sendmessage.

                            but thanks a lot. it really helped.

                            regards
                            Abhishek

                            "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                            news:uVcrYlbsGH A.148@TK2MSFTNG P05.phx.gbl...
                            Hi Abhishek,
                            >
                            Well you still might be able to use scripting if the Flash object model
                            supports simulating a mouse click at a certain point. Check if Flash also
                            supports raising a mouse over event and scrolling from script while your
                            at it.
                            >
                            >so my best bet is to use something like sendmessage, which is returning
                            >zero. maybe there is a click happening just not at 30,30 the point i am
                            >sending the cursor to.
                            >
                            You must send the point to the SendMessage function. It doesn't matter
                            where the cursor is actually located on the screen for SendMessage with
                            WM_LBUTTONDOWN.
                            >
                            To verify that SendMessage is working, since it is after all returning
                            zero, why don't you replace the browser with a Button and in a Click event
                            handler show a MessageBox. Try to click the button with SendMessage. If
                            it works then I suspect the problem is with the browser and script might
                            be your only option.
                            >
                            --
                            Dave Sexton
                            >
                            "Abhishek" <shake@activele ment.comwrote in message
                            news:OTlV3yXsGH A.356@TK2MSFTNG P05.phx.gbl...
                            >cant use the script :(
                            >>
                            >Since this will just create a event on a link. bit of there is flash open
                            >then? I will get the object of the flash and the click will not happen on
                            >the button that is in the flash. also mouseovers and other stuff will
                            >not happen. I need to create actual in game browser with all the bell and
                            >whistles there is also the issue of scrollbars that need to be dragged
                            >>
                            >so my best bet is to use something like sendmessage, which is returning
                            >zero. maybe there is a click happening just not at 30,30 the point i am
                            >sending the cursor to.
                            >>
                            >regards
                            >Abhishek
                            >>
                            >"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                            >news:en4NokBsG HA.3412@TK2MSFT NGP05.phx.gbl.. .
                            >>Hi Abhishek,
                            >>>
                            >>Does SendMessage return 0 when you send WM_LBUTTONDOWN or UP?
                            >>>
                            >>Either way, I think your out of luck with this approach (see my other
                            >>post) but if it's non-zero that would indicate an error and you should
                            >>go from there.
                            >>>
                            >>--
                            >>Dave Sexton
                            >>>
                            >>"Abhishek" <shake@activele ment.comwrote in message
                            >>news:e$VVXU$r GHA.3676@TK2MSF TNGP03.phx.gbl. ..
                            >>>>I added
                            >>>>
                            >>>rt1 = SendMessage(thi s.Handle, WM_CLOSE, 0, 0);
                            >>>the application is closing but the click is not happening
                            >>>I just cant understand why
                            >>>>
                            >>>Regards
                            >>>Abhishek
                            >>>>
                            >>>"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                            >>>news:%237duR j8rGHA.696@TK2M SFTNGP02.phx.gb l...
                            >>>>Hi Abhishek,
                            >>>>>
                            >>>>Is your 'game' by any chance tying up the UI Thread? You'd have to
                            >>>>call Application.DoE vents() in that case to allow the Control some
                            >>>>time to process your mouse notifications, however a better program
                            >>>>architectur e would be more appropriate.
                            >>>>>
                            >>>>Actually, after reviewing your post a second time I'm not so sure I
                            >>>>fully understand the situation.
                            >>>>>
                            >>>>Do you have two applications running simultaneously and you are
                            >>>>attemptin g to get one application to send a mouse notification to the
                            >>>>other? If so, are both apps managed code?
                            >>>>Do you have a single, managed application with two visible Forms and
                            >>>>you are attempting to send a mouse notification to a control on the
                            >>>>unfocused Form?
                            >>>>>
                            >>>>Please clarify. I'd like to help if I can.
                            >>>>>
                            >>>>--
                            >>>>Dave Sexton
                            >>>>>
                            >>>>"Abhishek " <shake@activele ment.comwrote in message
                            >>>>news:eaQE8v 7rGHA.356@TK2MS FTNGP05.phx.gbl ...
                            >>>>>Hi All
                            >>>>>>
                            >>>>>Getting the handle of the contol is not the problem. if I have a game
                            >>>>>running then the mouse event does not function (with mouse_event).
                            >>>>>the sendmessage is not working at all, the application gets focus but
                            >>>>>the click event is not happening.
                            >>>>>>
                            >>>>>SendMessag e(axWebBrowser1 .Handle, WM_LBUTTONDOWN, 0, point);
                            >>>>>SendMessag e(axWebBrowser1 .Handle, WM_LBUTTONUP, 0, point);
                            >>>>>>
                            >>>>>>
                            >>>>>This is the mouse_event
                            >>>>>mouse_even t(MOUSEEVENTF_L EFTDOWN, 0, 0, 0, new System.IntPtr(0 ));
                            >>>>>mouse_even t(MOUSEEVENTF_L EFTUP, 0, 0, 0, new System.IntPtr(0 ));
                            >>>>>>
                            >>>>>regards
                            >>>>>Abhishek
                            >>>>>>
                            >>>>>"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                            >>>>>news:Of$zh N6rGHA.3964@TK2 MSFTNGP04.phx.g bl...
                            >>>>>>Hi Abhiishek,
                            >>>>>>>
                            >>>>>>Try sending WM_LBUTTONDOWN and then WM_LBUTTONUP and specify the
                            >>>>>>control 's handle using the Control.Handle property. I doubt this
                            >>>>>>will work cross-process but you could try to obtain the handle to a
                            >>>>>>window in another application using the EnumWindows or
                            >>>>>>EnumChild Windows Win32 API functions.
                            >>>>>>>
                            >>>>>>private void SimulateClick(C ontrol ctrl)
                            >>>>>>{
                            >>>>>>if (ctrl == null)
                            >>>>>> throw new ArgumentNullExc eption("ctrl");
                            >>>>>>>
                            >>>>>>int x = 8, y = 8;
                            >>>>>>int point = x + (y << 16);
                            >>>>>>>
                            >>>>>>SendMessa ge(ctrl.Handle, WM_LBUTTONDOWN, 0, point);
                            >>>>>>SendMessa ge(ctrl.Handle, WM_LBUTTONUP, 0, point));
                            >>>>>>}
                            >>>>>>>
                            >>>>>>private const uint WM_LBUTTONUP = 0x0202, WM_LBUTTONDOWN = 0x0201;
                            >>>>>>>
                            >>>>>>[DllImport("user 32.dll")]
                            >>>>>>public static extern int SendMessage(Int Ptr hwnd, uint msg, int
                            >>>>>>wparam, int lparam);
                            >>>>>>>
                            >>>>>>>
                            >>>>>>--
                            >>>>>>Dave Sexton
                            >>>>>>>
                            >>>>>>"Abhishek " <shake@activele ment.comwrote in message
                            >>>>>>news:eY6x ruzrGHA.5032@TK 2MSFTNGP02.phx. gbl...
                            >>>>>>>Hi,
                            >>>>>>>>
                            >>>>>>> how do I pass the handle of a control to the win32 api
                            >>>>>>>mouse_ev ent. so that it will create the click event on that
                            >>>>>>>applicat ion only even if there is any other window in front of it.
                            >>>>>>>I dont what to set focus. I just want the click event to happen in
                            >>>>>>>that window directly.
                            >>>>>>>>
                            >>>>>>>Regard s
                            >>>>>>>Abhish ek
                            >>>>>>>>
                            >>>>>>>
                            >>>>>>>
                            >>>>>>
                            >>>>>>
                            >>>>>
                            >>>>>
                            >>>>
                            >>>>
                            >>>
                            >>>
                            >>
                            >>
                            >
                            >

                            Comment

                            Working...