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.
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...