dwaynek Posted June 1, 2021 Share Posted June 1, 2021 my 2nd script works fine when triggered on its own. but when i launch my 1st script which then triggers the 2nd script, i get a line 44 error. anyone know why that is? here's my 1st script: #include <ImageSearch.au3> Run("C:\Program Files (x86)\AutoIt3\AutoIt3.exe " & chr(34) & "d:\my documents\bat\test2.au3" & chr(34)) here's my 2nd script: #include <Array.au3> #include <File.au3> #include <Date.au3> #include <Debug.au3> #include <ImageSearch.au3> Local $x, $y Local $search = _ImageSearchArea('D:\My Documents\imagesearch\thinkorswim_7x4(1&5m).png', 1, 0, 0, 500, 400, $x, $y, 0) sleep(100) ;WinMove($hArray[$i][1], "",-3848,-8, 3856,2136) ;msgbox(0,"",$search) If $search = 1 Then ;msgbox(0,"","Moving to -3850,0,1936,1070") WinMove($hArray[$i][1], "",-3850,0,1936,1070) sleep(100) Local $pos=WinGetPos($hArray[$i][1]) While $pos[0] <> -3850 Or $pos[1] <> 0 Or $pos[2] <> 1936 Or $pos[3] <> 1070 WinMove($hArray[$i][1], "",-3850,0,1936,1070) sleep(100) $pos=WinGetPos($hArray[$i][1]) ;msgbox(0,"",$pos) FileWriteLine($hFileOpen, "$pos: " & $pos) WEnd $cnt+=1 Else ;msgbox(0,"","Moving to -1929,0,1936,1070") WinMove($hArray[$i][1], "",-1929,0,1936,1070) sleep(100) $pos=WinGetPos($hArray[$i][1]) While $pos[0] <> -1929 Or $pos[1] <> 0 Or $pos[2] <> 1936 Or $pos[3] <> 1070 WinMove($hArray[$i][1], "",-1929,0,1936,1070) sleep(100) $pos=WinGetPos($hArray[$i][1]) WEnd EndIf Link to comment Share on other sites More sharing options...
Luke94 Posted June 1, 2021 Share Posted June 1, 2021 Post the error. Link to comment Share on other sites More sharing options...
dwaynek Posted June 2, 2021 Author Share Posted June 2, 2021 Link to comment Share on other sites More sharing options...
markyrocks Posted June 3, 2021 Share Posted June 3, 2021 I think I may have come across this issue b4 playing around with image search. You can just go into the image search au3 and change that line from if $result[0] etc to something like if IsArray($result) and $result[0]="0" then return 0 That way it won't try to access like an array unless it's sure that it is one. Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
dwaynek Posted June 4, 2021 Author Share Posted June 4, 2021 got another error after making that change... Link to comment Share on other sites More sharing options...
Solution markyrocks Posted June 4, 2021 Solution Share Posted June 4, 2021 (edited) 1 hour ago, dwaynek said: got another error after making that change... ;change this if $result[0]="0" then return 0 ; to this if not IsArray($result) or $result[0]="0" then return 0 I had a feeling something like that would happen. That should fix it. Edited June 4, 2021 by markyrocks Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
dwaynek Posted June 7, 2021 Author Share Posted June 7, 2021 awesome! you da man, markyrocks! 👍 Link to comment Share on other sites More sharing options...
JockoDundee Posted June 7, 2021 Share Posted June 7, 2021 @dwaynek, can you post a copy of the ImageSearch.au3 you are using? Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
Professor_Bernd Posted June 7, 2021 Share Posted June 7, 2021 I suspect he is using that source. ImageSearch Usage Explanation Link to comment Share on other sites More sharing options...
JockoDundee Posted June 8, 2021 Share Posted June 8, 2021 2 hours ago, Professor_Bernd said: I suspect he is using that source. Here’s the thing, for ImageSearch.au3 that exact line 44 array subscript error has been encountered literally a dozen times, including in the thread you linked. But I have used the same functions, e.g. _ImageSearchArea(), without problem. But I am using _ImageSearch.au3 (with a leading underscore), which can be found here: I think maybe it’s a newer version?? Anyway, the functions always return an array and if nothing is found then $result[0]=0, just like the error is expecting. Professor_Bernd 1 Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
dwaynek Posted June 12, 2021 Author Share Posted June 12, 2021 thanks, i tried the new version, seems to work better. 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