Jump to content
Sign in to follow this  
KillKill

LeftMouseButton click when a Pixel changes his colour. Need help to script.

Recommended Posts

KillKill

Hello. I'm new here and I have got a question. I think its very easy for YOU, but i dont know the right script commands.

The following script presses the left mouse button when the pixel right under the mouse pointer changes its colour. The whole thing only starts scanning the pixel when it was activated before with the hotkey "e".

HotKeySet("{e}", "AwpSchuss")
 
$GegnerErkannt = 0
 
while 1
 
WEnd
 
func AwpSchuss()
 
    $GegnerErkannt = 0
 
    $MousePos = MouseGetPos()
 
    $MouseColor1 = PixelGetColor($MousePos[0],$MousePos[1])
 
    While $GegnerErkannt = 0
 
        Sleep(10)
 
        $MouseColor2 = PixelGetColor($MousePos[0],$MousePos[1])
 
        if $MouseColor2 <> $MouseColor1 Then
 
            Sleep(10)
 
            MouseClick("left")
 
            $GegnerErkannt = 1
 
        EndIf
 
    WEnd
 
EndFunc

Now i won't scan only the pixel under my mousepointer. I want to scan three pixel strings around my pointer (altogether 9 pixels, the middle is the one under the mouspointer and the 8 pixels around.)

When this is NOT possible or when this option is too hard to script then i wish that i can move the scanned area 3 pixels to the right and down from the mouse point. I think about something like this:

$MousePos = MouseGetPos(3,-3)   ;The 3 and -3 stands for the displacement of the scanned pixel by 3 pixel right and down. The starting point ist the cursor.
 
                                ;THIS IS ONLY an example of what i am actually meaning, its wrong (otherwise i wouldn't ask for the right script command).

I want to specify a tolerance before the script says "there is a new pixel-colour in the scanned area" and acts.Hello. I'm new here and I have got a question. I think its very easy for YOU, but i dont know the right script commands. (I cannot open a new topic so I ask here, I hope its okay.)

The following script presses the left mouse button when the pixel right under the mouse pointer changes its colour. The whole thing only starts scanning the pixel when it was activated before with the hotkey "e".

HotKeySet("{e}", "AwpSchuss")
 
$GegnerErkannt = 0
 
while 1
 
WEnd
 
func AwpSchuss()
 
    $GegnerErkannt = 0
 
    $MousePos = MouseGetPos()
 
    $MouseColor1 = PixelGetColor($MousePos[0],$MousePos[1])
 
    While $GegnerErkannt = 0
 
        Sleep(10)
 
        $MouseColor2 = PixelGetColor($MousePos[0],$MousePos[1])
 
        if $MouseColor2 <> $MouseColor1 Then
 
            Sleep(10)
 
            MouseClick("left")
 
            $GegnerErkannt = 1
 
        EndIf
 
    WEnd
 
EndFunc

Part 1:

Now I won't scan only the pixel under my mousepointer. I want to scan three pixel-strings around my pointer (altogether 9 pixels, the middle one is the one under the mouspointer and the 8 pixels around are the other eight ones :graduated:.)

When this is NOT possible or when this option is too hard to script then i wish that i can move the scanned area 3 pixels to the right and down from the mouse point. I think about something like this:

$MousePos = MouseGetPos(3,-3)   ;The 3 and -3 stands for the displacement of the scanned pixel by 3 pixel right and down. The starting point ist the cursor.
 
                                ;THIS IS ONLY an example of what i am actually meaning, its wrong (otherwise i wouldn't ask for the right script command).

Part 2:

Also I want to specify a tolerance value before the script says "there is a new pixel-colour in the scanned area" and acts. Is that possible?

Edited by KillKill

Share this post


Link to post
Share on other sites
IntentionallyLeftBlank

It means he didn't read the FAQ. Didn't read the help documentation for PixelGetColor (Hint: Look under Related), and, in a not so subtle way, asking how to write a game bot - which in my understanding is a no-no. Other than that, I have no idea what this all means :graduated:

Share this post


Link to post
Share on other sites
KillKill

Okay I found my solution for Part 1:

(Before i started the topic, I had written it in wrong ordner, but now it works.)

PixelGetColor($MousePos[0]+3,$MousePos[1]+3)

This is my actually script:

HotKeySet("{t}", "AwpSchuss")
$GegnerErkannt = 0
while 1
WEnd
func AwpSchuss()
$GegnerErkannt = 0
$MousePos = MouseGetPos()
$MouseColor1 = PixelGetColor($MousePos[0]+3,$MousePos[1]+3)
While $GegnerErkannt = 0
  Sleep(10)
  $MouseColor2 = PixelGetColor($MousePos[0]+3,$MousePos[1]+3)
  if $MouseColor2 <> $MouseColor1 Then
   Sleep(10)
   MouseClick("left")
   $GegnerErkannt = 1
  EndIf
WEnd
EndFunc

So, now I need (Part 2) a tolerance value for the Pixel how much its colour can change before the script clicks left mouse button.

I think i must do it with Pixelsearch, but i couldnt know how to combine that with this script ... :?

PS: I have no idea why parts of my first post are written twice, sorry for that, cant change it anymore.

Edited by KillKill

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  

×