Jump to content
Sign in to follow this  
joncom

Send/Hold Keypress

Recommended Posts

Is there any possible way to make a script that will hold down the letter "G" until a particular color is detected at pixel (1,1)? I do NOT want the script to keep hitting the key multiple times. It must HOLD it down until the change is detected.

Any help would GREATLY be appreciated.

Share this post


Link to post
Share on other sites

While $Color <> "Insert decimal color value here"
   Send("{g down}")
   $Color = PixelGetColour(1,1)
Wend

or

Do
   Send("{g down}")
   $Color = PixelGetColour(1,1)
Until $Color = "Insert decimal color value here"

Doesnt holding a key down, and pressing the key multiple times, give you the same result? If not can you please give and example.


qq

Share this post


Link to post
Share on other sites

I need this for responding to what's being displayed in a game... in the game, holding down the button performs a much different action than tapping it... for example.. in some video games, if you hold the "jump" button, you will jump higher than if u just tap it.

So, what I want to accomplish here, is a script that will do something along the lines of {SHIFTDOWN} (except using the "g" key of course), and then once the pixel color change is detected at (1,1), I need the equivilent of {SHIFTUP} (for the "g" instead though).

Does this make sense? And is it possible? Or does the AutoIt language not support this?

Share this post


Link to post
Share on other sites

Yes its possible, the above won't work? I'm unsure if it will or not, test please. If it doesn't I remember a topic not long ago for someone asking for a key to be held down there entire script, I'll see if I can find it.

Edit: On further inspection, try this.

Send("{g down}")

While 1
   If PixelGetColour(1,1) = "Insert decimal color value here" Then
      Send("{g up}")
   EndIf
Wend
Edited by Burrup

qq

Share this post


Link to post
Share on other sites

Might want exitloop:

Send("{g down}")

While 1
   If PixelGetColour(1,1) = "Insert decimal color value here" Then
      Send("{g up}")

      ExitLoop

   EndIf
Wend

...but then again, you might not...


[size="1"][font="Arial"].[u].[/u][/font][/size]

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...