Jump to content

Script restart after time


Recommended Posts

Hello, i just created an account but i read a lot in this forum.

I digged some posts but i cannot find an answer that fits my script (or i cannot make it fit, which is the most probable answer).

 

I used AdlibRegister to close a program every 15 minutes, and i also need to restart the script  because i have many lines of code and if i end the process in the middle of a while inside the script it will never start from the begining of the main loop (which has all the lines)

 

AdlibRegister('close', time) ; 15 minutes = time 


Func close()
       If ProcessExists("Process.exe") Then
        ProcessClose("Process.exe")
       EndIf
       
EndFunc

While 1

;over 300 lines of code, if the process ends in the middle of a while it gets stuck there

Wend

So i was thinking about putting in the end of the close func a "script restart" so it would end the script when the func close is called (after 15 minutes) and it would start again from while 1, but i dont figure how can i do that.

 

Its my first post so if you need more information or the way im thinking about is wrong please tell me im learning! c:

Link to comment
Share on other sites

Sorry if this is spam, i dont know if i can edit forum posts  (i don't see the option) but i forgot to say that i tried making some kind of goto inside the close func that goes to the while 1, but as i read in the forum this doesnt exists and i cannot implement it well enough.
 

Link to comment
Share on other sites

  • Developers
1 minute ago, jorgenitales said:

i don't see the option

correct, that will come later when you are in the next group, so no worries. :) 

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I can't figure it out why your script gets stuck after closing another process.  But you have to know that AdLibRegister will pause your main script during the execution of the function close ().  Maybe that is why, idk.

You can also try _Timer_SetTimer instead of AdLibRegister.  If that doesn't work, you could create a two scripts, one containing your while 1 loop.  The other would contain the timer, that would close both your first script and the process.exe, and restart your first script just after.

Link to comment
Share on other sites

23 minutes ago, Nine said:

I can't figure it out why your script gets stuck after closing another process.  But you have to know that AdLibRegister will pause your main script during the execution of the function close ().  Maybe that is why, idk.

You can also try _Timer_SetTimer instead of AdLibRegister.  If that doesn't work, you could create a two scripts, one containing your while 1 loop.  The other would contain the timer, that would close both your first script and the process.exe, and restart your first script just after.

Thanks for your answer, it gets stuck (i think) because it cannot end a while loop and ends the process, for example
 

AdlibRegister('close', time) ; 15 minutes = time 


Func close()
       If ProcessExists("Process.exe") Then
        ProcessClose("Process.exe")
       EndIf
       
EndFunc

While 1 ;main loop

While $flag = True
;code if flag is true
Wend

Wend

if the 15 mins are insde the second while, the flag will be true and i cannot end that while because the process is not running anymore and still looks for the flag, so i need to get to the start main loop again.

Link to comment
Share on other sites

5 minutes ago, jorgenitales said:

Sorry for doble post again, but i tried doing 2 scripts as you said and it worked, so i will try a bit more if i can do all in 1, but i have this working, thanks.

:)

Link to comment
Share on other sites

Check restart.au3 udf i can give you if you dont find it. 

 

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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...