Jump to content

How to execute code after every action?


Recommended Posts

I have a script that is quite long and want to execute a certain piece of code after every action without implementing the piece of code after every action if that makes sense.

The lines I want to repeat after every line of code in my script are:

$coord99 = PixelSearch( 36, 102, 38, 104, 16777215 );Color of popup
If Not @error Then
    $checksum = PixelChecksum(36, 102, 38, 104);waits for popup to go away
While $checksum = PixelChecksum(36, 102, 38, 104);popup is gone and resumes script
Wend
EndIf;resuming actions where left off

So instead of having lets say for example:

Sleep(100);first action being done
$coord99 = PixelSearch( 36, 102, 38, 104, 16777215 );Color of popup
If Not @error Then
    $checksum = PixelChecksum(36, 102, 38, 104);waits for popup to go away
While $checksum = PixelChecksum(36, 102, 38, 104);popup is gone and resumes script
Wend
EndIf;resuming actions where left off
Send("BLAH");second action being done
$coord99 = PixelSearch( 36, 102, 38, 104, 16777215 );Color of popup
If Not @error Then
    $checksum = PixelChecksum(36, 102, 38, 104);waits for popup to go away
While $checksum = PixelChecksum(36, 102, 38, 104);popup is gone and resumes script
Wend
EndIf;resuming actions where left off

I want to be able to have this piece of code only once in my script but be executed after every line of code, instead of manually adding it after every line.

$coord99 = PixelSearch( 36, 102, 38, 104, 16777215 );Color of popup
If Not @error Then
    $checksum = PixelChecksum(36, 102, 38, 104);waits for popup to go away
While $checksum = PixelChecksum(36, 102, 38, 104);popup is gone and resumes script
Wend
EndIf;resuming actions where left off

If its possible could you tell me the method and how to do it or even better just use my "sleep and "blah" example with the code being implemented.

Link to comment
Share on other sites

Make it into a function and call that every time:

Sleep(100);first action being done

myfuncc()

Send("BLAH");second action being done

myfuncc()

Func myfuncc()

$coord99 = PixelSearch( 36, 102, 38, 104, 16777215 );Color of popup

If Not @error Then

$checksum = PixelChecksum(36, 102, 38, 104);waits for popup to go away

While $checksum = PixelChecksum(36, 102, 38, 104);popup is gone and resumes script

Wend

EndIf;resuming actions where left off

EndFunc

s!mpL3 LAN Messenger

Current version 2.9.9.1 [04/07/2019]

s!mpL3 LAN Messenger.zip

s!mpL3

Link to comment
Share on other sites

Make it into a function and call that every time:

Sleep(100);first action being done

myfuncc()

Send("BLAH");second action being done

myfuncc()

Func myfuncc()

$coord99 = PixelSearch( 36, 102, 38, 104, 16777215 );Color of popup

If Not @error Then

$checksum = PixelChecksum(36, 102, 38, 104);waits for popup to go away

While $checksum = PixelChecksum(36, 102, 38, 104);popup is gone and resumes script

Wend

EndIf;resuming actions where left off

EndFunc

Even better, make it into a function and the run it regularly with AdLibEnable() (Prod), or AdLibRegister() (Beta).

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Make it into a function and call that every time:

Sleep(100);first action being done

myfuncc()

Send("BLAH");second action being done

myfuncc()

Func myfuncc()

$coord99 = PixelSearch( 36, 102, 38, 104, 16777215 );Color of popup

If Not @error Then

$checksum = PixelChecksum(36, 102, 38, 104);waits for popup to go away

While $checksum = PixelChecksum(36, 102, 38, 104);popup is gone and resumes script

Wend

EndIf;resuming actions where left off

EndFunc

Thanks for the quick reply so I will just have to add myfuncc() after every line? I will use this method unless there is a better way that is less tedious than manually adding a line of code after every line. Thank you for your help. Regarding Psalty's method I would just add
AdlibEnable("myfuncc")
to the start of the code correct? Edited by phearme
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...