Sign in to follow this  
Followers 0
spuuunit

Send key as long as a button is pressed physically

9 posts in this topic

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?

Share this post


Link to post
Share on other sites



I'm not sure if this is possible. You can remap the keyboard, so C becomes space. I don't know how to code for that, but there are keyboard remapping programs available.

Share this post


Link to post
Share on other sites

Well, then you have to restart your whole computer for that to work...

Share this post


Link to post
Share on other sites

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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

Share this post


Link to post
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 =).

Share this post


Link to post
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
Sign in to follow this  
Followers 0