Jump to content

Send("{key down}") not holding keys down/interrupting key presses


Recommended Posts


I've been trying to get this working for a while, but each option that I've tried doesn't quite give me the results that I'm looking for.

I'm attempting to have a hotkey which, when pressed, will capture the keypress. It will then have function Send hold down a key (Send("{key down}")) while Mouse4 is pressed, then release the key (Send("{key up}")) when Mouse 4 is released. If Mouse4 isn't held at all, the keypress will simply be sent as normal without being held down. The problem is, the key press is required to have no interruptions between the "key down" and "key up" events.

I have adjusted Opt("SendKeyDownDelay", 1) to many different values (0-3000), as well as trying to use ControlSend in place of Send. Neither of them gave the desired effect. All attempts I've made at this were unsuccessful; there was an interruption between the "key down" and "key up" events.

Thanks for reading, and I appreciate any help in advance!

p.s. Here's an excerpt of what I have (specifically that pertains to this issue) so far:

#include <Misc.au3>
Global $hDLL = DllOpen("user32.dll")
Opt("SendKeyDownDelay", 1) ;1 millisecond

HotKeySet("q", "qhold")

Func qhold()
    If _IsPressed("05", $hDLL) Then
        Send("{q down}")
        While _IsPressed("05", $hDLL)
        Send("{q up}")
    HotKeySet("q", "qhold")

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...