Lucidity Posted April 2, 2012 Share Posted April 2, 2012 (edited) Last time I used AutoIT was 3 years ago and already then I wasn't very good at coding/scripting. I got very low experiences in programming and have only been using Visual Basic (6 and .net) and AutoIT.Now however, I've already run into a problem that I don't understand of what's wrong.Here what I gotFunc Test() $Click = PixelSearch(822, 550, 860, 565, 0x3B5998) Sleep(1000) if @error Then MsgBox("Error","The pixels was not found.") Else Mouseclick("left",$Click[0], $Click[1]) EndIf EndFuncWhen I got the color in this coordination, the mouse goes to the coordination and making a left click. Just as I want.However, when I don't got the color in the coordination, I'm getting up an error on the Mouseclick line. It says the [0] is error (if I understand it right).I don't understand. Because wont it be registered as an @error when the pixelsearch isn't found? What I see from my old script I got it very similar.When I look at the guide it says @error is set to 1, so even if I try to make it If @error = 1 then instead, it will still give me error on the same line as before.Anybody who would like to help?Also is there more tutorials? I've read the 4 tutorials in the help file, but then it's just functions and stuffs, ofc I guess I can read one by one from there, but if somebody got more tutorials that me as a beginner can follow for being a pro in AutoIT, it would be very nice.also I tried this, but still same error!Func Test() $Click = PixelSearch(822, 550, 860, 565, 0x3B5998) Sleep(1000) if @error = 1 Then MsgBox("Error","The pixels was not found.") Elseif @error = 0 Then Mouseclick("left",$Click[0], $Click[1]) EndIf EndFuncThanks in advance! Edited April 2, 2012 by Lucidity Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 2, 2012 Moderators Share Posted April 2, 2012 Lucidity,Welcome to the Autoit forum. If PixelSearch fails then you do not get an array of coordinates returned - so the script crashes when you try to read the elements. And when you check @error you are actually checking Sleep which rarely errors in my experience. Use IsArray to test like this:$Click = PixelSearch(822, 550, 860, 565, 0x3B5998) Sleep(1000) If IsArray($Click) Then Mouseclick("left",$Click[0], $Click[1]) Else MsgBox("Error","The pixels was not found.") EndIfTry that and see how you get on. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Lucidity Posted April 2, 2012 Author Share Posted April 2, 2012 Aah, thank you! 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