AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How accurate is Sleep? / Name, time of XP "Scheduled Ta

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Robert Carnegie



Joined: 01 Jun 2005
Posts: 53
Location: Scotland

PostPosted: Tue Aug 09, 2005 1:21 am    Post subject: How accurate is Sleep? / Name, time of XP "Scheduled Ta Reply with quote

Mostly as reassurance, how accurate is the Sleep command in millisecconds? I see AHk Help bills it as accurate to 10 milliseconds and at risk of overrunning "if the CPU is under load", which is probably okay.

I decided to reprogram my crazy PC video/radio software - it has to spend a full minute closing and reopening the application from Windows Scheduled Tasks to change one recording to another, which is not good if you want to catch two shows that run consecutively - so today's new plan was to write little AHk scripts to press various buttons in the application, such as the bottom left Record start/stop button:
Code:

#SingleInstance off

Sleep, %1%

IfWinExist, DigitalTV-t - DEC2000/3000
{
    WinActivate
    WinGetPos,        dtvX, dtvY,          dtvWidth, dtvHeight
    MouseClick, Left, 24,   dtvHeight-54,  1, 0
}
else
    return


- and to put /that/ into Scheduled Tasks with minute-accurate precision and a parameter setting a time in seconds. So to stop and then start, I'd tell Scheduled Tasks to run this program twice, setting the second MouseClick event two seconds after the first.

But then I thought, "D'oh! If I want to record a 30 minutes show, I should write an AHk script that takes... say minutes and seconds as parameters, and punches Record start, waits while the show plays, and punches Record stop."

Only I'm anxious that I'd get a recording with length 30 minutes 2 seconds, or 29 minutes 50, or 20 minutes...

I suppose wait for exact-time-of-day may be do-able in a script, but I haven't gotten to grips with timer commands. Currently I'm still looking at starting these events from Windows Scheduled Tasks, which has a fairly nice event editor... well, useable, anyway.

As an issue related to my project but not to AHk specifically, I'm curious whether an AHk script, a shell command file, or any other kind of program can reliably tell that it's been run as a Scheduled Task, and what the Task start time and name are. See, tasks are listed by name, or by time, or whatever; so currently I have in mind tasks that run once (but that hang around so I can set them to run again) with names like "0...0400,00 Hauppauge record (stop)" "0...0400,02 Hauppauge record (start)", which should mean "Press the Record button at 04:00:00" and "Press the Record button again at 04:00:02". This keeps them organised. But in fact I have to set the correct time separately from the name, and also insert a command that does what the name says - such as (this refers to the script above, compiled)
Code:

"C:\Program Files\Utils\Haup_Timed_Record.exe" 2000

(Set to run at 04:00:00 - Scheduled Tasks apparently won't do seconds - and to wait for 2 full seconds before doing its thing.)

It would be nice if the script could obtain its own Scheduled Tasks name and work out some of what it's supposed to do from it. Then I could edit task names as necessary and use an identical command inside each one.
Back to top
View user's profile Send private message Send e-mail
Robert Carnegie



Joined: 01 Jun 2005
Posts: 53
Location: Scotland

PostPosted: Fri Aug 12, 2005 12:09 am    Post subject: Well, this is annoying (not AutoHotkey problem?) Reply with quote

Some of my Windows Scheduled Tasks apparently decide that they don't want to run. Simple and annoying. The run time sits there even though it isn't a future date any more. I wanted to record one show from 07:28 to 08:03 and another 08:28 to 09:03; at 08:50, I find I've got a recording from 07:28 still running.

If I change the time on the Tasks to near-future times and wait, they run okay.

I have the latest Windows XP patch, and... hmm, AutoHotkey 1.37.0.2. That's not the latest, but I don't see anything in change log that would bear on this. Anyway, Windows seems not to be attempting to run the programs at all.

Nothing in Web pages for Windows stands out, but having about 200 tasks in the library, new and old, might be a problem. I don't need all of those; most are previous attempts to program the same video/radio software. I just didn't want to clear them out until the new program was working reliably. Heigh ho.

Mainly, it looks like I'm forced at least to do what I was considering, write an AHk program to start a recording, wait, and stop a recording - instead of having separate Scheduled Tasks to start and stop. Alternatively, I find out about AHk timer implementation and move most or all of the thing over to AHk. Possibly tricky.

On the plus side, if I throw out Windows Scheduled Tasks, then I don't have to worry about getting Scheduled Tasks names into AHk. Maybe I can encode values into multiple copies (or multiple shortcuts) to the same AHk script that does the work?
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group