Sign in to follow this  
Followers 0
Marzupilami

Color Detect

9 posts in this topic

Is there any way I can program in AutoIT so that it can detect what color a certain area of the screen has and use that in code, for example, "If", "When", and "Do"-commands?

Share this post


Link to post
Share on other sites



Marzupilami, can you explain more about what you're trying to accomplish, or what kind of window you're trying to manipulate? As FinishHim points out, there are options under PixelGetColor, but these are flaky at best. Most applications support using Control commands to send commands to the window, and this will provide you with a much more stable script.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Ok, how do I make it wait until a certain pixel has a certain color?

Share this post


Link to post
Share on other sites

Would you please be so kind to answer the question posted by JLogan3o13?

When we know which program you try to auomate we can provide the most reliable solution.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Perhaps, if you share a little of your code thus far, it might become clear about what you are working with, as many windows have different requirements etc. Perhaps even knock up a little If When Do scenario, which we can correct for you if need be. Window positioning and size may need to be taken into account.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

Ok, how do I make it wait until a certain pixel has a certain color?

 

Seeing you are new, you may have not have the pleasure of reading our forum rules. Just to keep things on the up and up. I say this for what you are asking for is 99% of the time for a game and we do not allow for that here. I have no idea if that is your intent or not however no point in wasting our time if it is. Otherwise, it be great if you shared your code so far so we can see how we can help. Thanks.

Share this post


Link to post
Share on other sites

Hi!

Ok, here's the background: I often search the same travel on the local public transport company Västtrafik's webpage, in their route planner: http://reseplanerare.vasttrafik.se/bin/query.exe/sn

Because it would be easier, and because I'm a little interested in code, I thougt I'd make a program in AutoIT that automatically opens Chrome and searches the travel for me. But the page does not load as fast every time, and if the program is going to be fast I cannot just put a long delay in the beginning to be sure.

So my code this far is just:

ShellExecute ("chrome.exe", "http://reseplanerare.vasttrafik.se/bin/query.exe/sn")

Then I thougt something that could detect when a certain pixel on the screen changed color (the page loaded) could solve the problem. Of course if there is a better solution I would really appreciate that as well.

 

(PS. I'm really new to AutoIT, and any type of code. I only know like "ShellExecute, "Sleep", and "Winkill" :) )

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Use IE, or Firefox, and you can easily hook into the DOM object, and wait for it to load...IE comes packaged with autoit:

Here is one of them:

_IELoadWait

If the page loads, and still has elements being built, then you can loop for your specific element to be present.

That will be ooddles easier than pixel searching...not to mention more reliable also.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0