Jump to content

Color change alarm script?


 Share

Recommended Posts

I'm looking for a script that will play an alarm when there is a certain color recognized at whatever coordinates are marked in a window.

I.e.

Aim chat window -

My buddy sends me a message, lettering is black. Next line buddy sends a red lettered message, my CPU plays an alarm sound. (second lines coordinates would be marked)

Is this possible?

Sorry if this is a common question - search wasn't helping me out.

Link to comment
Share on other sites

  • Moderators

Yobear,

Welcome to the AutoIt forum. ;)

I'm looking for a script

That is not exactly how it works here. We want you to have a go at coding something yourself first - we will help out when you run into problems. Think of the old saying: "Give a man a fish, you feed him for a day; give a man a net and you feed him forever". We try to be net makers and repairers, not fishmongers. :evil:

Some pointers to help you get started. Look in the Help file for:

WingetPos - this wil help you locate your chat window.

PixelGetColor and PixelSearch - they will help you identify when colours change in the window.

If...Then - this will let you choose what to do if the colour is or is not found

While...WEnd - this will let you wait until you get a colour change

SoundPlay - this will play your alarm sound

Have fun! You know where we are if you have problems. :evil:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Aye, sorry mate, I realize now my post came off as a "do it for me" type request. I was in fact looking for a few pointers as to where to get started, and you've hit all those for me! Thanks again mate.

Yobear,

Welcome to the AutoIt forum. ;)

That is not exactly how it works here. We want you to have a go at coding something yourself first - we will help out when you run into problems. Think of the old saying: "Give a man a fish, you feed him for a day; give a man a net and you feed him forever". We try to be net makers and repairers, not fishmongers. :evil:

Some pointers to help you get started. Look in the Help file for:

WingetPos - this wil help you locate your chat window.

PixelGetColor and PixelSearch - they will help you identify when colours change in the window.

If...Then - this will let you choose what to do if the colour is or is not found

While...WEnd - this will let you wait until you get a colour change

SoundPlay - this will play your alarm sound

Have fun! You know where we are if you have problems. :evil:

M23

Link to comment
Share on other sites

; Find a pure red pixel in the range
$coord = PixelSearch(0, 0, 820, 800, 0xFF0000)
If Not @error Then Alert($coord, "Red, Alert.")

; Find a pure red pixel in the range
$coord = PixelSearch(0, 0, 820, 800, 0x000000)
If Not @error Then Alert($coord, "Black, Alert.")

; Find a pure green pixel in the range
$coord = PixelSearch(0, 0, 820, 800, 0x00FF00, 150) ;<- shade-variation 150 for testing
If Not @error Then Alert($coord, "Green, Alert.")


;Ref: http://www.autoitscript.com/forum/index.php?showtopic=106866&view=findpost&p=754100
Func Alert($coord, $ColAlert = "Alert")
    Local $hGUI, $hLab[5], $temp, $File, $BkGndCol = 0xE0E0E0
    $temp = StringReplace($ColAlert & " " & $ColAlert, " ", "+")
    $File = StringRegExpReplace($ColAlert, "([ .,!])", "") ;Clean up file name.
    If Not FileExists(@TempDir & "\" & $File & ".mp3") Then _
            InetGet("http://translate.google.com/translate_tts?q=" & $temp, _
            @TempDir & "\" & $File & ".mp3")

    If StringInStr($ColAlert, "Red") Then $BkGndCol = 0xFFE0E0
    If StringInStr($ColAlert, "Black") Then $BkGndCol = 0xE0E0E0
    If StringInStr($ColAlert, "Green") Then $BkGndCol = 0xE0FFE0

    $hGUI = GUICreate("Colour Found", 200, 80, -1, -1, 0x80800000, 0x00120100)
    GUISetBkColor($BkGndCol, $hGUI)
    $hLab[0] = GUICtrlCreateLabel($ColAlert, 5, 5, 190, 40)
    GUICtrlSetFont($hLab[0], 22, 600)
    $hLab[1] = GUICtrlCreateLabel("X and Y are: " & $coord[0] & ", " & $coord[1], 10, 50)
    MouseMove($coord[0], $coord[1])
    GUISetState()

    SoundPlay(@TempDir & "\" & $File & ".mp3", 1)
    GUIDelete($hGUI)
    Return
EndFunc ;==>Alert

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...