Sign in to follow this  
Followers 0
EvAsion

[Request] Click On Change

6 posts in this topic

Hi, I was hoping someone could give me some guidance in creating a script. What i would like it to do is:

while holding a key (doesn't matter which) eg. F

the script will begin scanning a small area for any change in pixel colour (preferably it will ignore extremely minute changes).

If it notices a change, it will simulate left clicking of the mouse as fast as possible.

As soon as it does this, the script pauses.

Also releasing F even if it hasn't left clicked will pause the script.

If anyone can give me any pointers, that would be highly appreciated!

thanks in advance.

Share this post


Link to post
Share on other sites



sorry for double post but edit button dissapeared. I have a base code that i'm working off but the problem is that i'm using the "Pixelsearch" function which detects a colour then left clicks. Is there a function which detects a "change" in colour, not just detects a colour then left clicks. Or is there someway i can take a snapshot of a small area, then just compare it constantly to my current screen and to left click if theres any change. I'm stuck for ideas here.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

as i said, this is a base. I don't need all the shadowmdls,brightmdls, counter and terrorism things.

just so you know after this post I won't be back for a few hours.

#include <Misc.au3>
#include <array.au3>
Global $on = 0;On/Off Variable
Global $coords;Coords needed to click
Hotkeyset("{F1}", "_power");On/Off Key
HotKeySet("{LEFT}", "Terrorist")
HotKeySet("{RIGHT}", "CounterT")
Global $colorswitch = 0
$shadowMDLS = "0x080A32"; when script first starts CTS are the target
$BrightMDLS = "0x0000FE"

While 1;Start Loop
    Sleep(100);Pause
    If $on = 1 Then
    If $colorswitch = 0 Then
        $colorswitch = 1
        $coords = PixelSearch(60, 40, 600, 430, $shadowMDLS, 100, 3);Search for cts in shadows
    If IsArray($coords) Then;Check if we found any
        MouseClick("left");SHOOT!
        $colorswitch = 0
    EndIf
EndIf
EndIf
        Sleep(100);Pause
        If $colorswitch = 1 Then
    If $on = 1 Then;Only search if its on.
        $colorswitch = 0
    $coords = PixelSearch(60, 40, 600, 430, $BrightMDLS, 100, 3);Search for cts
    If IsArray($coords) Then;Check if we found any
        MouseClick("Left");SHOOT!
        $colorswitch = 1
    EndIf
EndIf
EndIf
Wend

Func _power();On/Off Function
If $on = 1 Then
    $on = 0
Else
    $on = 1
EndIf
EndFunc

Func Terrorist()
    $BrightMDLS = "0xBB0000"; T
    $shadowMDLS = "0xFE0000"
EndFunc

Func CounterT()
    $shadowMDLS = "0x080A32"; CTS
    $BrightMDLS = "0x0000FE"
EndFunc
Edited by EvAsion

Share this post


Link to post
Share on other sites

well. I changed my code to this but i can't figure out why its not working.

#include <Misc.au3>
#include <array.au3>
HotKeySet("{F}","Check")
HotKeySet("{F1}","Stop")

While 1
 Sleep(100)
Wend


Func Check()
    $checking = 1
    while $checking = 1
        $checksum = PixelChecksum(319,239,321,241)
        While $checksum = PixelChecksum(319,239,321,241)
            Sleep(100)
        WEnd
        MouseClick("left");SHOOT!
    WEnd
EndFunc

Func Stop()
    $checking = 0
EndFunc

Share this post


Link to post
Share on other sites

well, its finally working, exactly as i want. But I was wondering if it possible to make it lock my mouse movement as soon as i press f1, as well as doing what it is already doing. Then when i let go of f1 I want it to unlock mouse movement and to stop the script without left clicking. It it possible?

Here is my code so far.

#include <Misc.au3>
#include <array.au3>
HotKeySet("{F1}","Check")
HotKeySet("{F2}","Stop")
Dim $checksum
Dim $checking
While 1
 Sleep(100)
Wend


Func Check()
    $checking = 1
    while $checking = 1
        $checksum = PixelChecksum(319,239,321,241)
        While $checksum = PixelChecksum(319,239,321,241)
            Sleep(10)
        WEnd
        MouseClick("left");SHOOT!
        $checking = 0
    WEnd
EndFunc

Func Stop()
    $checking = 0
EndFunc

Share this post


Link to post
Share on other sites

I updated my code even further to this:

HotKeySet("f","Check")
HotKeySet("v","Stop")
HotKeySet("^!d","Terminate") 
Dim $checksum
Dim $checking
Dim $shoot
While 1
 Sleep(100)
Wend


Func Check()
    HotKeySet("f")
    send("f")
    HotKeySet("f","Check")
    $shoot = "left"
    $checking = 1
        while $checking = 1
        $checksum = PixelChecksum(319,239,321,241)
        While $checksum = PixelChecksum(319,239,321,241)
            Sleep(4)
        WEnd
        MouseClick($shoot);SHOOT!
        $shoot = 0
        $checking = 0
    WEnd
EndFunc

Func Stop()
    HotKeySet("v")
    send("v")
    HotKeySet("v","stop")
    $shoot = 0
    $checking = 0
EndFunc

Func Terminate()
    Exit 0
EndFunc

but i'm still wondering if it possible to make it lock my mouse movement as soon as i press f, as well as doing what it is already doing. Then when i let go of f I want it to unlock mouse movement and to stop the script without left clicking. Can anyone give me any tips on doing this?

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