Page 1 of 1

HELP: casual error

Posted: 07 Mar 2024, 09:23
by danitkd93
Hi everyone, I've recently been using this program instead of Macro Recorder as the latter has become really too expensive and also with Pulovers I have many more functions.
Despite this I have a big problem... the program is very unstable. Randomly it goes from one side to another, often gets stuck on GOTO commands and other times it misses clicks or doesn't find images (which are always the same).
Then I block it and restart it from the point where it stopped and magically it unblocks.
Another strange error is that at the end of the program, when it should start again, it often jams.

Why all this instability? Maybe there are errors in the code I wrote?
I'll leave you a copy... sorry for the length. I hope you can give me a hand :) :crazy:

Code: Select all

Run, C:\Users\giovanna\Documents\Macro Recorder\work in progress\distinta di confezionamento\Entrata merci distinta confezionamento.xlsx
KeyWait, Insert
KeyWait, Insert, D
prova:
Sleep, 1000
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, *10 C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304111533.png
    CenterImgSrchCoords("*10 C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304111533.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Break
    If (ErrorLevel)
    {
        Loop
        {
            CoordMode, Pixel, Screen
            ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, *10 C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304164731.png
            CenterImgSrchCoords("*10 C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304164731.png", FoundX, FoundY)
            If ErrorLevel = 0
            	Click, %FoundX%, %FoundY%, 0
        }
        Until ErrorLevel = 0
        Click, Left, 2
        Sleep, 10
    }
}
Click, %FoundX%, %FoundY% Left, 1
Sleep, 10
Send, {Control Down}{f}{Control Up}
Sleep, 500
Send, {A}{A}{A}
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\Screenshots\Screen_20240228125946.png
}
Until ErrorLevel = 0
Send, {Backspace}{Backspace}{Backspace}{Backspace}
Run, C:\Users\giovanna\Documents\Macro Recorder\work in progress\distinta di confezionamento\Entrata merci distinta confezionamento.xlsx
Loop, 5
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304111959.png
    CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304111959.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Click, %FoundX%, %FoundY% Left, 1
    If ErrorLevel
    	Loop, 2
    		SoundBeep
    Sleep, 1000
}
Until ErrorLevel = 0
Loop, 5
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304112043.png
    CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304112043.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Click, %FoundX%, %FoundY% Left, 1
    If ErrorLevel
    	Loop, 2
    		SoundBeep
    Sleep, 1000
}
Until ErrorLevel = 0
Send, {Down}
Loop, 5
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\Screenshots\Screen_20240304104648.png
    CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\Screenshots\Screen_20240304104648.png", FoundX, FoundY)
    Sleep, 1000
}
Until ErrorLevel = 0
Send, {Control Down}{c}{Control Up}
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, *10 C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304111533.png
    CenterImgSrchCoords("*10 C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304111533.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Break
    If (ErrorLevel)
    {
        Loop
        {
            CoordMode, Pixel, Screen
            ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, *10 C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304164731.png
            CenterImgSrchCoords("*10 C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304164731.png", FoundX, FoundY)
            If ErrorLevel = 0
            	Click, %FoundX%, %FoundY%, 0
        }
        Until ErrorLevel = 0
        Click, Left, 2
        Sleep, 10
    }
}
Click, %FoundX%, %FoundY% Left, 1
Sleep, 10
Send, {Control Down}{v}{Control Up}{Enter}
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307134418.png
    If ErrorLevel
    	Loop, 2
    		SoundBeep
    Sleep, 2000
}
Until ErrorLevel = 0
CoordMode, Pixel, Screen
ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304120749.png
If ErrorLevel = 0
	Click, %FoundX%, %FoundY% Left, 1
Click, 1030, 196 Right, 1
Sleep, 10
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304121113.png
    CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304121113.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Click, %FoundX%, %FoundY% Left, 1
}
Until ErrorLevel = 0
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304121155.png
    CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304121155.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Click, %FoundX%, %FoundY% Left, 1
}
Until ErrorLevel = 0
Run, C:\Users\giovanna\Documents\Macro Recorder\work in progress\distinta di confezionamento\Entrata merci distinta confezionamento.xlsx
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304150425.png
}
Until ErrorLevel = 0
Send, {Right}{Control Down}{c}{Control Up}
Loop, 5
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304144436.png
    CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304144436.png", FoundX, FoundY)
    Sleep, 1000
}
Until ErrorLevel = 0
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304145122.png
    CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304145122.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Click, %FoundX%, %FoundY% Left, 1
}
Until ErrorLevel = 0
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304145639.png
    CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304145639.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Click, %FoundX%, %FoundY%, 0
}
Until ErrorLevel = 0
Click, Rel 0, +20 Left, 1
Sleep, 10
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 371, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304151227.png
}
Until ErrorLevel = 0
Send, {Control Down}{v}{Control Up}{Enter}
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304151432.png
    CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304151432.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Click, %FoundX%, %FoundY% Left, 1
}
Until ErrorLevel = 0
Send, {Control Down}{v}{Control Up}{RShift Down}{Tab}{RShift Up}
Sleep, 1000
Run, C:\Users\giovanna\Documents\Macro Recorder\work in progress\distinta di confezionamento\Entrata merci distinta confezionamento.xlsx
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304150425.png
}
Until ErrorLevel = 0
Send, {Right}{Control Down}{c}{Control Up}
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304151851.png
}
Until ErrorLevel = 0
Send, {RWin Down}{Down}{RWin Up}
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304151926.png
    CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304151926.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Click, %FoundX%, %FoundY% Left, 1
}
Until ErrorLevel = 0
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240306191821.png
    CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240306191821.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Click, %FoundX%, %FoundY% Left, 1
}
Until ErrorLevel = 0
Sleep, 1000
Send, {Control Down}{v}{Control Up}
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, *5 C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240306190346.png
}
Until ErrorLevel
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, *5 C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240306191103.png
}
Until ErrorLevel = 0
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304151926.png
    CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304151926.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Click, %FoundX%, %FoundY% Left, 1
}
Until ErrorLevel = 0
Sleep, 1000
Send, {Tab}{Tab}
Sleep, 1000
Run, C:\Users\giovanna\Documents\Macro Recorder\work in progress\distinta di confezionamento\Entrata merci distinta confezionamento.xlsx
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304150425.png
}
Until ErrorLevel = 0
Sleep, 1000
Send, {Right}
Sleep, 500
Send, {Control Down}{c}{Control Up}
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304152139.png
}
Until ErrorLevel = 0
Send, {RWin Down}{Down}{RWin Up}
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304151926.png
    CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304151926.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Click, %FoundX%, %FoundY% Left, 1
}
Until ErrorLevel = 0
Sleep, 500
Send, {Control Down}{v}{Control Up}
Sleep, 500
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304152312.png
}
Until ErrorLevel
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304152356.png
}
Until ErrorLevel
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304152429.png
}
Until ErrorLevel
Send, {Enter}
Sleep, 1000
Send, {Enter}
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304151926.png
    CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304151926.png", FoundX, FoundY)
}
Until ErrorLevel
RIAGGIORNA:
Sleep, 500
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304155753.png
    CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304155753.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Click, %FoundX%, %FoundY% Left, 1
}
Until ErrorLevel = 0
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304155856.png
    CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304155856.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Break
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, *5 C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307123614.png
    CenterImgSrchCoords("*5 C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307123614.png", FoundX, FoundY)
    If (ErrorLevel = 0)
    {
        Loop
        {
            CoordMode, Pixel, Screen
            ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307124245.png
            CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307124245.png", FoundX, FoundY)
            If ErrorLevel = 0
            	Click, %FoundX%, %FoundY%, 0
        }
        Until ErrorLevel = 0
        Click, Rel 0, 20 Left, 1
        Sleep, 10
        Send, {Control Down}{c}{Control Up}{Alt Down}{m}{Alt Up}
        Loop
        {
            CoordMode, Pixel, Screen
            ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307123956.png
            CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307123956.png", FoundX, FoundY)
            If ErrorLevel = 0
            	Click, %FoundX%, %FoundY% Left, 1
        }
        Until ErrorLevel = 0
        Loop
        {
            CoordMode, Pixel, Screen
            ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307124053.png
            CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307124053.png", FoundX, FoundY)
            If ErrorLevel = 0
            	Click, %FoundX%, %FoundY% Left, 1
        }
        Until ErrorLevel = 0
        Loop
        {
            CoordMode, Pixel, Screen
            ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307124132.png
            CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307124132.png", FoundX, FoundY)
        }
        Until ErrorLevel = 0
        Send, {Control Down}{v}{Control Up}
        Sleep, 500
        Send, {Enter}
        Loop
        {
            CoordMode, Pixel, Screen
            ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307125028.png
            CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307125028.png", FoundX, FoundY)
            If ErrorLevel = 0
            	Click, %FoundX%, %FoundY%, 0
        }
        Until ErrorLevel = 0
        Send, {Enter}
        Sleep, 2000
        Loop
        {
            CoordMode, Pixel, Screen
            ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307125232.png
            CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307125232.png", FoundX, FoundY)
            If ErrorLevel = 0
            	Click, %FoundX%, %FoundY% Left, 1
        }
        Until ErrorLevel = 0
        Loop
        {
            CoordMode, Pixel, Screen
            ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307125329.png
            CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307125329.png", FoundX, FoundY)
            If ErrorLevel = 0
            	SoundBeep
            Sleep, 500
        }
        Until ErrorLevel
        Sleep, 1000
        Send, {Enter}
        Sleep, 1000
        Loop
        {
            CoordMode, Pixel, Screen
            ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, *10 C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307130055.png
            CenterImgSrchCoords("*10 C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307130055.png", FoundX, FoundY)
            If ErrorLevel = 0
            	Click, %FoundX%, %FoundY% Left, 1
            Sleep, 500
        }
        Until ErrorLevel = 0
        Loop
        {
            CoordMode, Pixel, Screen
            ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307130125.png
            CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240307130125.png", FoundX, FoundY)
            Sleep, 500
        }
        Until ErrorLevel
    }
    Goto, RIAGGIORNA
}
Click, %FoundX%, %FoundY% Left, 1
Sleep, 10
Sleep, 300
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, *10 C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304111533.png
    CenterImgSrchCoords("*10 C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304111533.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Break
    If (ErrorLevel)
    {
        Loop
        {
            CoordMode, Pixel, Screen
            ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, *10 C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304164731.png
            CenterImgSrchCoords("*10 C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304164731.png", FoundX, FoundY)
            If ErrorLevel = 0
            	Click, %FoundX%, %FoundY%, 0
        }
        Until ErrorLevel = 0
        Click, Left, 2
        Sleep, 10
    }
}
Click, %FoundX%, %FoundY% Left, 1
Sleep, 10
Run, C:\Users\giovanna\Documents\Macro Recorder\work in progress\distinta di confezionamento\Entrata merci distinta confezionamento.xlsx
Loop
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304150425.png
}
Until ErrorLevel = 0
Send, {RShift Down}{Space}{RShift Up}{Control Down}{NumpadSub}{Control Up}{Right}{Right}{Down}{Down}{Down}
CoordMode, Pixel, Screen
ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304170854.png
If (ErrorLevel = 0)
{
    CoordMode, Pixel, Screen
    ImageSearch, FoundX, FoundY, 0, 0, 1680, 1050, C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304172239.png
    CenterImgSrchCoords("C:\Users\giovanna\AppData\Roaming\MacroCreator\MacroCreator\Screenshots\Screen_20240304172239.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Click, %FoundX%, %FoundY% Left, 1
    Send, {Down}{Space}{Backspace}{Backspace}
    SendRaw, =SE(D2=""; ""; 'inserimento numero distinte'!$A$2&""&'inserimento numero distinte'!B2)
    Send, {Enter}{Up}{Control Down}{c}{Control Up}{RShift Down}{Down 20}{RShift Up}{Control Down}{v}{Control Up}{RShift Down}{F12}{RShift Up}
    KeyWait, End
    KeyWait, End, D
}
Else
{
}
Sleep, 1000
Goto, prova