Page 1 of 2

need help to make reminder

Posted: 01 May 2016, 14:36
by neosickle
pls help me i want to make a reminder every 20 minutes of the clock not a countdown like example 10:20pm, 10:40pm, 11:00pm and so on, a message box will pop up. can someone pls help me? :dance: :wave:

Re: need help to make reminder

Posted: 01 May 2016, 15:22
by Exaskryz
The simplest way:

Code: Select all

#Persistent
SetTimer, Reminder, % 20*60*1000 ; 1000 milliseconds to a second, 60 seconds to a minute, 20 minutes
return

Reminder:
MsgBox Hi
return
The issue with the above is you'd have to manually launch it when you want a message to appear for it to be synchronized.

The slightly more difficult way that doesn't need manual launching at the time you would want a message to appear:

Code: Select all

#Persistent
SetTimer, Reminder,  % -1 * (Mod(A_Min,20)*60000 - A_Sec*1000) ; The negative from the -1 means to run this timer only once
; It's 10:30:35, we need a timer of 9:25. The Mod(30,20) gives us a remainder of 10 minutes, multiplied into milliseconds. We also want to subtract 35 seconds off to hit the target 9:25, and converted that to milliseconds as well.
return

Reminder:
SetTimer, Reminder, % -1 * (Mod(A_Min,20)*60000 - A_Sec*1000) ; can be used instead of 20*60*1000 for repeating just in case something happens and it desyncs, this will resync it
MsgBox Hi
return
I might be wrong on the maths in the second one though.

Re: need help to make reminder

Posted: 01 May 2016, 15:30
by Asmodeus
yeah, I'm a little bit late, but maybe you like my solution: :wave:

Code: Select all

#Persistent

SetTimer, CheckTime, 60000

CheckTime:
	FormatTime, TimeString,, mm
	If (TimeString = 00 ) Or (TimeString = 20) Or (TimeString = 40)
	{
		MsgBox Your time has come! :)
	}
return
kissed by the muse, I came up with simpler version. enjoy! :beer:

Code: Select all

#Persistent
 
SetTimer, CheckTime, 60000

CheckTime:
If (A_Min = 00) OR (A_Min = 20) OR (A_Min = 40)
		MsgBox This time, for sure!
Return

Re: need help to make reminder

Posted: 01 May 2016, 16:00
by neosickle
Thank you for the reply. As is I see in the posts, I think Asmodeus gave the solution. But i'll test it and give a feedback.

Re: need help to make reminder

Posted: 01 May 2016, 16:03
by neosickle
Hi Asmodeus. Is the script continuous? won't it stop? i need the script to always remind me till i exit the script.

Re: need help to make reminder

Posted: 01 May 2016, 16:06
by neosickle
Exaskryz wrote:The simplest way:

Code: Select all

#Persistent
SetTimer, Reminder, % 20*60*1000 ; 1000 milliseconds to a second, 60 seconds to a minute, 20 minutes
return

Reminder:
MsgBox Hi
return
The issue with the above is you'd have to manually launch it when you want a message to appear for it to be synchronized.

The slightly more difficult way that doesn't need manual launching at the time you would want a message to appear:

Code: Select all

#Persistent
SetTimer, Reminder,  % -1 * (Mod(A_Min,20)*60000 - A_Sec*1000) ; The negative from the -1 means to run this timer only once
; It's 10:30:35, we need a timer of 9:25. The Mod(30,20) gives us a remainder of 10 minutes, multiplied into milliseconds. We also want to subtract 35 seconds off to hit the target 9:25, and converted that to milliseconds as well.
return

Reminder:
SetTimer, Reminder, % -1 * (Mod(A_Min,20)*60000 - A_Sec*1000) ; can be used instead of 20*60*1000 for repeating just in case something happens and it desyncs, this will resync it
MsgBox Hi
return
I might be wrong on the maths in the second one though.
i'll try this one too. I don't want to waste your effort helping me. Tahnk you. I'll give feedback.

Re: need help to make reminder

Posted: 01 May 2016, 16:10
by Asmodeus
neosickle wrote:Hi Asmodeus. Is the script continuous? won't it stop? i need the script to always remind me till i exit the script.
I will work forever until you kill the process or someone suspends the process or you turn off your computer or ah you get the point. :D
This is because of the #Persistent directive. Click on it in the code section to open the corresponding help file.

Re: need help to make reminder

Posted: 01 May 2016, 16:36
by neosickle
Thank you Asmodeus. It works as i wanted. What if I want to change the size of the message box? I want to make the box smaller. The alert box was spacious, i don't like it.

Re: need help to make reminder

Posted: 01 May 2016, 16:50
by Exaskryz
You may want to opt for a GUI instead.

Re: need help to make reminder

Posted: 01 May 2016, 17:21
by neosickle
Exaskryz wrote:You may want to opt for a GUI instead.
This is the script that I chosen. How can i opt a Gui here and where will i put it? Im sorry for asking but im really noob here. All i know is the send command. Can you pls guide me?

Code: Select all

#Persistent
 
SetTimer, CheckTime, 60000
 
CheckTime:
If (A_Min = 00) OR (A_Min = 20) OR (A_Min = 40)
		MsgBox This time, for sure!
Return

Re: need help to make reminder

Posted: 01 May 2016, 17:27
by Exaskryz
Instead of the MsgBox, I would use just a Gui, Show. It'll come together in a moment.

In the auto-execute section, you would create the GUI. Using Gui, Add, Text,,Your Message should suffice. Then as you want to customize it, you can read through the Gui docs.

Re: need help to make reminder

Posted: 01 May 2016, 17:40
by neosickle
I had a glance in gui docs. I want the gui to be simply small, centered, word wrapped, and always on top when it showed. Can you help me Exaskryz? Can you pls help me with the code?

Re: need help to make reminder

Posted: 01 May 2016, 20:54
by neosickle
Exaskryz wrote:Instead of the MsgBox, I would use just a Gui, Show. It'll come together in a moment.

In the auto-execute section, you would create the GUI. Using Gui, Add, Text,,Your Message should suffice. Then as you want to customize it, you can read through the Gui docs.
I tried to put gui in the script. I also put ok button into it. The size of the gui is perfect than msgbox gives for me. But the problem is when i execute the script it displays the message instantly, the gui must appear only as i indicated in my script and when i press the ok button nothing happens. It must close the window after pressing ok. Pls help. Here's what i have done.

Code: Select all


#Persistent
 


SetTimer, CheckTime, 60000
 


CheckTime:

If (A_Min = 00) OR (A_Min = 20) OR (A_Min = 40)
		
		Gui +AlwaysOnTop
		Gui, Add, Text, Center, Audit na!
		Gui, Add, Button, Default, OK
		Gui, Show
Return

Re: need help to make reminder

Posted: 01 May 2016, 22:53
by neosickle
I need some help even from other members...

Re: need help to make reminder

Posted: 01 May 2016, 23:15
by wolf_II
Try this:

Code: Select all

Gui +AlwaysOnTop
Gui, Add, Text, Center, Audit na!
Gui, Add, Button, Default, OK
SetTimer, CheckTime, 1000

CheckTime:
    If (A_Min = 00) OR (A_Min = 20) OR (A_Min = 40)
		Gui, Show
Return

ButtonOK:
    Gui, Hide
Return
I hope that helps.

Re: need help to make reminder

Posted: 02 May 2016, 06:30
by neosickle
wolf_II wrote:Try this:

Code: Select all

Gui +AlwaysOnTop
Gui, Add, Text, Center, Audit na!
Gui, Add, Button, Default, OK
SetTimer, CheckTime, 1000

CheckTime:
    If (A_Min = 00) OR (A_Min = 20) OR (A_Min = 40)
		Gui, Show
Return

ButtonOK:
    Gui, Hide
Return
I hope that helps.
It did not solve my problem, wolf. Nothing shows after hitting time in the clock. Pls help.

Re: need help to make reminder

Posted: 02 May 2016, 06:43
by neosickle
Anybody wants to help me?

Re: need help to make reminder

Posted: 02 May 2016, 08:10
by jmeneses

Code: Select all

#NoEnv
#SingleInstance force
#Persistent

Gui +AlwaysOnTop -Caption
Gui, Add, Text, Center, Audit na!
Gui, Add, Button, Default, OK
SetTimer, CheckTime, 1000        
oTime := A_Min
Return

CheckTime:
If (oTime < A_min) && ((A_Min = 00) OR (A_Min = 20) OR (A_Min = 40)){
    oTime := A_min
    Gui, Show
}
Return
 
ButtonOK:
Gui, Hide
Return


Re: need help to make reminder

Posted: 02 May 2016, 10:00
by Exaskryz
neosickle wrote:
I tried to put gui in the script. I also put ok button into it. The size of the gui is perfect than msgbox gives for me. But the problem is when i execute the script it displays the message instantly, the gui must appear only as i indicated in my script and when i press the ok button nothing happens. It must close the window after pressing ok. Pls help. Here's what i have done.

Code: Select all


#Persistent
 


SetTimer, CheckTime, 60000
 


CheckTime:

If (A_Min = 00) OR (A_Min = 20) OR (A_Min = 40)
		
		Gui +AlwaysOnTop
		Gui, Add, Text, Center, Audit na!
		Gui, Add, Button, Default, OK
		Gui, Show
Return
The MsgBox was appearing like that because you didn't put a Block with the If statement. Use of { and } are necessary if you want more than one line to be executed only when the if statement is true.

However, you may find this is a bit problematic, because it will add the Text and Button controls repeatedly. While technically you have this in the auto-execute section, I'd suggest moving it above the label. I suggest having only the Gui, Show associated with the If statement - you also won't need a Block in that situation.

Now, that suggestion I have is what wolf's code demonstrates. It should be working; I see no reason it shouldn't be. It would be problematic though because it will actually be checking too frequently; wolf changed his timer to 1000 instead of 60000, which means that the GUI may reappear within the exact same minute after you dismiss it. So I'd suggest he put the timer back on 60000.

I executed wolf's code, and that's the behavior I got actually. A GUI that kept showing itself. With the timer on 60000 (or using the maths I originally suggested), you could have that problem resolved.

Re: need help to make reminder

Posted: 02 May 2016, 19:24
by neosickle
wolf_II wrote:Try this:

Code: Select all

Gui +AlwaysOnTop
Gui, Add, Text, Center, Audit na!
Gui, Add, Button, Default, OK
SetTimer, CheckTime, 1000

CheckTime:
    If (A_Min = 00) OR (A_Min = 20) OR (A_Min = 40)
		Gui, Show
Return

ButtonOK:
    Gui, Hide
Return
I hope that helps.
Thanks wolf for the script. It did solve my prob. Ill just have to change the timer. Thank you very much.