phearme Posted June 29, 2009 Share Posted June 29, 2009 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 More sharing options...
AoRaToS Posted June 29, 2009 Share Posted June 29, 2009 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 More sharing options...
PsaltyDS Posted June 29, 2009 Share Posted June 29, 2009 Make it into a function and call that every time:Sleep(100);first action being donemyfuncc()Send("BLAH");second action being donemyfuncc()Func myfuncc()$coord99 = PixelSearch( 36, 102, 38, 104, 16777215 );Color of popupIf Not @error Then $checksum = PixelChecksum(36, 102, 38, 104);waits for popup to go awayWhile $checksum = PixelChecksum(36, 102, 38, 104);popup is gone and resumes scriptWendEndIf;resuming actions where left offEndFuncEven 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 More sharing options...
phearme Posted June 29, 2009 Author Share Posted June 29, 2009 (edited) 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 EndFuncThanks 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 June 29, 2009 by phearme Link to comment Share on other sites More sharing options...
AoRaToS Posted June 29, 2009 Share Posted June 29, 2009 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.9.1 [04/07/2019] s!mpL3 LAN Messenger.zip s!mpL3 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now