How to get Mathematica to trigger an event when a variable inside a Dynamic[] changes?
I want Mathematica to Beep[] when the colour of a pixel on the screen changes. I recommend wiggling some multicolour window in the middle of the screen to test this program. On Mac you can find the coordinates of pixels at the cursor with Command+Shift+4.
<< GUIKit`;
num := Evaluate[numb[thePixel]];
thePixel := GUIScreenShot[{{1280, 1281}, {730, 731}}];
numb = Flatten[ImageData[#, "Byte"]] &;
Dynamic[
Refresh[
Clear[z];
z := num // Total;
Evaluate[z],
UpdateInterval -> .1
]
]
Now you should see a number changing as you change the colours of the pixel.
Now how do I get Mathematica to trigger a Beep[] when the number changes?
clues welcome :)
I tried both of the solutions in Detecting changes of variables' values