I am looking to have an LED turn on if a pixel on screen is flashing yellow
I want the LED to remain on if the pixel is flashing and turn off 2 seconds after it has stopped flashing (the 2 seconds is to ensure it is not going to flash again and turn off when not wanted)
I have a script that works
BUT when I duplicate it for a second LED and PIXEL the OFF function does not work
This is the working script:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance Force
If DllCall("LoadLibrary", "str", "PacDrive32.dll")
If DllCall("PacDrive32.dll\PacInitialize")
#Persistent
;Turns LED off if pixel grey for 2seconds
CoordMode, Pixel
ticks := A_TickCount, targetColor := "0xC0C0C0", minTime := 2000
Sub1:
PixelGetColor, thisColor, -574, 327
If (thisColor != targetColor)
ticks := A_TickCount
SetTimer, Sub1, 100
If (A_TickCount - ticks > minTime)
DllCall("PacDrive32.dll\PacSetLEDState",Int,0,Int,9,Int,0)
;Turns LED on if pixel flashes yellow
CoordMode, Pixel, Screen
Pixelgetcolor, Color9, -574, 327, RGB
if Color9 = 0xFFFF00
DllCall("PacDrive32.dll\PacSetLEDState",Int,0,Int,9,Int,1)
This is when trying to add a second LED and PIXEL the OFF function does not work
If DllCall("LoadLibrary", "str", "PacDrive32.dll")
If DllCall("PacDrive32.dll\PacInitialize")
#Persistent
;Turns LED off if pixel grey for 2seconds
CoordMode, Pixel
ticks := A_TickCount, targetColor := "0xC0C0C0", minTime := 2000
Sub1:
PixelGetColor, thisColor, -574, 327
If (thisColor != targetColor)
ticks := A_TickCount
SetTimer, Sub1, 100
If (A_TickCount - ticks > minTime)
DllCall("PacDrive32.dll\PacSetLEDState",Int,0,Int,9,Int,0)
;Turns LED on if pixel flashes yellow
CoordMode, Pixel, Screen
Pixelgetcolor, Color9, -574, 327, RGB
if Color9 = 0xFFFF00
DllCall("PacDrive32.dll\PacSetLEDState",Int,0,Int,9,Int,1)
;Turns LED off if pixel grey for 2seconds
CoordMode, Pixel
ticks := A_TickCount, targetColor := "0xC0C0C0", minTime := 2000
Sub2:
PixelGetColor, thisColor, -652, 327
If (thisColor != targetColor)
ticks := A_TickCount
SetTimer, Sub2, 100
If (A_TickCount - ticks > minTime)
DllCall("PacDrive32.dll\PacSetLEDState",Int,0,Int,8,Int,0)
;Turns LED on if pixel flashes yellow
CoordMode, Pixel, Screen
Pixelgetcolor, Color8, -652, 327, RGB
if Color8 = 0xFFFF00
DllCall("PacDrive32.dll\PacSetLEDState",Int,0,Int,8,Int,1)
Script to turn LED on if pixel flashes yellow
Script to turn LED on if pixel flashes yellow
Last edited by Jezza on 20 May 2022, 09:42, edited 1 time in total.
Re: Script to turn LED on if pixel flashes yellow
@Jezza - the colored parts of the code can't be read if not viewed with the dark forum setting - and the code-line-tag/feature is lacking all the benefits of the standard code-section-tags. JFTR