❔ Triggering an action after a complex on-screen dialog with a small time window
Apologies for the confusing title but this is a very complex one to explain.
I'm running a test to see how far I can automate basic activities using C#.
The activity I'm trying to automate involves clicking a number presented in a circle when the red line meets the green section - an example gif is here for said circle: https://share.zeron.dev/CKXj2VV.gif
This red line changes in speed and the green section is randomly placed around the circle. The red line moves at quite a fast pace sometimes too. The green only changes colour after the input is given too, for context.
I have already setup OCR to read the number in the center but I am struggling to think of a good way to trigger the keypress (specifically at the right time).
My initial thought is to screenshot the dialog area of the screen constantly until the green pixels are detected - then I can keep rechecking to see if those green pixels turn red (meaning the bar has began to cross), and I would fire the keypress with the number.
The only reason I haven't tried this process yet is because I know the method for checking image pixels in C# is very slow - so I'm wondering if anyone has any better ideas for this?
Thanks a lot!
2 Replies