Jump to content

Detect color change for a specific color


Recommended Posts

 

Looking in the forum I found this code:

HotKeySet("{esc}","quit")
$pix=PixelGetColor(1595,770)
$quit=False
Do

sleep(50)
$pix2=PixelGetColor(1595,770)
if $pix <> $pix2 then
    MsgBox(0,"", "That Pixel Has Changed",0)
    $pix=PixelGetColor(1595,770)
EndIf
until $quit=true

func quit()
    $quit=True
MsgBox(0,"","Bye",0)
EndFunc

It detects when a pixel has changed color

But I need to detect when a color changes from 008000 to FF0000, or the reverse, and when that happens, I need to perform an action, only once (only when the change happens)
I tried several examples, but I'm a beginner and I could not make the action happen once, can anyone help me?

 

Thanks

Link to comment
Share on other sites

It should be a simple case of: if 008000 true, then loop until false, and do the action right after the loop.

Start with one color, and make it work, then proceed to more complexity, 2 or more colors.

If you dont understand the code, it would be a great idea to start checking the help file for the functions and their usage etc.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

25 minutes ago, careca said:

It should be a simple case of: if 008000 true, then loop until false, and do the action right after the loop.

Start with one color, and make it work, then proceed to more complexity, 2 or more colors. 

If you dont understand the code, it would be a great idea to start checking the help file for the functions and their usage etc.

Hi Careca, you mean I should use PixelSearch, to return a true / false?

Link to comment
Share on other sites

9 minutes ago, mclopes said:

I should use PixelSearch, to return a true / false?

PixelSearch does not return true or false.  Read help file carefully.  And it searches for one color (with variation) at a time.  You need to look for 2 very different colors.  So PixelGetColor is better fitted for you.  Change your code to look for either color, when it finds one, continue loop until it finds the other color.  A While True...Wend seems more appropriate for your need.  Put together a script that would attempt to do it, post your code here if you hit a wall...

Link to comment
Share on other sites

If you can tell us what you try to achieve we can tell you if working with pixels is the best approach.
AutoIt offers a lot of very reliable functions which are most of the time better suited than Pixel* functions.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

3 hours ago, water said:

If you can tell us what you try to achieve we can tell you if working with pixels is the best approach.
AutoIt offers a lot of very reliable functions which are most of the time better suited than Pixel* functions.

Agreed - pixel searching is the worst way to automate. WHat are you trying to automate?

Link to comment
Share on other sites

1 hour ago, Bert said:

Agreed - pixel searching is the worst way to automate. WHat are you trying to automate? 

Hello, thank you all, for the help, I intend to automate a stock trading system, when the bar indicator (yellow arrow) turn red will be triggered the sales order, when green will be triggered a purchase order. 

profit.jpg

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...