Jump to content

Make MouseClick click only once


Recommended Posts

Posted (edited)

I'm trying to make it click only once but it just keeps clicking, I'm new and I used examples to come up with this code but idk what is wrong

$left = 353
$bottom = 972
$right = 513
$top = 855
$color = 0xDD2E44

Global $Paused, $Runner
HotKeySet("{f7}", "TogglePause")
HotKeySet("{f8}", "Terminate")

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(10)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Sleep(2500)

while(true)
    $pix = PixelSearch($right, $bottom, $left, $top, $color)
    if Not @error Then
        MouseClick("left", $pix[0], $pix[1], 1, 0)
    EndIf
WEnd

 

Edited by Jos
added codebox
Link to post
Share on other sites
  • Developers
43 minutes ago, Sakkz said:

it click only once but it just keeps clicking,

Right ..  don't you think this has something to do with the While...Wend loop you have put in your script?
 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

 

41 minutes ago, Sakkz said:

I'm trying to make it click only once but it just keeps clicking

Then you should not run PixelSearch in a loop. Furthermore, the order of the parameters when calling Pixelsearch is wrong (take a look at the help).

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to post
Share on other sites

@Musashi

The order provided within PixelSearch can be mixed :

Quote

The search direction varies as follows:
    Left-to-Right - left < right
    Right-to-Left - right < left
    Top-to-Bottom - top < bottom
    Bottom-to-Top - bottom < top
 

;)

Link to post
Share on other sites
2 hours ago, Nine said:

The order provided within PixelSearch can be mixed :

I am aware of that, but you are right - "wrong order of parameters" is not a correct statement. ;).

According to the help, Param1 is the left coordinate and Param3 the right one. The search direction can be reversed, if one sets the value of Param1(left) greater than the value of Param3(right). (Analog for Param2(top) and Param4(bottom)).

I just wanted to make sure, @Sakkz got this point right.

In the end, it's probably just a matter of personal preference whether you set :

$left = 353, $bottom = 972, $right = 513, $top = 855, $color = 0xDD2E44
$pix = PixelSearch($right, $bottom, $left, $top, $color)

or :

$left = 513, $top = 972, $right = 353, $bottom = 855, $color = 0xDD2E44
$pix = PixelSearch($left, $top, $right, $bottom, $color)

which fits at least better to the help, regarding the naming of the variables.

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to post
Share on other sites

To explain what exactly I'm trying to do. In a discord group I'm in, the owner does these random giveaways which you have to react within like 5 seconds. (The winner gets their idea used for the owner to use as a rp character) and so I just want it to loop PixelSearch till it finds it and only clicks it once instead of it acting like an autoclicker. But if this sorta thing isn't allowed then I apologize

Link to post
Share on other sites
  • Developers
2 minutes ago, Sakkz said:

But if this sorta thing isn't allowed then I apologize

That is something you can determine yourself by taking the time to read or forum rules ! ;) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...