Jump to content
xProgrammer89x

holding and releasing a key or mouse if color exist

Recommended Posts

Hi all, I'm learning to use scar divi, that looks like Pascal language, and I had a problem during a little script developing.

 

I need to write a procedure that hold spacebar, or left click of mouse, until a color in X;Y coords, be orange.

 

A better explaination, I have a blank progress bar, that can be green, orange, and red when I hold spacebar, and I need a script that keep the spacebar orange (medium status) holding and releasing spacebar, when X;Y coords are orange, and blank.

 

Here is a photo of full progress bar.

 

gradient.png

 

Can someone help me?

 

Thanks in advance!

Link to comment
Share on other sites

I would use GetColor for this example, but generally a tolerance is a lot easier to please rather than compare the value to a specific color, requiring 100% accuracy.

 

Here's a possibility, this is just checking for 1 color at a position, holding down space until it's found. Another color could easily be added.

 

program Test;

var

xCheck, yCheck, xOut, yOut: Integer;

col1: Integer;

begin

xCheck := 10; yCheck := 10;

col1 := 6908408;

 

KeyDown(VK_SPACE);

repeat

Wait(1);

until (FindColorTol(xOut, yOut, col1, xCheck, yCheck, xCheck, yCheck, 5));

KeyUp(VK_SPACE);

end.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...