Help Pixel loop (FR Aide sur loop d'identification de pixel)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Nanope
Posts: 5
Joined: 03 Aug 2021, 09:33

Help Pixel loop (FR Aide sur loop d'identification de pixel)

Post by Nanope » 03 Aug 2021, 10:29

i'll write a translation in english bellow, but it's easier for me to explain in french, thank for your understanding.

=== English translation ===
(Sorry, it's just google translation, but i think it's understandable ;)
Hello everyone,
I'm trying to automate a bit of a tedious mechanic, which consists of pressing a key or not, depending on the message displayed. These messages are dialog boxes each having a different dimension, so I thought to create a loop that reacts according to the presence or not of the pixel of the box, and depending on whether or not the key signal is returned, but I do not understand not how to do that.

The complete loop consists of 4 messages, corresponding to 1 nested loop in the second:
- A first message at the start of the sequence: Keep pressing enter (the biggest box)
-> Sequence of two messages which alternate at random, the number of repetitions goes from 1 to 10
- Message A: Release entry (2nd largest box)
- Message B: Keep pressing enter (3rd largest box)
- When the sequence is finished, a last message appears: Release entry (smallest box), the sequence starts again.

The dialog boxes remain about 3 to 4 seconds, and disappear for as long before. Only the last box can appear while the previous box is displayed (different position). The sequence may take a little longer to reset (up to 6-7 seconds). Note that the first 3 boxes are located on top of each other (I therefore target the pixels by "elimination": if there are no pixels from the 1st box, I look for the 2nd, etc.):
[attachment = 0] image.png [/ attachment]
It is only necessary to press (or release) entry during the end of the dialog box (I would say the last second) and it does not matter whether the key is pressed or not when there is no box.
The full loop runs between 33 and 100 times (70-80 on average). When the loop can no longer be executed, a message appears.

So I thought I would do a style loop:
[Loop 1]
- Find the pixel of box 1
- When found, press enter for 3s (or keep pressed until ordered otherwise?)
[Loop 2]
- Find the pixel of box 2
- If found: Release entry (or do nothing if entry already released?)
- If not found: Search pixel of box 3
- Press the enter key (will necessarily be found if the other has not been found)
-> Repeat sequence until pixel of box 4 is found
[End loop 2]
- Pixel box 4 found: Release the enter key
- Wait 5 seconds
- Stop the loop if the end message appears, otherwise start over.
[End loop 1]

I tried to translate this on MacroCreator, but I'm stuck because I don't understand how to put it all in place: I don't understand how to handle the enter key, nor how to make the second loop so that it "searches" between the 2 possible options without blocking. I also tried to create an "endboucle" event for the moment when the 4th box appears, which would end the loop, but ditto I don't know how to do it.

For the moment it looks like this:

Code: Select all

 Loop, 3
{
    Loop
    {
        CoordMode, Pixel, Window
        PixelSearch, FoundX, FoundY, 1875, 32, 1886, 59, 0x2E5C73, 0, Fast RGB
        If ErrorLevel
        Loop, 2
        SoundBeep <! - To know if the loop bug, since it is supposed to find these pixels at the beginning of each sequence ->
    }
    Until ErrorLevel = 0
    If (ErrorLevel = 0)
    {
        Loop <! - start of inner loop ->
        {
            Loop, 10 <! - 1st part of the alternation between the 2 possibilities, in principle an "if (find the 1st pixel)" ->
            {
                CoordMode, Pixel, Window
                PixelSearch, FoundX, FoundY, 1829, 17, 1837, 41, 0x2E5C73, 0, Fast RGB
                If ErrorLevel = 0
                Click,% FoundX%,% FoundY%, 0
            } <! - In principle here an "else (find the other pixel)" (->
        }
        Until, end loop <! - Which is supposed to be the end of the inner loop ->
    }
}
Hope my explanation is understandable, otherwise I could still send you a gif of the footage.

Thank you in advance if you can unblock me, otherwise for taking the time to read so far! : D

=== French text ===
Bonjour à tous,
Je cherche à automatiser une mécanique un peu pénible, qui consiste à appuyer sur une touche ou non, selon le message qui s'affiche. Ces messages sont des boites de dialogue ayant chacunes une dimension différente, donc je pensais créer une boucle qui réagit en fonction de la présence ou non du pixel de la box, et en fonction renvoi ou non le signal de la touche, mais je ne comprends pas comment faire ça.

La boucle complète est constituée de 4 messages, correspondant à 1 boucle imbriquée dans la seconde :
- Un premier message au démarrage de la séquence : Restez appuyé sur entrée (la plus grosse box)
-> Séquence de deux messages qui s'alternent de manière aléatoire, le nombre de répétitions va de 1 à 10
- Message A : Relachez entrée (2e box la plus grosse)
- Message B : Restez appuyé sur entrée (3e box la plus grosse)
- Lorsque la séquence est terminée, un dernier message apparaît : Relachez entrée (box la plus petite), la séquence recommence.

Les box de dialogue restent environ 3 à 4 secondes, et disparaissent pendant autant de temps avant. Seule la dernière boite peut apparaître alors que la boite précédente est affichée (position différente). La séquence peut mettre un peu plus de temps à se réinitialiser (jusqu'à 6-7 secondes). À noter que les 3 premières box se situent les unes sur les autres (je cible donc les pixels par "élimination" : si il n'y a pas les pixels de la 1e box, je cherche la 2nde, etc.) :
image.png
(4.27 KiB) Downloaded 89 times
Il n'est nécessaire d'appuyer (ou relacher) entrée que pendant la fin de la boite de dialogue (je dirais la dernière seconde) et peut importe que la touche soit appuyée ou non quand il n'y a pas de box.
La boucle complète s'exécute entre 33 et 100 fois (70-80 en moyenne). Lorsque la boucle ne peut plus s'exécuter, un message apparaît.

Je pensais donc faire une boucle du style :
[Loop 1]
- Chercher le pixel de la box 1
- Lorsque trouvé, appuyer sur entrée pendant 3s (ou rester appuyé jusqu'à ordre contraire ?)
[Loop 2]
- Chercher le pixel de la box 2
- Si trouvé : Relacher entrée (ou ne rien faire si entrée déjà relaché ?)
- Si non trouvé : Chercher pixel de la box 3
- Appuyer sur la touche entrée (sera forcément trouvé si l'autre n'a pas été trouvé)
-> Répéter séquence jusqu'à ce que pixel de la box 4 soit trouvé
[Fin loop 2]
- Pixel box 4 trouvé : Relacher la touche entrée
- Attendre 5 secondes
- Stopper la boucle si message de fin apparaît, sinon recommencer.
[Fin loop 1]

J'ai essayé de traduire ça sur MacroCreator, mais je suis bloqué car je ne comprends pas comment mettre tout ça en place : je ne comprends pas comment gérer la touche entrée, ni comment faire la seconde boucle pour qu'elle "cherche" entre les 2 options possibles sans se bloquer. J'ai aussi essayer de créer un événement "finboucle" pour le moment où la 4e box apparaît, qui mettrais donc fin à la boucle, mais idem je ne sais pas comment faire.

Pour le moment ça donne ça :

Code: Select all

Loop, 3
{
    Loop
    {
        CoordMode, Pixel, Window
        PixelSearch, FoundX, FoundY, 1875, 32, 1886, 59, 0x2E5C73, 0, Fast RGB
        If ErrorLevel
        	Loop, 2
        		SoundBeep  <!-- Pour savoir si la boucle bug, vu qu'il est sensé trouver ces pixels à chaque début de séquence -->
    }
    Until ErrorLevel = 0
    If (ErrorLevel = 0)
    {
        Loop <!-- début de la boucle interne -->
        {
            Loop, 10 <!-- 1e partie de l'alternance entre les 2 possibilités, en principe un "if (trouve le 1er pixel)" -->
            {
                CoordMode, Pixel, Window
                PixelSearch, FoundX, FoundY, 1829, 17, 1837, 41, 0x2E5C73, 0, Fast RGB
                If ErrorLevel = 0
                	Click, %FoundX%, %FoundY%, 0
            } <!-- En principe ici un "else (trouve l'autre pixel)" (->
        }
        Until, finboucle <!-- Ce qui est sensé correspondre à la fin de la boucle interne -->
    }
}
=== French text ===
J'espère que mon explication est compréhensible, sinon je pourrais toujours vous envoyer un gif de la séquence.

Merci par avance si vous pouvez me débloquer, sinon d'avoir pris le temps de lire jusque là ! :D
Nanope
Posts: 5
Joined: 03 Aug 2021, 09:33

Re: Help Pixel loop (FR Aide sur loop d'identification de pixel)

Post by Nanope » 04 Aug 2021, 18:14

Up, still looking for the solution :(
User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: Help Pixel loop (FR Aide sur loop d'identification de pixel)

Post by boiler » 04 Aug 2021, 21:21

There is a lot to try to understand, and the Google translation into English is difficult for me to follow. Have you seen that there is a French section of the forum, specifically the section called J’ai besoin d’aide? It might work out better asking other French speakers since the problem seems quite involved.
Nanope
Posts: 5
Joined: 03 Aug 2021, 09:33

Re: Help Pixel loop (FR Aide sur loop d'identification de pixel)

Post by Nanope » 26 Aug 2021, 14:04

Thanks for the advice, idk what's not understandable on my post, let me know if i can explain some thing. I'll try on french topic, thanks !
Post Reply

Return to “Ask for Help (v1)”