BitOfHope Posted February 11, 2012 Share Posted February 11, 2012 Alright, so I know how PixelSearch works, that's not the actual problem. I'm trying to scan my screen for pixels and have it find where the pixels are located at(Easy enough). But in addition to that I am trying to have it recognize which area on my screen the pixels are located at, and perform an action based on where they are. For example: Let's say I have a normal screen and I had a dotted line down the middle. The pixels that I am attempting to locate are on the right side of the screen. So I want to perform a specific line of coding for when it finds them on the right. I also want my script to use a different line of coding if it's found on the left. I know that isn't very clear, and I'm sorry for that. For anybody willing to help just let me know what else I can do to explain it more clearly. I also don't expect anybody to just write out the code for me. Perhaps show me the proper help file(s) to assist me? I already spent a large amount of time searching but I can't find exactly what I need. I'm still new at this Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 11, 2012 Moderators Share Posted February 11, 2012 BitOfHope,Welcome to the AutoIt forum. PixelSearch returns an array containing the coordinates of the point it found. All you need to do is check those values against the coordinates of the location areas you wish to use. In the case of the mid-screen line you posit, we could do something like this: $aCoords = PixelSearch(......) ; Add some errorchecking to make sure we have a valid array returned ; Now chack the X-corrd to see where the point is on the screen If $aCoords[0] > (@DesktopWidth / 2) Then ; Here is the code if the point is to the right of centre Else ; Here is the code if the point is to the left of centre (or exactly on the line to be pedantic) EndIfIf you still have problems then it is probably best to post a screenshot showing the areas you wish to use and the pixel locations for which you are searching. 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...
BitOfHope Posted February 11, 2012 Author Share Posted February 11, 2012 (edited) Thanks for the help ;D After looking at your post I was able to get a basic grasp on it. Sadly though, I have dual monitors for my desktop so it's kind of annoying to use 1/2 of my screen. So I changed up a couple little tiny bits and came up with this: While 1 = 1 $aCoords = PixelSearch(2356, 610, 3350, 833, 0xFFEEDD, 10) If $aCoords[0] > ($aCoords) Then $var_1 = 0 While $var_1 < 1 Send("{A}") ;Coding if the point is on the right of the center Sleep(3000) Send("{B}") $var_1 = $var_1 + 1 WEnd Else $var_2 = 0 While $var_2 < 1 Send("{C}") ;Coding if the point is on the left of the center, or exactly on the line Sleep(3000) Send("{D}") $var_2 = $var_2 + 1 WEnd EndIf WEnd Now the problem is that no matter what, it always presses 'C and D'. While I'm sure it's an easy fix, I can't wrap my head around how to fix it. (Possibly due to lack of sleep ) I'm thinking it's this part? If $aCoords[0] > ($aCoords) Then But I'm drawing a blank here. I just retyped what you showed me without learning how it works exactly. I guess I'm not as good as I thought with this. Off topic: Would you/anybody else mind telling me how to change my display picture on this website? It's driving me crazy. Edited February 11, 2012 by BitOfHope Link to comment Share on other sites More sharing options...
frank10 Posted February 11, 2012 Share Posted February 11, 2012 the aCoords is an array, so if you want to compare some values, you must choose which element you want, like: aCoords[0], aCoords[1]..... aCoords In this case you have a return value from PixelSearch: Returns a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y) If you use the aCoords[0], you are using the x coordinate, so you must compare them with some other x value; you can put (@DesktopWidth / 2) like in previous post or a fixed value, but not (aCoords) because it isn't a value, but an Array. Link to comment Share on other sites More sharing options...
BitOfHope Posted February 11, 2012 Author Share Posted February 11, 2012 the aCoords is an array, so if you want to compare some values, you must choose which element you want, like: aCoords[0], aCoords[1]..... aCoords In this case you have a return value from PixelSearch: Returns a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y) If you use the aCoords[0], you are using the x coordinate, so you must compare them with some other x value; you can put (@DesktopWidth / 2) like in previous post or a fixed value, but not (aCoords) because it isn't a value, but an Array. Ah, alright. That makes a lot more sense, thanks. Now I just need to figure out the other X value to compare it too. I can do that in the morning though. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 11, 2012 Moderators Share Posted February 11, 2012 BitOfHope,Off topic: Would you/anybody else mind telling me how to change my display picture on this website? It's driving me crazyYou need 5 posts to be able to load an avatar - this prevents mere passers-by filling up the server with images.When you have the 5 posts, you open the drop-down menu under your name at top-right and select "My Profile". The default image appears on the left margin and you can change it by clicking on the "Change" button that appears when you move the mouse over it.I look forward to seeing it after a couple more posts from you. 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...
BitOfHope Posted February 11, 2012 Author Share Posted February 11, 2012 (edited) Hurray! I got it to work the way I want it too ;D Thanks guys. I don't know if I should make a new topic for this other question but: I use WinWaitActive so the script doesn't start until I click into the window. Is there a way to make the script pause and/or exit if I click outside of the WinWaitActive window? Edited February 11, 2012 by BitOfHope Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 11, 2012 Moderators Share Posted February 11, 2012 BitOfHope,Just check with WinActive to see if the GUI is active when you click. 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