Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

VariemClick() find'nClick image's multiple times in flash games


  • Please log in to reply
1 reply to this topic
Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012
Variem from the Latin word varius (“manifold, diverse, various, party-colored, variegated, also changing, changeable, etc.”)

Version: 1.0
Only tested by me with AHK L
Download it here

What is it?

Its a function i made to click multiple done buildings in a flash game on Facebook
why? Because i can't access my works web basede program interface from home
In the beginning, the image variation i used, that found the image in the flash game,
only worked one time and not the next time or on the next done building,
so i tried to just up the variation, only to have it not find the frist building,
I needed some way to frist use a low variation and then a little higher and so on,
but if it got to high it just found anything, so in with a max variation... etc. grin.png

What does it do?

It usage Ahk's imagesearch to find and Click multiple instances of a single image on screen
and if no image is found it increases the allowed variation for the next search
until 'NumberOfTries' is used up.

The function also returns a string with ether an error message
or a list (in message form) of X,Y coords clicked and the variation used.

How to use the parameters for this function:

VariemClick(ImageFile [, NumberOfTries, Start_Vari, Max_Vari, Click_X_Offset, Click_Y_Offset, WaitBetweenClicks])

*Required parameters:

- ImageFile << - >> The full file path must be enclosed in "" double quotes for ImageSearch to work

Optional parameters:

- NumberOfTries << - >> Number Of times to find `n click or increse the variation (default is 10)
- Start_Vari << - >> Allowed shades of variation to start with (default is 0)
- Max_Vari << - >> Maximum shades of variation to be used (default is 80)
- Click_X_Offset << - >> Offset from the X coordinate to use (default is 0)
- Click_Y_Offset << - >> Offset from the Y coordinate to use (default is 0)
- WaitBetweenClicks << - >> Time to Wait Between Clicks (default is 1/10 of a second)

Examples:
A simple way to use it is with a hotkey and a msgbox like this


+w::
Msgbox % VariemClick("C:\Users\Pictures\Blue2.bmp") ; use the default settings
Return

esc::Pause

<<VariemClick Function code here>>
Or like this in a script
IfWinExist, Some win title here
{
WinActivate
WinMaximize
Sleep, 1000
Clicks := VariemClick("C:\Users\Pictures\Blue2.bmp", 40,,, 5, 60, 500) ; 40 Tries,,, 5 X_offset, 60 Y_offset, wait 500ms Between Clicks
Msgbox, %Clicks%
Return
}
<<VariemClick Function code here>>
You can also Download it here and then use it like this!?
#Include VariemClick.ahk

{ some script text bla bla }

Tooltip % VariemClick("C:\Users\Pictures\Blue2.bmp",,,,,, 2000) ;Wait 2000ms Between Clicks
Sleep 5000
Tooltip

{ bla bla some more script here }
Function:
https://gist.github.com/98ef9747b49f9377ce19

Please let me know if you have or find a way to help me refine it!

Hope Some of you can use it... happy.png
Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About

JohnnyA
  • Members
  • 7 posts
  • Last active: Jun 01 2015 04:29 AM
  • Joined: 12 May 2015

This was awesome, and 100% what I needed!!!  There are so many example scripts that I have run into that simply do NOT work, so it was good to see this one working and also solving a problem I was running into.

:)