Polistotele Posted December 8, 2019 Share Posted December 8, 2019 Hello guys 😃 so basically from the other post even with the explanation of some fantastic users I couldn't understand somethings this is the code: expandcollapse popup#include <AutoItConstants.au3> #include "ImageSearch_64_bit/Imagesearch.au3" #include <Misc.au3> HotKeySet("{f1}", "myExit") #AutoIt3Wrapper_UseX64=y Global $x=0 Global $y=0 Global $Counter = 1 init(); changed all that to a function to call one time( readability) while 1 $timer = timerinit() Do MouseClick("Left", 779, 600, 1, 2) ; Red sleep(500) MouseClick("Left", 896, 685, 1, 2) Call ( "myResult", $Counter ) sleep(2000) MouseClick("Left", 607, 361, 1, 2) ;Blue sleep(500) MouseClick("Left", 896, 685, 1, 2) Call ( "myResult", $Counter ) sleep(2000) MouseClick("Left", 779, 600, 1, 2) ;Red sleep(500) MouseClick("Left", 896, 685, 1, 2) Call ( "myResult", $Counter ) sleep(2000) MouseClick("Left", 779, 600, 1, 2) ;Red sleep(500) MouseClick("Left", 896, 685, 1, 2) Call ( "myResult", $Counter ) sleep(2000) MouseClick("Left", 607, 361, 1, 2) ;Blue sleep(500) MouseClick("Left", 896, 685, 1, 2) Call ( "myResult", $Counter ) sleep(2000) MouseClick("Left", 607, 361, 1, 2) ;Blue sleep(500) MouseClick("Left", 896, 685, 1, 2) Call ( "myResult", $Counter ) Sleep(2000) until timerdiff($timer) > 960; WEnd Global $sImage[1+5] = ["", "primo.bmp", "secondo.bmp", "terzo.bmp", "quarto.bmp", "quinto.bmp"] Func myResult($Counter) For $i = 4 to 5 ; quarto.bmp & quinto.bmp $Variable = _ImageSearch($sImage[$i], 0, $x, $y, 0) ; returns 0 or 1 If $Variable = 1 Then ExitLoop ; found => exit the For loop Next If $Variable = 1 Then ; image found MouseClick("Left", 1110, 684, 1, 1) MouseClick($MOUSE_CLICK_LEFT, $Variable[0], $Variable[1], $Counter) RETURN ; then return to main program EndIf For $i = 1 to 3 ; primo.bmp & secondo.bmp & terzo.bmp $Variable = _ImageSearch($sImage[$i], 0, $x, $y, 0) ; returns 0 or 1 If $Variable = 1 Then ExitLoop ; found => exit the For loop Next If $Variable = 1 Then ; image found For $vElement In $Variable $Counter = $Counter * 2 Next MouseClick($MOUSE_CLICK_LEFT, $Variable[0], $Variable[1], $Counter) EndIf EndFunc Func init() WinActivate("Identikit") WinWaitActive("Identikit", "", 10); wait for 10 sec to appear MouseClick("Left", 746, 666, 1, 1) sleep(4000) MouseWheel($MOUSE_WHEEL_DOWN, 7) sleep(500) MouseClick("Left", 653, 780, 1, 1) sleep(2000) MouseClick("Left", 1010, 712, 1, 1) sleep(16000) MouseWheel($MOUSE_WHEEL_DOWN, 1) sleep(1000) EndFunc func myExit() Exit EndFunc I'm having issues on my function, as some users of this forum said it is because $Variable will never be an Array (it will only be 0 or 1), so you cannot test $Variable[...] which will give an error because it is the syntax for Array. So I already know the function is not gonna work because of these two: MouseClick($MOUSE_CLICK_LEFT, $Variable[0], $Variable[1], $Counter) For $vElement In $Variable $Counter = $Counter * 2 Next MouseClick($MOUSE_CLICK_LEFT, $Variable[0], $Variable[1], $Counter) so basically you can see in my full script that there's a sequence of MouseClick and everytime the function myResult is called. so basically what I want to do is: -if the script find quarto.bmp & quinto.bmp the number of clicks in MouseClick($MOUSE_CLICK_LEFT, $Variable[0], $Variable[1], $Counter) stay at 1 based on the counter -if the script find primo.bmp & secondo.bmp & terzo.bmp the number of clicks must be multiplied by his double: so the script find one time is gonna be 2 clicks, if the script find 2 times in a row is gonna be 4 then 8, 16, 32 etc etc. My question is: could you guys reference me to some kind of information that can help me solve this thing? I'm really sorry to repeat the same question but I'm kinda new in AutoIT 😢 P.S: I wrote the intention of this script in the other topic, I'm no trynna do nothing that can result harmful Thank you everyone for your attention! Link to comment Share on other sites More sharing options...
junkew Posted December 10, 2019 Share Posted December 10, 2019 (edited) See usage description in the help file. Imagesearch when returning 1 it will also put values in $x and $y. Although you are a starter still you need to read carefully input and output variables in documentation. Do not reference to other topics just add the link to it so we can understand what topic you refer to. Edited December 10, 2019 by junkew FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now