Teckx Posted January 28, 2021 Share Posted January 28, 2021 Hello . It's been quite some time since i've used AutoIt and im banging my head on the wall trying to figure this out. I have two images that will appear in a specific area on my screen (ImageSearchArea) However they will not appear at the same time. I am trying to have my script look for the first and if it isnt there it looks for the next, if thats not there the script repeats. I'm really unsure on how to implement the arrays into the ImageSearchArea functionality. take a look at what i've come up with please. #include <ImageSearch2015.au3> $x1 = 1690 $y1 = 113 $x2 = 1752 $y2 = 735 $returnX = 0 $returnY = 0 $picture = "UpDoot.png" $result = _ImageSearchArea($picture, 1, $x1, $y1, $x2, $y2, $returnX, $returnY, 100, 0) if $result = 1 Then ;MouseMove ($returnX, $returnY, 10) Tooltip("UpDoot Found") SLeep(1000) Else Tooltip("Error!") SLeep(1000) EndIf Link to comment Share on other sites More sharing options...
Nine Posted January 28, 2021 Share Posted January 28, 2021 Here the basic of a loop : Local $result, $returnX, $returnY While True Sleep (500) $result = _ImageSearchArea($picture, 1, 1690, 113, 1752, 735, $returnX, $returnY, 100, 0) If $result = 1 Then ConsoleWrite ("first found" & @CRLF) ; do your stuff here ContinueLoop EndIf $result = _ImageSearchArea($picture, 1, 200, 300, 400, 500, $returnX, $returnY, 100, 0) If $result = 1 Then ConsoleWrite ("second found" & @CRLF) ; do your stuff here EndIf WEnd “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Teckx Posted January 28, 2021 Author Share Posted January 28, 2021 14 minutes ago, Nine said: Here the basic of a loop : Local $result, $returnX, $returnY While True Sleep (500) $result = _ImageSearchArea($picture, 1, 1690, 113, 1752, 735, $returnX, $returnY, 100, 0) If $result = 1 Then ConsoleWrite ("first found" & @CRLF) ; do your stuff here ContinueLoop EndIf $result = _ImageSearchArea($picture, 1, 200, 300, 400, 500, $returnX, $returnY, 100, 0) If $result = 1 Then ConsoleWrite ("second found" & @CRLF) ; do your stuff here EndIf WEnd Hey. works perfectly. THank you Link to comment Share on other sites More sharing options...
Teckx Posted January 29, 2021 Author Share Posted January 29, 2021 is it possible to have a variable add +1 when image search is found THen when 2nd image is found it takes that variable and performs an operation X amount of times? Then resetting the variable back to 0 Link to comment Share on other sites More sharing options...
Nine Posted January 29, 2021 Share Posted January 29, 2021 Yes everything is possible... But I am curious to know what is the application you are trying to automate ? What is the operation you want to perform X amount of times ? There are better ways to automate application than using ImageSearch. So could you help me understand what you are trying to achieve first ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Teckx Posted January 29, 2021 Author Share Posted January 29, 2021 6 minutes ago, Nine said: Yes everything is possible... But I am curious to know what is the application you are trying to automate ? What is the operation you want to perform X amount of times ? There are better ways to automate application than using ImageSearch. So could you help me understand what you are trying to achieve first ? sure. THanks for the help so far. so I am playing with paper money in think or swim and trying to have it watch a trend i wrote where it indicates buy or sell. im having it check every 10 seconds for an indicator. sometimes it will buy more than it sells which isnt locking in my fake profits ! so i figured if i could keep a variable count every time the buy indicator hits - when that sell indicator pops up it will sell times X to bring my shares down to 0 Link to comment Share on other sites More sharing options...
Nine Posted January 29, 2021 Share Posted January 29, 2021 Could you show me a screenshot of this application, it would help me figuring out the flow of your automation. Thanks. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Teckx Posted January 29, 2021 Author Share Posted January 29, 2021 6 minutes ago, Nine said: Could you show me a screenshot of this application, it would help me figuring out the flow of your automation. Thanks. The red and green arrows is what the imagesearch is looking for Link to comment Share on other sites More sharing options...
Nine Posted January 29, 2021 Share Posted January 29, 2021 Isn't that some sort of a game ? Looks very much like it I must say. Right ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Teckx Posted January 29, 2021 Author Share Posted January 29, 2021 (edited) 5 minutes ago, Nine said: Isn't that some sort of a game ? Looks very much like it I must say. Right ? no its called think or swim. definitely not a game. it measures volume in a stock. im doing the paper money version for testing. modding games is not supported here i believe? so i definitely would not be trying to break the rules. Edited January 29, 2021 by Teckx Link to comment Share on other sites More sharing options...
Nine Posted January 29, 2021 Share Posted January 29, 2021 Ok. I went to TDAmeritrade, look like your screen shot. So, lets go back to your request. 1 hour ago, Teckx said: is it possible to have a variable add +1 when image search is found THen when 2nd image is found it takes that variable and performs an operation X amount of times? Then resetting the variable back to 0 You will have to declare a variable before the loop. Then increase that variable in first found. And when in second found execute your operation the variable time and set it to 0 after. Try putting something together and come back with you attempt if it fails. Teckx 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Teckx Posted January 29, 2021 Author Share Posted January 29, 2021 (edited) 2 hours ago, Nine said: Ok. I went to TDAmeritrade, look like your screen shot. So, lets go back to your request. You will have to declare a variable before the loop. Then increase that variable in first found. And when in second found execute your operation the variable time and set it to 0 after. Try putting something together and come back with you attempt if it fails. Something like this? N will be the value i'll be using Local $result, $returnX, $returnY $r= 0 $n= 0 While True Sleep (500) $result = _ImageSearchArea($picture, 1, 1690, 113, 1752, 735, $returnX, $returnY, 100, 0) If $result = 1 Then ConsoleWrite ("first found" & @CRLF) $r= ($r + 1) ContinueLoop EndIf $result = _ImageSearchArea($picture, 1, 200, 300, 400, 500, $returnX, $returnY, 100, 0) If $result = 1 Then ConsoleWrite ("second found" & @CRLF) $n = $r * Number("100") $r= 0 EndIf WEnd Edited January 29, 2021 by Teckx Link to comment Share on other sites More sharing options...
Nine Posted January 29, 2021 Share Posted January 29, 2021 Please do not quote everything I said, just use the reply box at the bottom of the thread. It makes the thread cumbersome for nothing. Also use this tool when you post code. It is easier for us to read it. As for your code, you are getting close . Did you try to run it from Scite ? The error I believe is self-explanatory. Also you can use += operator like this : $r += 1 ; instead of $r = $r + 1 (parenthesis are useless in this situration) Look help file for more details. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Teckx Posted January 29, 2021 Author Share Posted January 29, 2021 (edited) Thanks got it working! Am having an issue with the tooltip popping up with my variable ToolTip($r & "test") disregard. got it Edited January 29, 2021 by Teckx Link to comment Share on other sites More sharing options...
Teckx Posted January 30, 2021 Author Share Posted January 30, 2021 (edited) For the second image search. What’s the most efficient IF statement to skip if $r Isn’t = 0 ? If $result = 1 && $r >= 1 Then ConsoleWrite ("second found" & @CRLF) ; do your stuff here EndIf Edited January 30, 2021 by Teckx Link to comment Share on other sites More sharing options...
Teckx Posted February 1, 2021 Author Share Posted February 1, 2021 Hello all having trouble getting this conditional IF to work its ignoring the & $r >= 1 $result = _ImageSearchArea($picture1, 1, 1759, 122, 1831, 735, $returnX, $returnY, 100, 0) If $result = 1 & $r >= 1 Then ;ConsoleWrite ("second found" & @CRLF) MouseClick("left",1293,379,1,0) Link to comment Share on other sites More sharing options...
Teckx Posted February 1, 2021 Author Share Posted February 1, 2021 (edited) it seems to only look at the first If statement and not the & one Edited February 1, 2021 by Teckx Link to comment Share on other sites More sharing options...
Sidley Posted February 1, 2021 Share Posted February 1, 2021 I don't think '&&' is an AutoIt operator, try using 'And' instead. '&' is a string concatenator, not a logical operator.https://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm Link to comment Share on other sites More sharing options...
argumentum Posted February 1, 2021 Share Posted February 1, 2021 On 1/27/2021 at 11:58 PM, Teckx said: and im banging my head on the wall trying to figure this out ..use the platform's scripting. It'll be faster and you'll have a better chance to act on the position. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. 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