need help to make reminder

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
neosickle
Posts: 42
Joined: 01 May 2016, 14:02

need help to make reminder

01 May 2016, 14:36

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:
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: need help to make reminder

01 May 2016, 15:22

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.
Asmodeus
Posts: 57
Joined: 19 Oct 2015, 15:53

Re: need help to make reminder

01 May 2016, 15:30

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
Last edited by Asmodeus on 01 May 2016, 16:05, edited 1 time in total.
neosickle
Posts: 42
Joined: 01 May 2016, 14:02

Re: need help to make reminder

01 May 2016, 16:00

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.
neosickle
Posts: 42
Joined: 01 May 2016, 14:02

Re: need help to make reminder

01 May 2016, 16:03

Hi Asmodeus. Is the script continuous? won't it stop? i need the script to always remind me till i exit the script.
neosickle
Posts: 42
Joined: 01 May 2016, 14:02

Re: need help to make reminder

01 May 2016, 16:06

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.
Asmodeus
Posts: 57
Joined: 19 Oct 2015, 15:53

Re: need help to make reminder

01 May 2016, 16:10

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.
neosickle
Posts: 42
Joined: 01 May 2016, 14:02

Re: need help to make reminder

01 May 2016, 16:36

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.
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: need help to make reminder

01 May 2016, 16:50

You may want to opt for a GUI instead.
neosickle
Posts: 42
Joined: 01 May 2016, 14:02

Re: need help to make reminder

01 May 2016, 17:21

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
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: need help to make reminder

01 May 2016, 17:27

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.
neosickle
Posts: 42
Joined: 01 May 2016, 14:02

Re: need help to make reminder

01 May 2016, 17:40

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?
neosickle
Posts: 42
Joined: 01 May 2016, 14:02

Re: need help to make reminder

01 May 2016, 20:54

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
neosickle
Posts: 42
Joined: 01 May 2016, 14:02

Re: need help to make reminder

01 May 2016, 22:53

I need some help even from other members...
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: need help to make reminder

01 May 2016, 23:15

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.
neosickle
Posts: 42
Joined: 01 May 2016, 14:02

Re: need help to make reminder

02 May 2016, 06:30

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.
neosickle
Posts: 42
Joined: 01 May 2016, 14:02

Re: need help to make reminder

02 May 2016, 06:43

Anybody wants to help me?
User avatar
jmeneses
Posts: 524
Joined: 28 Oct 2014, 11:09
Location: Catalan Republic

Re: need help to make reminder

02 May 2016, 08:10

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

Donec Perficiam
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: need help to make reminder

02 May 2016, 10:00

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.
neosickle
Posts: 42
Joined: 01 May 2016, 14:02

Re: need help to make reminder

02 May 2016, 19:24

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.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], masheen, mikeyww and 161 guests