Jump to content

how to run some file every 30 sec


boy15
 Share

Recommended Posts

Which is it, 30 seconds, or 15 seconds? O.o

Anyways, :)

For the delay / timing, look up the sleep and timerdiff functions in the help file.
For the repeating, look up the do and while loop statements in the help file.  

Let us know what questions you have.

Link to comment
Share on other sites

  • Developers
50 minutes ago, boy15 said:

there is wrong in script

can any one correct script

You seriously have no clue what is going wrong in this script?  Check your process explorer and see how many anyname.bat files are running!

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

  • Developers

So read the script code and try to understand what it does and why it is running your script endless times!
You should be able to figure this out yourself.

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

2 hours ago, boy15 said:

but when I use script, it open many windows for same batch

 

2 hours ago, Jos said:

You should be able to figure this out yourself. 

@boy15 : Therefore, no ready-made solution is provided, but only a simulation to analyze the problem ;).

; Original :
;~ While 1
;~     While fileExists(@ScriptDir&"\anyname.bat")
;~         run(@ScriptDir&"\anyname.bat")
;~     WEnd
;~     Sleep(30000)
;~ WEnd

; Simulation :
HotKeySet("{ESC}", "_ExitNow") ; *** just to have an option to quit

Global $g_sFilename = @ScriptDir & "\anyname.bat"

While 1 ; Loop 1
    While FileExists($g_sFilename) ; Loop 2
        ConsoleWrite("> --> Loop 2 : RUN " & $g_sFilename & "   ...press ESC to Exit" & @CRLF)
        Sleep(500) ;  *** just to slow it down
    WEnd

    ConsoleWrite("+ ==> Loop 1  ...press ESC to Exit" & @CRLF)
    Sleep(1000) ; *** reduced for testing purposes
WEnd

Func _ExitNow()
    ConsoleWrite("! the script was terminated by the user." & @CRLF)
    Exit
EndFunc   ;==>_ExitNow

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

4 hours ago, Musashi said:

 

@boy15 : Therefore, no ready-made solution is provided, but only a simulation to analyze the problem ;).

; Original :
;~ While 1
;~     While fileExists(@ScriptDir&"\anyname.bat")
;~         run(@ScriptDir&"\anyname.bat")
;~     WEnd
;~     Sleep(30000)
;~ WEnd

; Simulation :
HotKeySet("{ESC}", "_ExitNow") ; *** just to have an option to quit

Global $g_sFilename = @ScriptDir & "\anyname.bat"

While 1 ; Loop 1
    While FileExists($g_sFilename) ; Loop 2
        ConsoleWrite("> --> Loop 2 : RUN " & $g_sFilename & "   ...press ESC to Exit" & @CRLF)
        Sleep(500) ;  *** just to slow it down
    WEnd

    ConsoleWrite("+ ==> Loop 1  ...press ESC to Exit" & @CRLF)
    Sleep(1000) ; *** reduced for testing purposes
WEnd

Func _ExitNow()
    ConsoleWrite("! the script was terminated by the user." & @CRLF)
    Exit
EndFunc   ;==>_ExitNow

 

:wacko2:

not work your script

Link to comment
Share on other sites

  • Developers
6 hours ago, boy15 said:

:wacko2:

not work your script

What about you kick your own brains in gear and think about what I said instead of blaming others?

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

7 hours ago, boy15 said:

:wacko2:

not work your script

The script works for the purpose it was made for (not to spoon-feed you).

11 hours ago, Musashi said:

(it is) only a simulation to analyze the problem.

Which part of the sentence do you not understand ? So stop playing with Emojies and start analyzing. There is e.g. no need to run the batch file to find out the flaws in your construct.

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

20 hours ago, boy15 said:

I have one batch file

If I run it manually it opens one time

but when I use script, it open many windows for same batch

When you write a Autoit script, that will run an external BATCH file every 30 seconds, ist simply WAD, that every 30 seconds a new instance of the BATCH file is started, each one opening a Independent, separate Window.

 

What else do you expect?

 

And, basically, what are you trying to achive? It might be helpful to explain what you Need to do. Possibly the BAT file isn't really necessary and doing everything withing AUTOIT is the better Approach...

 

 

Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

  • Developers

@rudi, Have a closer look at the script the OP posted. It will shell endless versions of the bachtfile when it exists for as long as the computer  doesn't hang itself. ;) 

This is an indicator the OP doesn't have the foggiest clue what the script does and I am trying to encourage the OP to think and understand it first.

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

  • Developers

Guess you didn't scroll back far enough. this is what the OP posted before somebody else started to pollute the thread with other code: 

  There's clearly a big OOPS in there. ;) 

Edited by 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

7 minutes ago, Jos said:

... before somebody else started to pollute the thread with other code:

I hope you don't mean my contribution. I just wanted to make the OP aware of the problem with the endless running While-Loops. A ready-made solution would have undermined your advice : " So read the script code and try to understand what it does and why it is running your script endless times! " ;).

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

  • Developers
1 minute ago, Musashi said:

I hope you don't mean my contribution.

Yes I did and was just playing a little... ;)
Understood what you were trying but, as you saw, it only confused the OP and diverted the attention from his own script to your script. 

.. but feel free to contribute anytime you feel you can help! :) 

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

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