SendKeys to hold down keys

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

    SendKeys to hold down keys

    I am trying have an application hold down the Shift key (+) and the Alt key
    (%) simultaneously for a given period of time, or until a condition is met.

    I tried this but it doesn't work: SendKeys.Send(" %(+)")

    neither does this:

    SendKeys.Send(" %")

    SendKeys.Send(" +")


  • John Timney \(MVP\)

    #2
    Re: SendKeys to hold down keys

    try "+(%+)"

    Cant remember the exact syntax, but I recall you preceed a combination key
    press with a +
    --
    Regards

    John Timney (MVP)


    "Daniel N." <deeznuts247@ex cite.com> wrote in message
    news:Nriig.71$u k5.52@fe12.lga. ..[color=blue]
    >I am trying have an application hold down the Shift key (+) and the Alt key
    > (%) simultaneously for a given period of time, or until a condition is
    > met.
    >
    > I tried this but it doesn't work: SendKeys.Send(" %(+)")
    >
    > neither does this:
    >
    > SendKeys.Send(" %")
    >
    > SendKeys.Send(" +")
    >
    >[/color]


    Comment

    • Daniel N.

      #3
      Re: SendKeys to hold down keys

      '+(%+)' is not a valid SendKeys String is the error it gives me, but I will
      try diffrent things, thanks


      "John Timney (MVP)" <x_john@timney. eclipse.co.uk> wrote in message
      news:s_2dnXScmY LxdxTZRVny2w@ec lipse.net.uk...[color=blue]
      > try "+(%+)"
      >
      > Cant remember the exact syntax, but I recall you preceed a combination key
      > press with a +
      > --
      > Regards
      >
      > John Timney (MVP)
      >
      >
      > "Daniel N." <deeznuts247@ex cite.com> wrote in message
      > news:Nriig.71$u k5.52@fe12.lga. ..[color=green]
      > >I am trying have an application hold down the Shift key (+) and the Alt[/color][/color]
      key[color=blue][color=green]
      > > (%) simultaneously for a given period of time, or until a condition is
      > > met.
      > >
      > > I tried this but it doesn't work: SendKeys.Send(" %(+)")
      > >
      > > neither does this:
      > >
      > > SendKeys.Send(" %")
      > >
      > > SendKeys.Send(" +")
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Daniel N.

        #4
        Re: SendKeys to hold down keys

        I was up late, and finally found that:
        SendKeys.Send(" (+%) + (+)") did the trick, however, what I needed to do was
        to do was to HOLD DOWN the alt and shift while something else was happening,
        such as:

        1) Hold down ALT + SHIFT
        2)Move Mouse
        3)Release ALT + SHIFT

        Do you know how I might be able to do it?


        Comment

        • John Timney \(MVP\)

          #5
          Re: SendKeys to hold down keys

          Glad you got something working anyway. I knew I was on the right track.

          Perhaps think about running two threads - one that sends the keys and waits
          for the mouse move to end, triggering the thread to complete. Your probably
          heading into the realm of windows hooks if you are looking to control
          keyboard and mouse vents, notifications etc. Theres some good reading about
          that would help you:

          Microsoft Support is here to help you with Microsoft products. Find how-to articles, videos, and training for Microsoft Copilot, Microsoft 365, Windows 11, Surface, and more.


          --
          Regards

          John Timney (MVP)


          "Daniel N." <deeznuts247@ex cite.com> wrote in message
          news:j7sig.287$ uk5.210@fe12.lg a...[color=blue]
          >I was up late, and finally found that:
          > SendKeys.Send(" (+%) + (+)") did the trick, however, what I needed to do
          > was
          > to do was to HOLD DOWN the alt and shift while something else was
          > happening,
          > such as:
          >
          > 1) Hold down ALT + SHIFT
          > 2)Move Mouse
          > 3)Release ALT + SHIFT
          >
          > Do you know how I might be able to do it?
          >
          >[/color]


          Comment

          • Mini-Tools Timm

            #6
            Re: SendKeys to hold down keys

            "Daniel N." wrote:
            [color=blue]
            > I was up late, and finally found that:
            > SendKeys.Send(" (+%) + (+)") did the trick, however, what I needed to do was
            > to do was to HOLD DOWN the alt and shift while something else was happening,
            > such as:
            >
            > 1) Hold down ALT + SHIFT
            > 2)Move Mouse
            > 3)Release ALT + SHIFT
            >
            > Do you know how I might be able to do it?[/color]

            Hi Daniel,

            In our experience, SendKeys is not the best function for sending keyboard
            input, especially when it involves holding down a modifier key. The User32
            function SendInput and the deprecated keybd_event work much better.

            We offer a .NET component FREE for non-commercial use that will do the trick
            for you:



            --
            Timm Martin
            Mini-Tools
            ..NET Components and Windows Software
            Find your domain name at HugeDomains. Start using this domain right away.


            Comment

            Working...