beekeeper222 Posted June 10, 2020 Share Posted June 10, 2020 (edited) I'm trying to use "And" but it's not working, do you know why, or how else can I set checking three variables at the same time? $coords = PixelSearch(49,422,237,814,0xFFF43C,1) $x = PixelSearch($coords[0]-25,$coords[1]-25,$coords[0]+100,$coords[1]+100,0xFCFCFC,10) $y = PixelSearch(237,442,337,690,0xFCFCFC,10) $z = PixelSearch(237,566,337,690,0xFCFCFC,10) If $x = 1 And $y = 0 And $z = 0 Then Send("{s 2}") ElseIf $x = 1 And $y = 0 And $z = 1 Then Send("{s}") EndIf Edited June 10, 2020 by beekeeper222 Link to comment Share on other sites More sharing options...
Musashi Posted June 10, 2020 Share Posted June 10, 2020 I'm not sure in which "direction" the script goes, but the following for instance is incorrect : $x = PixelSearch(...) --> If $x = 1 ... PixelSearch -> Return Value : a two-element array of pixel's coordinates, not a value like 1 or 0. "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...
beekeeper222 Posted June 10, 2020 Author Share Posted June 10, 2020 Doesn't $x =1 mean the same as Not @error, and $x =0 @error? Link to comment Share on other sites More sharing options...
Musashi Posted June 10, 2020 Share Posted June 10, 2020 (edited) 36 minutes ago, beekeeper222 said: Doesn't $x =1 mean the same as Not @error, and $x =0 @error? The return value of PixelSearch in case of success is an array. On failure @error is set, but this is a separate flag, not a function return. @beekeeper222 : EDIT -> I removed the example, because i made an error -> will give a new one later ! @beekeeper222 : EDIT2 : Example, but no ready-made solution. You should be able to make progress with that . Local $bXFound = True, $bYFound = True, $bZFound = True PixelSearch(237, 442, 337, 690, 0xFFFFFF) If @error Then $bXFound = False PixelSearch(237, 443, 337, 690, 0xFFFFFF) If @error Then $bXFound = False PixelSearch(237, 444, 337, 690, 0xFFFFFF) If @error Then $bXFound = False Select Case (Not $bXFound) And (Not $bYFound) And (Not $bZFound) ConsoleWrite("X-FALSE Y-FALSE Z-FALSE" & @CRLF) Case $bXFound And (Not $bYFound) And (Not $bZFound) ConsoleWrite("X-TRUE Y-FALSE Z-FALSE" & @CRLF) Case $bXFound And (Not $bYFound) And $bZFound ConsoleWrite("X-TRUE Y-FALSE Z-TRUE" & @CRLF) Case $bXFound And $bYFound And $bZFound ConsoleWrite("X-TRUE Y-TRUE Z-TRUE" & @CRLF) Case Else ConsoleWrite("others" & @CRLF) EndSelect Edited June 10, 2020 by Musashi "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...
Nine Posted June 10, 2020 Share Posted June 10, 2020 (edited) I think that it is what @Musashi wanted to show you $coords = PixelSearch(49,422,237,814,0xFFF43C,1) If @error Then Exit PixelSearch($coords[0]-25,$coords[1]-25,$coords[0]+100,$coords[1]+100,0xFCFCFC,10) $x = @error PixelSearch(237,442,337,690,0xFCFCFC,10) $y = @error PixelSearch(237,566,337,690,0xFCFCFC,10) $z = @error If not $x And $y And $z Then Send("{s 2}") ElseIf not $x And $y And not $z Then Send("s") EndIf Edited June 10, 2020 by Nine Musashi 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...
beekeeper222 Posted June 10, 2020 Author Share Posted June 10, 2020 (edited) Thanks guys so much for helping. @Nine why isn't it like that? How would the program know what variables I am referring PixelSearch to? $coords = PixelSearch(49,422,237,814,0xFFF43C,1) If @error Then Exit $x = PixelSearch($coords[0]-25,$coords[1]-25,$coords[0]+100,$coords[1]+100,0xFCFCFC,10) $x = @error $y = PixelSearch(237,442,337,690,0xFCFCFC,10) $y = @error $z = PixelSearch(237,566,337,690,0xFCFCFC,10) $z = @error If not $x And $y And $z Then Send("{s 2}") ElseIf not $x And $y And not $z Then Send("s") EndIf Edited June 10, 2020 by beekeeper222 Link to comment Share on other sites More sharing options...
Nine Posted June 10, 2020 Share Posted June 10, 2020 (edited) Like @Musashi told you, the PixelSearch function return an array of coordinates (X and Y) if successful, otherwise it returns nothing. To check for success you need to look at @error. Like all functions in AutoIt, it is not mandatory to capture the return value. If you do not need the return value, then do not capture it (simple as that). If you insist of capturing the return value, you could check for success or failure by testing if the return value is an array or not using IsArray ($x). In your snippet, it is useless to capture return value of PixelSearch, since you are overwriting the the variables right after when assigning it to @error. Edited June 10, 2020 by Nine “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...
beekeeper222 Posted June 10, 2020 Author Share Posted June 10, 2020 It's giving me error, maybe I can do that? $coords = PixelSearch(49,422,237,814,0xFFF43C,1) $x = PixelSearch($coords[0]-25,$coords[1]-25,$coords[0]+100,$coords[1]+100,0xFCFCFC,10) $y = PixelSearch(237,442,337,690,0xFCFCFC,10) $z = PixelSearch(237,566,337,690,0xFCFCFC,10) If IsArray($x) And Not IsArray($y) And Not IsArray($z) Then Send("{s 2}") ElseIf IsArray($x) And Not IsArray($y) And Isarray($z) Then Send("{s}") EndIf Link to comment Share on other sites More sharing options...
Musashi Posted June 10, 2020 Share Posted June 10, 2020 @beekeeper222 : You may want to familiarize yourself with some of the basics, so that you can understand the context better. Macros such as @error and @extended are set within most functions, but are not equivalent to the return value of the function itself. How this is handled within the particular functions can be found in the Help under "Return Value". Example : ; Function IsArray() ; Return Value : ; Success: 1 (if parameter is an array variable) ; Failure: 0 (if parameter is not an array variable) Local $aArray[3] = ["One", "Two", "Three"] Local $iValue = 42 ConsoleWrite("> >>> is $aArray an array = " & IsArray($aArray) & @CRLF) ConsoleWrite("> >>> is $iValue an array = " & IsArray($iValue) & @CRLF) As you can see, this function returns a value for both cases. In Pixelsearch, there is no return value in case of failure, as @Nine has already explained. Help : Failure: sets the @error flag to 1 if the color is not found. @error must therefore be queried explicitly. One more aspect should be considered regarding @error and @extended. These macros are usually reset after calling another function (even ConsoleWrite). Therefore it is recommended to save them in a variable. "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...
Musashi Posted June 10, 2020 Share Posted June 10, 2020 48 minutes ago, beekeeper222 said: It's giving me error, maybe I can do that? $coords = PixelSearch(49,422,237,814,0xFFF43C,1) $x = PixelSearch($coords[0]-25,$coords[1]-25,$coords[0]+100,$coords[1]+100,0xFCFCFC,10) $y = PixelSearch(237,442,337,690,0xFCFCFC,10) $z = PixelSearch(237,566,337,690,0xFCFCFC,10) If IsArray($x) And Not IsArray($y) And Not IsArray($z) Then Send("{s 2}") ElseIf IsArray($x) And Not IsArray($y) And Isarray($z) Then Send("{s}") EndIf No, since if $coords = PixelSearch(49,422,237,814,0xFFF43C,1) fails, then the line $x = PixelSearch($coords[0]-25,$coords[1]-25,$coords[0]+100,$coords[1]+100,0xFCFCFC,10) will throw an error (==> Subscript used on non-accessible variable) because the array $coords does not exist. For this reason, @Nine added the line If @error Then Exit after $coords = ... "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...
beekeeper222 Posted June 10, 2020 Author Share Posted June 10, 2020 Ok i'll figure it out thank you Link to comment Share on other sites More sharing options...
beekeeper222 Posted June 10, 2020 Author Share Posted June 10, 2020 Also can you guys help me with setting up Pixel Search, i need to search for one pixel on some area, and then mouse move to that pixel, but on the screen are appearing multiple pixels at the same time, so I want to move mouse between them randomly till they dissapear? Link to comment Share on other sites More sharing options...
Musashi Posted June 10, 2020 Share Posted June 10, 2020 18 minutes ago, beekeeper222 said: i need to search for one pixel on some area, and then mouse move to that pixel, but on the screen are appearing multiple pixels at the same time, so I want to move mouse between them randomly till they dissapear? Hmm, now we are slowly but steadily entering a realm where I should ask the following question : "What exactly do you want to achieve with your script?" As you may know, PixelSearch is often used in connection with mouse operations to automatize e.g. Games. I am not a moderator, but I would like to point out, that according to our forum-rules such automatizations are not supported. A more detailed description of your objectives would therefore be beneficial before further assistance can be provided. "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...
beekeeper222 Posted June 10, 2020 Author Share Posted June 10, 2020 Trying to make a bot that scrolls trough a book and counts how many pages are in a single chapter, all the chapters are separated with a navy blue line, but sometimes there are two blue lines on a single page because writer added the same line before the references, and when it happens, bot stops working. Link to comment Share on other sites More sharing options...
Musashi Posted June 10, 2020 Share Posted June 10, 2020 17 minutes ago, beekeeper222 said: Trying to make a bot that scrolls trough a book and counts how many pages are in a single chapter ... This does not sound entirely implausible to me. However, I would still like to ask a moderator how he or she evaluates the issue. A response usually comes pretty fast. I hope you don't have a problem with that. "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...
beekeeper222 Posted June 10, 2020 Author Share Posted June 10, 2020 Sure, I can apply a screenshot of the book or a code I'm currently stucked with if there will be any uncertainty. Link to comment Share on other sites More sharing options...
Musashi Posted June 11, 2020 Share Posted June 11, 2020 5 hours ago, beekeeper222 said: Sure, I can apply a screenshot of the book or a code I'm currently stucked with if there will be any uncertainty. I think that's a good idea. On the one hand, it probably helps the moderator in his/her evaluation. If the feedback is positive, this information will also help users, who are willing and able to give further assistance . "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...
Moderators Melba23 Posted June 11, 2020 Moderators Share Posted June 11, 2020 beekeeper222, A screenshot of the book would be just the thing please. 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...
beekeeper222 Posted June 11, 2020 Author Share Posted June 11, 2020 https://imgur.com/a/dhtikfP and here is a link to the pdf file https://www.researchgate.net/publication/319252974_Podstawy_programowania_w_srodowisku_MS_Excel Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 11, 2020 Moderators Share Posted June 11, 2020 beekeeper222, Perfect, thank you. Thread clear to continue. 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...
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