kukkuk Posted September 2, 2012 Share Posted September 2, 2012 This script works just fine as .au3 file. After compiling it to an .exe it gets error: "Subscript used with non-Array Variable". I really dont get the difference - why is it working in .au3 and not in. exe. Part of my code where it gets the error: $slot1x = 538 $slot1y = 367 $offset = 27 $x = 0 $y = 0 For $i = 0 To 9 For $j = 0 To 5 MouseMove($slot1x + ($i * $offset), $slot1y + ($j * $offset),3) $pos = MouseGetPos() $res = _ImageSearchArea('req.png', 1, $pos[0]-150, $pos[1], $pos[0], 638, $x, $y, 100) If $res = 0 Then PixelSearch($pos[0]-250,200,$pos[0]-100,$pos[1]+50,12564995,3) If @error Then Sleep(Random(50,100)) MouseClick("right") Endif Else Sleep(Random(50,100)) MouseClick("right") Endif Next Next After clicking the first position (538,367) and doing image search there is an error which I described above. After removing the: $res = _ImageSearchArea('req.png', 1, $pos[0]-150, $pos[1], $pos[0], 638, $x, $y, 100) If $res = 0 Then Endif It works fine. _ImageSearchArea is a function from ImageSearch which is included. Code: Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance) $findImage = "*TRANSBLACK " & $findImage if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage) if $result = "0" then return 0 ; Otherwise get the x,y location of the match and the size of the image to ; compute the centre of search $array = StringSplit($result[0],"|") If(UBound($array) >= 4) Then $x=Int(Number($array[2])) $y=Int(Number($array[3])) if $resultPosition=1 then $x=$x + Int(Number($array[4])/2) $y=$y + Int(Number($array[5])/2) endif return 1 EndIf EndFunc Link to comment Share on other sites More sharing options...
kukkuk Posted September 2, 2012 Author Share Posted September 2, 2012 Anyone? Link to comment Share on other sites More sharing options...
water Posted September 2, 2012 Share Posted September 2, 2012 Welcome to AutoIt and the forum! This is no 24-hours-support-forum. So please wait at least 24 hours before you bumpt a thread. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
kukkuk Posted September 2, 2012 Author Share Posted September 2, 2012 Ok, thanks for letting me know. I wont do it again. Link to comment Share on other sites More sharing options...
kukkuk Posted September 4, 2012 Author Share Posted September 4, 2012 up Link to comment Share on other sites More sharing options...
nitekram Posted September 4, 2012 Share Posted September 4, 2012 I would start with that function call ($pos = MouseGetPos()) and see if you are actually getting an array back - check for error value and if no error continue? 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
jackraymund Posted September 5, 2012 Share Posted September 5, 2012 (edited) try it if isarray($pos) $res = _ImageSearchArea('req.png', 1, $pos[0]-150, $pos[1], $pos[0], 638, $x, $y, 100) If $res = 0 Then Endif endif Edited September 5, 2012 by jackraymund thanks you BrewManNH Link to comment Share on other sites More sharing options...
Tripredacus Posted September 5, 2012 Share Posted September 5, 2012 You are using a relative path to the PNG file. You should determine a way to determine exactly where the PNG file is and use that. The reason you get the error is likely because your EXE can't find the PNG file, but since you aren't using any error checking, it processes the function anyways... which probably is returning a NULL or 0 value, rather than an array value, thus causing the error. Twitter | MSFN | VGCollect Link to comment Share on other sites More sharing options...
kukkuk Posted September 7, 2012 Author Share Posted September 7, 2012 thanks mates, Ill try your solutions Link to comment Share on other sites More sharing options...
kukkuk Posted September 8, 2012 Author Share Posted September 8, 2012 I have tried such a code:$slot1x = 538 $slot1y = 367 $offset = 27 $x = 0 $y = 0 DEBUG("Stashing in tab2") Sleep(1500) For $i = 0 To 9 For $j = 0 To 5 MouseMove($slot1x + ($i * $offset), $slot1y + ($j * $offset),3) $pos = MouseGetPos() if isarray($pos) then Debug("It is an array!") endif Sleep (1000) Debug("Mouse pos: x:" & $pos[0] & " y:" & $pos[1] & "") Sleep (3000) $res = _ImageSearchArea('req.png', 1, $pos[0]-150, $pos[1], $pos[0], 638, $x, $y, 100); If $res = 0 Then Debug("Mouse pos: x:" & $pos[0] & " y:" & $pos[1] & "") Else Debug("Found it") Endif Next NextI get the result that $pos is an array and can see the $pos[0] and $pos[1] results. So there is no error and I am always getting an array back. And after compiling it to an exe I still have the same error... "Subscript used with non-Array Variable".I have also tried to change: $res = _ImageSearchArea('req.png', 1, $pos[0]-150, $pos[1], $pos[0], 638, $x, $y, 100);to $res = _ImageSearchArea('D:\Users\Mateusz_2\Desktop\req.png', 1, $pos[0]-150, $pos[1], $pos[0], 638, $x, $y, 100);It is the full path of that file. Still I have the same error after compiling.I will be thankfull for any further help! Link to comment Share on other sites More sharing options...
Tripredacus Posted September 10, 2012 Share Posted September 10, 2012 You should output what $res is after using the _ImageSearchArea() function to see if it has the data in it that you are expecting. Twitter | MSFN | VGCollect 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