1. farbe einmalig einlesen und zusammen mit coordinaten speichern
2. dauerhaft farbe von gespeicherten coordinaten mit gespeicherter farbe vergleichen
Code:
Dim $user32 = DllOpen('user32.dll')
Dim $newPosCtrl[4][2] = [['X',0],['Y',0],['Set',0],['Cancel',0]], $pixelColor[3], $running = False, $mouseCheckState = False, $text[2] = ['Start','Stop']
$gui = GUICreate('GUI', 200, 105, Default, Default, 0x10C80000, 8)
$setPosCtrl = GUICtrlCreateButton('Set Current', 10, 10, 180, 20)
GUICtrlCreateGroup('Current Color', 10, 30, 180, 40)
$pixelColorCtrl = GUICtrlCreateLabel('', 15, 45, 170, 20, 0x1001)
SetColor(0,0)
$startCtrl = GUICtrlCreateButton('Start checking for changes', 10, 75, 180, 20)
$childGui = GUICreate('Set Current', 200, 120, Default, Default, 0xC00000, Default, $gui)
For $i=0 To 1
GUICtrlCreateGroup($newPosCtrl[$i][0], 10, 10+$i*40, 100, 40)
$newPosCtrl[$i][1] = GUICtrlCreateInput('', 15, 25+$i*40, 90, 20, 0x2000)
$newPosCtrl[$i+2][1] = GUICtrlCreateButton($newPosCtrl[$i+2][0], 110, 15+$i*40, 80, 36)
Next
$mousePosCtrl = GUICtrlCreateButton('By Mouse Position', 10, 95, 180, 20)
While True
$msg = GUIGetMsg(1)
Switch $msg[0]
Case -3
Exit
Case $setPosCtrl
GUISetState(@SW_SHOW, $childGui)
Case $newPosCtrl[0][1], $newPosCtrl[1][1]
ToolTip('')
Case $newPosCtrl[2][1]
If StringIsInt(GUICtrlRead($newPosCtrl[0][1])) And StringIsInt(GUICtrlRead($newPosCtrl[1][1])) Then
$pixelColor[0] = GUICtrlRead($newPosCtrl[0][1])
$pixelColor[1] = GUICtrlRead($newPosCtrl[1][1])
SetColor($pixelColor[0], $pixelColor[1])
GUISetState(@SW_HIDE, $childGui)
Else
ToolTip('Enter the X and Y postion to set first!', Default, Default, 'Error', 3, 5)
EndIf
Case $newPosCtrl[3][1]
GUISetState(@SW_HIDE, $childGui)
ToolTip('')
Case $startCtrl
ChangeState()
Case $mousePosCtrl
GUISetState(@SW_HIDE, $childGui)
$mouseCheckState = True
EndSwitch
If $mouseCheckState And _IsPressed(1) Then
SetColor(MouseGetPos(0), MouseGetPos(1))
$mouseCheckState = False
EndIf
If $running Then
If PixelGetColor($pixelColor[0], $pixelColor[1]) <> $pixelColor[2] Then
MsgBox(64, 'Info', 'Change detected')
ChangeState()
EndIf
EndIf
WEnd
Func _IsPressed($sHexKey)
Local $a_R = DllCall($user32, "short", "GetAsyncKeyState", "int", $sHexKey)
Return BitAND($a_R[0], 0x8000) <> 0
EndFunc
Func ChangeState()
$running = Not $running
GUICtrlSetData($startCtrl, $text[$running]&' checking for changes')
EndFunc
Func SetColor($x=0, $y=0)
$pixelColor[0] = $x
$pixelColor[1] = $y
$pixelColor[2] = PixelGetColor($x, $y)
GUICtrlSetData($pixelColorCtrl, '0x'&Hex($pixelColor[2],6))
GUICtrlSetBkColor($pixelColorCtrl, $pixelColor[2])
GUICtrlSetColor($pixelColorCtrl, 0xFFFFFF-$pixelColor[2])
EndFunc