 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
keyboardfreak
Joined: 09 Oct 2004 Posts: 216 Location: Budapest, Hungary
|
Posted: Fri Jun 26, 2009 8:05 am Post subject: Gentle nagging reminder for things you want to keep in mind |
|
|
I have a new sitting ball and I have to pay attention to my posture, so that I don't hunch forward while sitting on it.
To remind myself I created this small script which shows a reminder text on the screen at regular intervals for a few seconds not interfering with the work I'm doing, and then it silently disappears.
I used a fairly high GUI number and prefixed every variable, so you can easily add it to your main script if there is something you want to be reminded of.
A reminder can be specified in the format: text/period in minutes.
If you want multiple reminders separate them with | characters.
See the example reminders in the script.
| Code: | nagreminder_reminders = Sit up straight/30|Be happy/55
nagreminder_visible := 1000 * 10
nagreminder_width := 400
nagreminder_color = 99FF00
Gui 72: +LastFound -Caption +AlwaysOnTop +ToolWindow
Gui 72: Font, s20
Gui 72: Color, %nagreminder_color%
Gui 72: Add, Text, vNagreminder_popup_text, Placeholder so that the label has an initial size
SysGet, nagreminder, Monitor
nagreminder_schedules = 0
Loop, parse, nagreminder_reminders, |
{
StringSplit, nagreminder_fields, A_LoopField, /
nagreminder_schedules += 1
nagreminder_text_%a_index% := nagreminder_fields1
nagreminder_period_%a_index% := nagreminder_fields2
nagreminder_remaining_%a_index% := nagreminder_fields2
}
SetTimer nagreminder_check, % 1000 * 60
return
nagreminder_check:
loop %nagreminder_schedules%
{
nagreminder_remaining_%a_index% -= 1
if (nagreminder_remaining_%a_index% == 0)
{
nagreminder_show(nagreminder_text_%a_index%)
nagreminder_remaining_%a_index% := nagreminder_period_%a_index%
}
}
Return
nagreminder_show(text)
{
global
guicontrol 72:, Nagreminder_popup_text, %text%
random nagreminder_x,, % nagreminderright - nagreminder_width
random nagreminder_y,, % nagreminderbottom - 50
Gui 72: show, x%nagreminder_x% y%nagreminder_y% w%nagreminder_width% NoActivate
sleep % nagreminder_visible
Gui 72: hide
}
|
Last edited by keyboardfreak on Mon Jul 06, 2009 3:37 pm; edited 1 time in total |
|
| Back to top |
|
 |
Kohath
Joined: 28 Jun 2009 Posts: 3 Location: Australia
|
Posted: Sun Jun 28, 2009 5:50 am Post subject: Very nice! |
|
|
I really like it! It's nice in that it doesn't disrupt mouse/keyboard focus as you work on the computer, but is obvious to see. Another idea might be to make the GUI pop up randomly using Sleep, so that you don't get used to when it will pop up i.e. . |
|
| Back to top |
|
 |
keyboardfreak
Joined: 09 Oct 2004 Posts: 216 Location: Budapest, Hungary
|
Posted: Sun Jun 28, 2009 6:38 am Post subject: Re: Very nice! |
|
|
| Kohath wrote: | Another idea might be to make the GUI pop up randomly using Sleep, so that you don't get used to when it will pop up i.e. . |
I may do that if I set the popup to a shorter repeat period.
Currently, the reminder is shown every 30 minutes which is far too long for my brain to anticipate its appearance  |
|
| Back to top |
|
 |
keyboardfreak
Joined: 09 Oct 2004 Posts: 216 Location: Budapest, Hungary
|
Posted: Mon Jul 06, 2009 3:38 pm Post subject: |
|
|
| Improved the script, so that multiple reminders/affirmations can be specified, each with its own period. See the explanation in the first post. |
|
| Back to top |
|
 |
robusta
Joined: 22 Jul 2010 Posts: 2
|
Posted: Thu Jul 22, 2010 4:11 pm Post subject: how to make reminder show up in same position each time? |
|
|
Sorry for the newbie question; I've been searching the help files and forums and haven't figured out how to do this:
I have one space on my monitor that I keep clear of windows and use for notifications and IMs while I am working. How would I modify this script to have the popup appear at the same x/y coordinates each time? |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Jul 22, 2010 4:25 pm Post subject: |
|
|
| Removed the "random nagreminder..." lines and set nagreminder_x and nagreminder_y in their place to a constant value. |
|
| Back to top |
|
 |
robusta
Joined: 22 Jul 2010 Posts: 2
|
Posted: Thu Jul 22, 2010 5:35 pm Post subject: |
|
|
Fantastic. Removed and replaced with
| Code: | nagreminder_x = 1600
nagreminder_y = 800 |
Works a charm. Thanks! |
|
| Back to top |
|
 |
iPhilip
Joined: 03 Jun 2010 Posts: 31
|
Posted: Fri Jul 23, 2010 5:59 pm Post subject: |
|
|
Folks,
The above script inspired me to work on a slight modification that allows long reminders and short multi-line reminders. See the code below.
| Code: | ;
; Reminder.ahk
;
; Script Description:
;
; This script was inspired by keyboardfreak (Reference: http://www.autohotkey.com/forum/topic45738.html)
; It loads in a set of reminders from the Reminders.txt file, one per line. The syntax is as follows:
;
; text1/time1
; text2/time2
; text3/time2
;
; Times are specified in minutes. Multi-line reminders can be achieved by adding `n to the text
;
; The script uses the SplashMe scripts to display the reminders
; (Reference: Reference: http://www.autohotkey.com/forum/topic18040.html)
;
; --------------------------------------------------------------------------------------------------
;
; Change the tray icon tip
Menu, Tray, Tip, Reminder
;
; Show starting splash window in bottom right corner
;
SplashOn("","Starting Reminder ...",0,"","XR YB")
Sleep 1000
;
; Setup the parameters
;
SplashTime := 10*1000 ; Display the reminders for 10 seconds
SplashFont := ""
SplashOptions := "FS14 CWLime" ; Options for SplashImage, e.g. CWRed - Don't include X or Y coordinates
;
; Get the working width and height of the screen
;
SysGet, Pos, MonitorWorkArea
WorkingWidth := PosRight - PosLeft ; Calculate the working width of the screen
WorkingHeight:= PosBottom - PosTop ; Calculate the working height of the screen
;
; Update the working width and height of the screen when there is a display change
;
OnMessage(0x7E, "WM_DISPLAYCHANGE")
WM_DISPLAYCHANGE()
{
global
SysGet, Pos, MonitorWorkArea
WorkingWidth := PosRight - PosLeft ; Calculate the working width of the screen
WorkingHeight:= PosBottom - PosTop ; Calculate the working height of the screen
Return true ; Tell the OS to allow the display change to continue
}
;
; Set the splash window coordinates so that the window is off the screen (X = WorkingWidth, Y = WorkingHeight)
; This is simply a trick to get the dimensions of the splash window so that they can be used later on
;
AllSplashOptions := SplashOptions . " X" . WorkingWidth . " Y" . WorkingHeight
AllSplashOptions = %AllSplashOptions% ; Trim whitespaces at either end in case SplashOptions is blank
;
; Read reminders from file and parse the information
;
Schedules := 0
Loop, Read, Reminders.txt
{
Schedules += 1
StringSplit, Field, A_LoopReadLine, /
Text%A_Index% := Field1
StringReplace, Text%A_Index%, Text%A_Index%, ``n, `n, All
Period%A_Index% := Field2
Counter%A_Index% := Field2
SplashOn("",Text%A_Index%,0,SplashFont,AllSplashOptions)
WinGetPos, , , Width%A_Index%, Height%A_Index%, SplashOnWindow
}
;
; Quickly run through all the reminders once at the start
;
Loop %Schedules%
{
Random, X, , % WorkingWidth - Width%A_Index%
Random, Y, , % WorkingHeight - Height%A_Index%
AllSplashOptions := SplashOptions . " X" . X . " Y" . Y
AllSplashOptions = %AllSplashOptions%
SplashOn("",Text%A_Index%,0,SplashFont,AllSplashOptions)
Sleep 1000
SplashOff()
}
;
; Now start a timer so that every minute the reminder counter is checked against its period
;
SetTimer, CountDown, % 60*1000 ; Set the counter period to 1 minute
Return
CountDown:
Loop %Schedules%
{
Counter%A_Index% -= 1
if (Counter%A_Index% = 0)
{
Random, X, , % WorkingWidth - Width%A_Index%
Random, Y, , % WorkingHeight - Height%A_Index%
AllSplashOptions := SplashOptions . " X" . X . " Y" . Y
AllSplashOptions = %AllSplashOptions%
SplashOn("",Text%A_Index%,0,SplashFont,AllSplashOptions)
Sleep Splashtime
SplashOff()
Counter%A_Index% := Period%A_Index%
}
}
Return
#p::
Pause
Return
Exit:
SplashOff()
ExitApp
#Include Library
#Include Splash Me.ahk ; Defines a set of functions to generate splash windows
|
Thank you keyboardfreak for the inspiration. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|