Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Run a script automatically at a certain time


  • Please log in to reply
8 replies to this topic
Niri
  • Guests
  • Last active:
  • Joined: --
HI

I have found tremendous info on this site about scripts and find them amazing. i have the script working but i would like it to be scheduled at 6pm every evening. it is to drop the volume on the computer and then up it again at 6 in the morning. Any ideas? i'm still searching for an answer but if someone knows please email me at [email protected]

Thanks a million

garath
  • Members
  • 398 posts
  • Last active: Feb 05 2011 10:31 PM
  • Joined: 24 Mar 2005
Try this one:

Gui, Add, DateTime, 1 vMyStartTime , 'DayStartTime:' HH:mm:ss 
Gui, Add, DateTime, 1 vMystopTime , 'DayStopTime:' HH:mm:ss 
Gui, add, text,section, Day-Volume  [`%]
Gui, add, text,, Night-Volume [`%]
Gui, add, edit,ys vDayVolume, 80
Gui, add, edit, vNightVolume, 20
Gui, add, button, section gStart, Start 
gui, show
return


;********this part of the skript starts by pressig the button. Read about gui´s and g-label**************
Start:
Gui, submit, nohide								   ; get the info from the gui, and don`t hide it
Stringright, MyStartTime, MyStartTime, 6		;We get a Timecode with the Format YYYYMMDDHH24MISS
Stringright, MyStopTime, MyStopTime, 6 	 	; back from the 2 DateTimecontrols, wie need to drop YYYYMMDD
																; Stringright gets only the 6 chars from thr right side

setTimer, CheckVolume, 1000			; Start the Part CheckVolume each second once
return



;*********this is the next part, started each second by setTimer, CheckVolume, 1000*****************
CheckVolume:
Stringright, Acual_Time, A_now, 6			; again a long timecode, we have to shorten
						; the System_variable A_now contains the Actual time

if (MyStartTime <  Acual_Time  and  Acual_Time < MyStopTime)
{
	SoundSet, %DayVolume%  ; Set the master volume to vDayVolume%
	tooltip, high Volume
}
else
{
	SoundSet, %NightVolume%  ; Set the master volume to vNightVolume%
	tooltip, low Volume
}
return

;***********************************************************************************************************
you only have to adjust the math a bit

moodleyn
  • Guests
  • Last active:
  • Joined: --
HI Garath

Thank you so much. i tried it and it works perfectly. So does it mean i can use the similar code for any types of scripts that need to be timed?

Thanks i learnt alot from your code. I appreciate you time.

Kind Regards,
NIRI

moodleyn
  • Guests
  • Last active:
  • Joined: --
Garath

I just want to ask something. the GUI allows the times and percentages to be changed via the interface. But i see there are 6's in the software. Does it mean it that at 6pm it will drop the volume even though i've set the time to 9pm manually?

Thanks,
NIRI

garath
  • Members
  • 398 posts
  • Last active: Feb 05 2011 10:31 PM
  • Joined: 24 Mar 2005
I changed the description in the script. I hope, you can understand it, now.
One remaining problem is the situation
Starttime 22:00
Endtime 5:00

now the Timer won`t work like intended

You need to change the math, for situations Startime > Endtime
but for situations EndTime > Starttime it will work :wink:

df
  • Members
  • 13 posts
  • Last active: Mar 04 2006 06:55 PM
  • Joined: 30 Jul 2005
Could you not just set the time length of the script and activate it with scheduled task manager on a timed daily basis?

garath
  • Members
  • 398 posts
  • Last active: Feb 05 2011 10:31 PM
  • Joined: 24 Mar 2005
I could, but I like standalone solutions, hihi
But you could explain niki the usage of the scheduled task manager, sorry, I never used it :?

moodleyn
  • Guests
  • Last active:
  • Joined: --
HI

Initially before i posted on this forum, i did get the application to start in Scheduled Tasks, but it still required intervention(shortcut keys) to put the sound up and down.

WIth Garaths software, you set the time of up and down. How can i get the script then to run with scheduled tasks?

That is very interesting.

garath
  • Members
  • 398 posts
  • Last active: Feb 05 2011 10:31 PM
  • Joined: 24 Mar 2005
If you use the scheduled tasks, build 2 ahk-scripts, one for day, and one for night.
first script for Day
SoundSet, 100     ;Day-volume is 100%
second script for night
SoundSet, 40    ;Night-volume is 40%
So you have two scripts, which could be used by scheduled tasks