help with else line

Advanced Macro Recorder/Editor.

Moderator: Pulover

dvir

help with else line

02 May 2017, 06:11

Hi everyone,
Im trying to write simple login macro that will run in the background infinity until i open specific login page (like to the forum's login page),
somehow i made a big mess with the code and i need your help.

this is the code :

Code: Select all

Loop
{
    Sleep, 500
    CoordMode, Pixel, Window
    ImageSearch, FoundX, FoundY, 0, 0, 1920, 1080, C:\Users\Shaked\AppData\Roaming\MacroCreator\Screenshots\Screen_20170501140939.png
    CenterImgSrchCoords("C:\Users\Shaked\AppData\Roaming\MacroCreator\Screenshots\Screen_20170501140939.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Click, %FoundX%, %FoundY% Left, 1
    Sleep, 1000
    CoordMode, Pixel, Window
    ImageSearch, FoundX, FoundY, 0, 0, 1920, 1080, C:\Users\Shaked\AppData\Roaming\MacroCreator\Screenshots\Screen_20170501140939.png
    CenterImgSrchCoords("C:\Users\Shaked\AppData\Roaming\MacroCreator\Screenshots\Screen_20170501140939.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Click, %FoundX%, %FoundY% Left, 1
    Sleep, 1000
    CoordMode, Pixel, Window
    ImageSearch, FoundX, FoundY, 0, 0, 1920, 1080, C:\Users\Shaked\AppData\Roaming\MacroCreator\Screenshots\Screen_20170501140215.png
    CenterImgSrchCoords("C:\Users\Shaked\AppData\Roaming\MacroCreator\Screenshots\Screen_20170501140215.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Click, %FoundX%, %FoundY% Left, 1
    SendRaw, [email protected]
    Sleep, 300
    CoordMode, Pixel, Window
    ImageSearch, FoundX, FoundY, 0, 0, 1920, 1080, C:\Users\Shaked\AppData\Roaming\MacroCreator\Screenshots\Screen_20170501140431.png
    If ErrorLevel = 0
    	Click, %FoundX%, %FoundY% Left, 1
    SendRaw, 123456
    CoordMode, Pixel, Window
    ImageSearch, FoundX, FoundY, 0, 0, 1920, 1080, C:\Users\Shaked\AppData\Roaming\MacroCreator\Screenshots\Screen_20170501140519.png
    CenterImgSrchCoords("C:\Users\Shaked\AppData\Roaming\MacroCreator\Screenshots\Screen_20170501140519.png", FoundX, FoundY)
    If ErrorLevel = 0
    	Click, %FoundX%, %FoundY% Left, 1
}
Else
{
    1:
}
The macro should search for 2 diffrent login buttons and if he dont find them he should not run and back to the if statement but he does not do that .
thanks for the help ,
dvir.
User avatar
Almost_there
Posts: 404
Joined: 30 Sep 2014, 10:32

Re: help with else line

02 May 2017, 15:08

It's hard to say because it's a mess. There is an If, but no belonging Else - or are the If/Else ment to be grouped, so there is one curly bracket too much?

Also, the label "1" doesn't give any sense, espechially not when it's only statement within the If statement.

Another problem (i think that is a problem) is that there is a function call between ImageSearch and "If errorlevel" - so that may mess up with the errorlevel check. I've not tested yet if errorlevel is global or not, I think it was never ment to be used globally.

I can assume that CenterImgSrchCoords() should be a part of the "if errorlevel" block together with Click command.

Return to “Pulovers Macro Creator”

Who is online

Users browsing this forum: No registered users and 23 guests