How to perform a control click?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • hurricane_number_one@yahoo.com

    How to perform a control click?

    I tried this but it doesn't work

    keybd_event(VK_ CONTROL, 0, 0, 0)
    mouse_event(MOU SEEVENTF_LEFTDO WN, 0, 0, 0, 0)
    mouse_event(MOU SEEVENTF_LEFTUP , 0, 0, 0, 0)
    keybd_event(VK_ CONTROL, 0, KEYEVENTF_KEYUP , 0)

    Any idea how to do this?
  • rowe_newsgroups

    #2
    Re: How to perform a control click?

    On Nov 19, 1:27 am, "hurricane_numb er_...@yahoo.co m"
    <hurricane_numb er_...@yahoo.co mwrote:
    I tried this but it doesn't work
    >
    keybd_event(VK_ CONTROL, 0, 0, 0)
    mouse_event(MOU SEEVENTF_LEFTDO WN, 0, 0, 0, 0)
    mouse_event(MOU SEEVENTF_LEFTUP , 0, 0, 0, 0)
    keybd_event(VK_ CONTROL, 0, KEYEVENTF_KEYUP , 0)
    >
    Any idea how to do this?
    Are you trying to click one of your applications controls or something
    else?

    Thanks,

    Seth Rowe [MVP]

    Comment

    • Phill W.

      #3
      Re: How to perform a control click?

      hurricane_numbe r_one@yahoo.com wrote:
      I tried this but it doesn't work
      >
      keybd_event(VK_ CONTROL, 0, 0, 0)
      mouse_event(MOU SEEVENTF_LEFTDO WN, 0, 0, 0, 0)
      mouse_event(MOU SEEVENTF_LEFTUP , 0, 0, 0, 0)
      keybd_event(VK_ CONTROL, 0, KEYEVENTF_KEYUP , 0)
      If it's a control in your own application, use

      [<control>].PerformClick()

      It has all the same restrictions as clicking it interactively - the
      control has to be visible and enabled (as do all of its parent controls).

      If it's a /different/ application, are you running Vista?
      That puts some fairly rigid barriers between types of application,
      preventing them from doing just this sort of thing.
      Any idea how to do this?
      No, but then I'm not familiar with these particular functions.
      Take a step back; what is the end /result/ you're trying to achieve?

      HTH,
      Phill W.

      Comment

      • hurricane_number_one@yahoo.com

        #4
        Re: How to perform a control click?

        It's another program, this acts like a remote access app. I have no
        problem with the clicks, but adding any modifiers don't do anything.
        It must be possible, otherwise how would programs like VNC do it?

        On Nov 19, 8:25 am, "Phill W." <p-.-a-.-w-a-r...@-o-p-e-n-.-a-c-.-u-k>
        wrote:
        hurricane_numbe r_...@yahoo.com wrote:
        I tried this but it doesn't work
        >
        keybd_event(VK_ CONTROL, 0, 0, 0)
        mouse_event(MOU SEEVENTF_LEFTDO WN, 0, 0, 0, 0)
        mouse_event(MOU SEEVENTF_LEFTUP , 0, 0, 0, 0)
        keybd_event(VK_ CONTROL, 0, KEYEVENTF_KEYUP , 0)
        >
        If it's a control in your own application, use
        >
        [<control>].PerformClick()
        >
        It has all the same restrictions as clicking it interactively - the
        control has to be visible and enabled (as do all of its parent controls).
        >
        If it's a /different/ application, are you running Vista?
        That puts some fairly rigid barriers between types of application,
        preventing them from doing just this sort of thing.
        >
        Any idea how to do this?
        >
        No, but then I'm not familiar with these particular functions.
        Take a step back; what is the end /result/ you're trying to achieve?
        >
        HTH,
            Phill  W.

        Comment

        • kimiraikkonen

          #5
          Re: How to perform a control click?

          On Nov 19, 4:39 pm, "hurricane_numb er_...@yahoo.co m"
          <hurricane_numb er_...@yahoo.co mwrote:
          It's another program, this acts like a remote access app. I have no
          problem with the clicks, but adding any modifiers don't do anything.
          It must be possible, otherwise how would programs like VNC do it?
          >
          On Nov 19, 8:25 am, "Phill W." <p-.-a-.-w-a-r...@-o-p-e-n-.-a-c-.-u-k>
          wrote:
          >
          hurricane_numbe r_...@yahoo.com wrote:
          I tried this but it doesn't work
          >
          keybd_event(VK_ CONTROL, 0, 0, 0)
          mouse_event(MOU SEEVENTF_LEFTDO WN, 0, 0, 0, 0)
          mouse_event(MOU SEEVENTF_LEFTUP , 0, 0, 0, 0)
          keybd_event(VK_ CONTROL, 0, KEYEVENTF_KEYUP , 0)
          >
          If it's a control in your own application, use
          >
          [<control>].PerformClick()
          >
          It has all the same restrictions as clicking it interactively - the
          control has to be visible and enabled (as do all of its parent controls).
          >
          If it's a /different/ application, are you running Vista?
          That puts some fairly rigid barriers between types of application,
          preventing them from doing just this sort of thing.
          >
          Any idea how to do this?
          >
          No, but then I'm not familiar with these particular functions.
          Take a step back; what is the end /result/ you're trying to achieve?
          >
          HTH,
              Phill  W.
          Hi,
          If your VNC program accepts an action with modifier key combination
          when it's first activated (got focus), just like on normal usage, you
          can automate it using SendKeys.Send method based on that approach:

          For example, send a CTRL+UP message
          ' First activate the VNC application
          ' You can pass its process ID
          ' or its title string
          AppActivate("We lcome to VNC")

          ' Send CTRL+UP using CTRL modifier
          SendKeys.Send(" ^{UP}")

          ....where caret (^) is your modifier, in that case, control key.

          For more keys:


          Hope that approach makes some sense,

          Onur Güzel

          Comment

          • hurricane_number_one@yahoo.com

            #6
            Re: How to perform a control click?

            I can do keys with modifiers. I'm looking to do a mouse click with
            modifiers.


            On Nov 19, 11:25 am, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
            On Nov 19, 4:39 pm, "hurricane_numb er_...@yahoo.co m"
            >
            >
            >
            <hurricane_numb er_...@yahoo.co mwrote:
            It's another program, this acts like a remote access app. I have no
            problem with the clicks, but adding any modifiers don't do anything.
            It must be possible, otherwise how would programs like VNC do it?
            >
            On Nov 19, 8:25 am, "Phill W." <p-.-a-.-w-a-r...@-o-p-e-n-.-a-c-.-u-k>
            wrote:
            >
            hurricane_numbe r_...@yahoo.com wrote:
            I tried this but it doesn't work
            >
            keybd_event(VK_ CONTROL, 0, 0, 0)
            mouse_event(MOU SEEVENTF_LEFTDO WN, 0, 0, 0, 0)
            mouse_event(MOU SEEVENTF_LEFTUP , 0, 0, 0, 0)
            keybd_event(VK_ CONTROL, 0, KEYEVENTF_KEYUP , 0)
            >
            If it's a control in your own application, use
            >
            [<control>].PerformClick()
            >
            It has all the same restrictions as clicking it interactively - the
            control has to be visible and enabled (as do all of its parent controls).
            >
            If it's a /different/ application, are you running Vista?
            That puts some fairly rigid barriers between types of application,
            preventing them from doing just this sort of thing.
            >
            Any idea how to do this?
            >
            No, but then I'm not familiar with these particular functions.
            Take a step back; what is the end /result/ you're trying to achieve?
            >
            HTH,
                Phill  W.
            >
            Hi,
            If your VNC program accepts an action with modifier key combination
            when it's first activated (got focus), just like on normal usage, you
            can automate it using SendKeys.Send method based on that approach:
            >
            For example, send a CTRL+UP message
            ' First activate the VNC application
            ' You can pass its process ID
            ' or its title string
            AppActivate("We lcome to VNC")
            >
            ' Send CTRL+UP using CTRL modifier
            SendKeys.Send(" ^{UP}")
            >
            ...where caret (^) is your modifier, in that case, control key.
            >
            For more keys:http://msdn.microsoft.com/en-us/libr...83(VS.85).aspx
            >
            Hope that approach makes some sense,
            >
            Onur Güzel

            Comment

            • Andrew Morton

              #7
              Re: How to perform a control click?

              hurricane_numbe r_one@yahoo.com wrote:
              Turns out, my code actually does work, just not in Firefox, which is
              the program I was testing it with and the one I was hopefully aiming
              to get this working for. I tried this in other browsers and it works
              fine. I also tried your suggestion, and it performs a doubleclick but
              doesn't do anything different than before. Any idea why this wouldn't
              work in Firefox only?
              It could be that FF thinks something else is in focus (like a blank area).
              What if you manually click on the element in question before running your
              code?

              Andrew


              Comment

              Working...