Craig321 Posted April 15, 2008 Share Posted April 15, 2008 Hi, I have a script that PixelSearches for a particular colour in a window. Every time this window opens it opens in a fairly random place on the screen, so I have to move it to the upper right hand side of the screen to ensure PixelSearch searches the right window. The best solution to this would obviously be to tell PixelSearch to search in a particular window regardless of where it is... is this possible? If the above isn't possible, then is there any way, when the script is started, for the window to get moved to the coordinates that are in the PixelSearch code? Thanks, Craig. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 15, 2008 Moderators Share Posted April 15, 2008 I believe the Beta has an Hwnd option (unless they took it out) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
joshtp Posted April 15, 2008 Share Posted April 15, 2008 I believe the Beta has an Hwnd option (unless they took it out) Yes that option is in the beta versions. However, if it is a window that you move programmatically, then you obviously already know the window position, and you can provide these as arguments to PixelSearch. That should work just as well as using the window handle. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 15, 2008 Moderators Share Posted April 15, 2008 (edited) Yes that option is in the beta versions. However, if it is a window that you move programmatically, then you obviously already know the window position, and you can provide these as arguments to PixelSearch. That should work just as well as using the window handle.Iterate that a bit... this would be using Opt("PixelCoordMode", 2) and getting the client coords of where you want to search versus the screen coords (Which I would assume would be the same for Hwnd anyway).I like the option for hwnd (though I haven't used it yet, but based on other languages I have used the feature in) because if the window is partially covered, it will still get the colors if visible. Edited April 15, 2008 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Craig321 Posted April 15, 2008 Author Share Posted April 15, 2008 Any chance of some examples please? I'm fairly new to AutoIt. Link to comment Share on other sites More sharing options...
joshtp Posted April 15, 2008 Share Posted April 15, 2008 (edited) Any chance of some examples please? I'm fairly new to AutoIt. Here's the simplest way to do it. Like SmOke_N mentioned, that will give you screen coordinates, so if you need them in window coordinates you'll need to shift the result. $winTitle="Inbox - Microsoft Outlook" $color=0xFF0000 $pos=WinGetPos($winTitle) $array=PixelSearch($pos[0],$pos[1],$pos[0]+$pos[2]-1,$pos[1]+$pos[3]-1,$color) If @error Then MsgBox(0,"","Not found") Else MsgBox(0,"",$array[0]&","&$array[1]) EndIf Edited April 15, 2008 by joshtp Link to comment Share on other sites More sharing options...
Craig321 Posted April 15, 2008 Author Share Posted April 15, 2008 Perfect, thanks very much. 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