Jump to content
Sfikes

If Time = x Then ...

Recommended Posts

Sfikes

Hey i have a problem!

This script will activate once the time is 22:05:00 and send a message.
 

#include <Date.au3>


While 1

If _NowTime(5) = "22:05:00" Then
       Send("Hell yea!")
       ExitLoop
EndIf

WEnd


Whenever i try to run my code it doesn't go like it should. It never sends a "Hell Yea" when the time have passed. So i have no idea how to fix this.

Share this post


Link to post
Share on other sites
AutoBert

try

If _NowTime(5) >= "22:05:00" Then

as you have a exitloop it will only be send once nearby 22:05:00. I suggest: put also a sleep(10) in your loop.

Edited by AutoBert

Share this post


Link to post
Share on other sites
orbs

the condition is correct, and a 1s time window should be sufficient to trap the time. the likely cause is that when the time is reached, you have no input field in focus, so you do not see the keys sent.

 

Share this post


Link to post
Share on other sites
spudw2k

You also might want to consider using Scheduled Tasks instead if allowed in your environment.  The advantage of doing so is you don't have to have a resident process (your script) tracking the time, but rather pass that task/responsibility to the OS.  Depends on what you are looking to accomplish I guess....

Share this post


Link to post
Share on other sites
weirddave

Are you certain the message isn't being sent, what window is active at 22:05:00 ? (Where is the send() sending the message)

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

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.