morpheuz Posted October 28, 2021 Share Posted October 28, 2021 If he sees an image 500 times, I want him to take action, but once he sees it, he immediately starts to perform the actions, this is the code #include <ImageSearch2015.au3> $returnC = 0 $returnV = 0 Do $picture = _ImageSearchArea("picture.png",1, 0, 0, 1920, 1080, $returnC, $returnV, 0, 5) If $picture <> 500 Then Sleep(500) Until $picture = 500 ToolTip(".... picture search") Is there a way or an example on how to do it? Link to comment Share on other sites More sharing options...
Musashi Posted October 28, 2021 Share Posted October 28, 2021 I don't use ImageSearch2015.au3, but according to the description in the function header, ; Syntax: _ImageSearchArea, _ImageSearch ; Parameter(s): ... ; Return Value(s): On Success - Returns True ; On Failure - Returns False _ImageSearchArea returns True(=1) on success, and False(=0) on failure. Do $picture = _ImageSearchArea("picture.png",1, 0, 0, 1920, 1080, $returnC, $returnV, 0, 5) If $picture <> 500 Then Sleep(500) Until $picture = 500 This means that your $picture variable gets either the value 0 or 1, the value 500 is never reached, and the loop runs endlessly. You need a counter, e.g. #include <ImageSearch2015.au3> $returnC = 0 $returnV = 0 Local SiCounter = 0, $bFound = False Do $bFound = _ImageSearchArea("picture.png",1, 0, 0, 1920, 1080, $returnC, $returnV, 0, 5) If $bFound Then SiCounter += 1 Sleep(500) Else ExitLoop EndIf Until SiCounter = 500 ToolTip(".... picture search") (untested and possibly wrong ) "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 comment Share on other sites More sharing options...
JockoDundee Posted October 29, 2021 Share Posted October 29, 2021 @Musashi, why the ExitLoop statement? Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
Musashi Posted October 29, 2021 Share Posted October 29, 2021 23 minutes ago, JockoDundee said: @Musashi, why the ExitLoop statement? I was almost on my way to bed and pretty tired when I read the question (last forum check before shutting down the PC) . Frankly, I'm not even sure I interpreted the OP's question ("If he sees an image 500 times, I want him to take action...") correctly. At the moment it checks, if the requested image was found. If yes, the counter is incremented and a 500ms delay is applied (until the counter equals 500). If another image appears before reaching the 500 iterations (_ImageSearchArea = False), then the loop will be interrupted (ExitLoop). Possibly complete nonsense "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 comment Share on other sites More sharing options...
JockoDundee Posted October 29, 2021 Share Posted October 29, 2021 1 hour ago, Musashi said: If another image appears before reaching the 500 iterations (_ImageSearchArea = False), then the loop will be interrupted (ExitLoop) Right, but in both cases “he takes action”, assuming that the action is the ToolTip statement. Some people call a ship “she”, but these days it might get flagged as misogynistic. Calling a script “he” is a refreshing change, although some of the natural constructs might be awkward: He crashed. He bombed. I executed him. Musashi 1 Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
Musashi Posted October 29, 2021 Share Posted October 29, 2021 11 minutes ago, JockoDundee said: ... but in both cases “he takes action”, assuming that the action is the ToolTip statement. You are right about that. I mainly wanted to point out to the OP, that his loop would run infinitely. He should be able to do the fine-tuning himself . Do [...] Until SiCounter = 500 If $bFound Then ToolTip(".... picture search") 11 minutes ago, JockoDundee said: He crashed. He bombed. I executed him. ... or the traditional statement from ancient computer times : FUBAR -> "He" Fucked Up Beyond All Repair JockoDundee 1 "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 comment Share on other sites More sharing options...
morpheuz Posted October 29, 2021 Author Share Posted October 29, 2021 4 hours ago, JockoDundee said: Right, but in both cases “he takes action”, assuming that the action is the ToolTip statement. Some people call a ship “she”, but these days it might get flagged as misogynistic. Calling a script “he” is a refreshing change, although some of the natural constructs might be awkward: He crashed. He bombed. I executed him. actually i mean "that" I don't even know if this is true, when I translate it into our own language, it's exactly what I mean, but in English there are sentences like she , he, that are used. Anyway, I want you to know that I didn't do it on purpose, I will check the code at a convenient time and mark it as a solution if it works. 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