Jump to content

Wait until clock time


 Share

Recommended Posts

I know this has been asked ;) , but not able to find it - not good at searching this site :) .

I need to have an application go to a SQL database but need it to only go at a specific time each hour. Not sure how to do this and would appreciate any help/advice/examples.

Thanks

F

Link to comment
Share on other sites

Have you written a basic script that will do ANYTHING at a specific time each hour (maybe just pop a MsgBox())? Did you want to use a script running all the time or a Scheduled Task?

Have you written a basic script to make any access at all to an SQL database? Do you know anything about ADODB, or do you want to use a command line, like OSQL.exe?

Hard to tell exactly which part you want help with. And of course we're not going to write it for you.

:)

Well, maybe kaotkbliss will...

;)

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

Something like?

While 1
If @min=30 Then;any hour at the 30 minute mark
_somefunc() ; go to some function to do stuff
Else
Sleep(10);pause for 10 miliseconds
EndIf
Wend

Func _somefunc()
;do whatever you need the program to do
EndFunc

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

PSaltyDS - yes, I don't expect you to write my app ;) . I just could not figure out how to make this work using the same minute each hour. Yes, I have the ADODB stuff but just needed to trigger the time.

kaotkbliss - did not even look at @min in help :) . Tried datediff but, well, could not figure it out using that. Thanks for the guidance to the @min.

F

Link to comment
Share on other sites

  • 10 months later...

While 1 is an infinate loop.

What you have given says if @min is not 15 then sleep, but you don't tell it what to do if @min does =15

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

So if it is 15 it does nothing...

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

you did not put anything to happend when the time is correct

While 1 (Loop) is there to keep the script alive

While 1
    If @min = 33 then
        MsgBox(0,"",@HOUR&"h "&@MIN&"m "&@SEC&"s",10)
        Do
            Sleep(10)
        Until @min <> 33
    Endif
    Sleep(10)
Wend

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

No, you need to put your code "msgbox" instead "sleep(1000)" place and remove ;Not; statment in ;If then;

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Or:

While 1 
If not @min = 15 then 
Sleep (1000) 
Else
Msgbox (0,"Test", @min)
Endif
Wend

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

I probably coudnt explain what i am looking for.

I have a script that needs to be sleeping until a certain time. lets say 10:15.

Start Notepad.exe
wait untill 10:15

give txt a name and close notepad.
Link to comment
Share on other sites

While 1;the infinite loop to keep the script alive
    If @HOUR = 10 And @min = 15 then; if the minute counter is on 15 and H counter is on 10
        MsgBox(0,"",@HOUR&"h "&@MIN&"m "&@SEC&"s",10);msgbox to see that is working, msgbox will automaticly close after 10 seconds
        Do
            Sleep(10)
        Until @min <> 15; sleep untill minute counter is diffrent than 15, this alow you to activate your code only once on specific H time when it hit 15 minutes
    Endif
    Sleep(10);sleep 10 to reduce cpu usage
Wend

so whats wrong with this?

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Alfa, take bogQ's code and rewrite it to your needs.

We can't do everything for you!

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

Alfa, take bogQ's code and rewrite it to your needs.

We can't do everything for you!

Thats what i am trying. And i actually didnt ask you to do everything for me. I am asking a way to do something so can use it everytime i need it.

thanks bogQ for your efforts but i cant make it work. There is probably something i dont understand about this while 1 loop. Does all of the code have to be done in the loop ?

Edited by alfa
Link to comment
Share on other sites

while loop is a circle that keep the script looping the code all the time

loops can b

best choice for infinite loop

while $something

wend

run code 10 times

for $x = 1 to 10

next

run code untill something changes

do

something()

until $something = $something_else

If sityations where you dont have loop, your script will run your code only once and then exit

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

and rewrite it to your needs.

Your sure. That's usually the part where the problems arise. :)

---

Oops.

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

I use something like this to create log files each day

Run("Notepad.exe C:\Log " & @YEAR & @MON & @MDAY & ".txt")
Sleep(500)
If WinExists("Notepad", "") Then
    ControlClick("Notepad", "&Yes", "[CLASS:Button;INSTANCE:1]", "LEFT", 1)
EndIf

And what it does is it tries to open the txt file but if it doesn't exist, it creates it.

You can use this to create and name your txt file in the beginning, then add text to it later.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

Thats what i am trying. And i actually didnt ask you to do everything for me. I am asking a way to do something so can use it everytime i need it.

You're asking for us to write something you can use.

I can't see any effort on your part, so if you are trying post what you got.

Your sure. That's usually the part where the problems arise. :)

---

Oops.

What do you mean?

If he gets problems he can post the code and we can help.

But we can't help unless he does an effort for the code to work.

Edited by Maffe811

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

What do you mean?

If he gets problems he can post the code and we can help.

True.

But we can't help unless he does an effort for the code to work.

@general: I generally feel that the same effort applies to at least reading the doc/manual on the subjects/commands at hand.

(should also make is easier for needed party (basic newbies) to explain what it is they don't get when they do so in relation to the AutoIt documentation.)

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

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