Jump to content

Send key as long as a button is pressed physically


Recommended Posts

I want to do a script that works like this:

As long as I'm holding down my C button on my keyboard, I want the SPACE button to be held down too.

When I later release the C button on my keyboard, I want the SPACE button to be released too.

How can I do a script like this?

Link to comment
Share on other sites

  • Moderators

Just curious, what are you trying to accomplish? There has to be a much easier way of accomplishing what you're after than spamming the Send function.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

The problem, as I see it, is that the keys you want to use can only be sent separately - one at a time. It isn't like holding down the control, or alt key to combine with another key. If I am correct, then remapping may be the only solution. I haven't tested it and I could be wrong. You could try setting 'c' as a hotkey to call a function. It might work with some tweaks. It seems a strange thing to do though.

Edited by czardas
Link to comment
Share on other sites

I can't remember the function that disables the keyboard and mouse intput, but you can probably use that, with a _IsPressed loop to do what you require...(then just send "C " in a loop)...I'd add a timer limit to it, to make sure you can become responsive again, while testing.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

thi

I can't remember the function that disables the keyboard and mouse intput, but you can probably use that, with a _IsPressed loop to do what you require...(then just send "C " in a loop)...I'd add a timer limit to it, to make sure you can become responsive again, while testing.

Hmmm, I'll test that out.

Link to comment
Share on other sites

Okay I was wrong.

;

#include <Misc.au3>

HotKeySet("c", "space")
HotKeySet("{ESC}", "quit")

Global $dll = DllOpen("user32.dll")

While 1
    Sleep(10)
WEnd

Func space()
    While _IsPressed("43")
        Send("{SPACE}")
    WEnd
EndFunc

Func quit()
    DllClose($dll)
    Exit
EndFunc

;

If you want to make it less sensitive, add a sleep value to the function - after Send().

Edited by czardas
Link to comment
Share on other sites

Okay I was wrong.

;

#include <Misc.au3>

HotKeySet("c", "space")
HotKeySet("{ESC}", "quit")

Global $dll = DllOpen("user32.dll")

While 1
    Sleep(10)
WEnd

Func space()
    While _IsPressed("43")
        Send("{SPACE}")
    WEnd
EndFunc

Func quit()
    DllClose($dll)
    Exit
EndFunc

;

If you want to make it less sensitive, add a sleep value to the function - after Send().

 

Thanks =).

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
 Share

  • Recently Browsing   0 members

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