Jump to content
Sign in to follow this  
phearme

How to execute code after every action?

Recommended Posts

phearme

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.

Share this post


Link to post
Share on other sites
AoRaToS

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.8.8 [30/09/2015]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
phearme

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

Share this post


Link to post
Share on other sites
AoRaToS

Well if it's for something that pop's up then Adlib is better...

AdlibEnable("myfuncc")

will call it every 250ms, you can change the time like this:

AdlibEnable("myfuncc", 1000) or any other


s!mpL3 LAN Messenger

Current version 2.9.8.8 [30/09/2015]

Download Here

s!mpL3

Share this post


Link to post
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
Sign in to follow this  

×