Timer script: Display delayed messages (without hacks)

Sharing and discussing custom actions for LaunchBar
feddd
Posts: 1
Joined: Mon May 30, 2011 11:52 am

Re: Timer script: Display delayed messages (without hacks)

Postby feddd » Mon May 30, 2011 11:58 am

Thank you Guys for trying :)
Your conversation turn my mind into the right direction) I think I found the solution.

michaellynton
Posts: 1
Joined: Tue May 15, 2012 4:53 pm

Re: Timer script: Display delayed messages (without hacks)

Postby michaellynton » Tue May 15, 2012 4:54 pm

I keep getting the error:
Syntax Error
Expected end of line but found “after”.

I copied and pasted the script explicitly. What did I do wrong?

ptujec
Wizard
Wizard
Posts: 321
Joined: Fri Dec 19, 2008 11:36 am
Contact:

Re: Timer script: Display delayed messages (without hacks)

Postby ptujec » Tue May 15, 2012 7:08 pm

There are different versions here so I'm not sure which which one you where using.

I use a slightly modified version of Justins script. The only thing I added is the sound parameter.

Code: Select all

-- http://justinblanton.com/2010/02/launchbar-timer
-- Expamle: "1=1s, 1m, 1h ... 1.5 ..."
-- just added a sound to it (@Ptujec)

on handle_string(msg)
   
   set duration to last word of msg
   set mLength to (count characters of msg)
   set dLength to ((count characters of duration) + 1)
   set reminder to (characters 1 thru (mLength - dLength) of msg) as string
   
   tell application "LaunchBar"
      display in large type reminder after delay duration with sound "Glass"
      delay
   end tell
   
end handle_string
Last edited by ptujec on Sat May 26, 2012 3:57 pm, edited 2 times in total.

matthias
Rank 1
Rank 1
Posts: 21
Joined: Thu May 15, 2008 7:15 pm

Re: Timer script: Display delayed messages (without hacks)

Postby matthias » Fri May 25, 2012 11:59 pm

ptujec wrote:
norbert wrote:
majormauser2 wrote:Any way for it to play a sound when completed?


Note that the display in large type command also has a with sound option where you can specify a sound to be played when the message appears.


This is the version I currently use … with sound:

Code: Select all

-------------------------
-- Display Alert 1.2 for LaunchBar 5
-- this script displays a large typed message after a given delay time
--
-- originally written by ludwigschubert http://forums.obdev.at/viewtopic.php?f=24&t=615
-- modified by Zettt (http://www.zettt.de) at 2009-05-04
-- thanks to ptujec for providing additional information about changed AppleScript terms
--
-- Usage: Call LaunchBar, Hit Space, Input your message and provied your delay time at the end in "3s", "1m" or "2d" (without quotes)
-- Example: "This is an example message 2s" (without quotes)
--
-- 05/11/09 really minor change by ptujec - just added sound
-------------------------


on handle_string(message)
   
   tell application "LaunchBar"
      
      -- set time ... it's the last word of your string e.g. 'test 3'
      set delay_time to last word of message
      set future_message to message as text
      
      -- strip away last word of message
      set delay_time_length to length of delay_time
      set message_length to length of future_message
      set future_message to (characters 1 thru (message_length - delay_time_length) of future_message) as string
      
      -- display it in large type
      display in large type future_message after delay delay_time with sound "Glass"
      
   end tell
   
end handle_string


Works great! Thanks!

Was
Rank 2
Rank 2
Posts: 70
Joined: Wed Jan 13, 2010 2:27 am

Re: Timer script: Display delayed messages (without hacks)

Postby Was » Wed Jul 31, 2013 9:44 pm

Hi, I'm afraid all the versions of this script on this thread that omit the time from the large text display now place '+' signs between each letter in the large text display.

They used to work fine, so I wonder what's going wrong. Anyone have any idea of a fix?

ptujec wrote:There are different versions here so I'm not sure which which one you where using.

I use a slightly modified version of Justins script. The only thing I added is the sound parameter.

Code: Select all

-- http://justinblanton.com/2010/02/launchbar-timer
-- Expamle: "1=1s, 1m, 1h ... 1.5 ..."
-- just added a sound to it (@Ptujec)

on handle_string(msg)
   
   set duration to last word of msg
   set mLength to (count characters of msg)
   set dLength to ((count characters of duration) + 1)
   set reminder to (characters 1 thru (mLength - dLength) of msg) as string
   
   tell application "LaunchBar"
      display in large type reminder after delay duration with sound "Glass"
      delay
   end tell
   
end handle_string

ptujec
Wizard
Wizard
Posts: 321
Joined: Fri Dec 19, 2008 11:36 am
Contact:

Re: Timer script: Display delayed messages (without hacks)

Postby ptujec » Tue Aug 06, 2013 2:17 pm

Hi, Justins scripts still works just fine for me.

Was
Rank 2
Rank 2
Posts: 70
Joined: Wed Jan 13, 2010 2:27 am

Re: Timer script: Display delayed messages (without hacks)

Postby Was » Wed Aug 07, 2013 3:02 am

embarrassingly it now works fine for me, even though I'm using the same syntax as before. Odd. Thanks for replying, else I wouldn't have thought to check again.

thymara
Posts: 10
Joined: Wed Mar 26, 2014 4:45 pm

Re: Timer script: Display delayed messages (without hacks)

Postby thymara » Tue Apr 01, 2014 6:00 pm

I modified ptujec's script for my own purposes. being lazy I display the entire input message including the duration of the delay or the ultimate display time. I don't go over days but this meets my needs and allows input of either a duration or a time including the am or pm designation. No error checking.

easily modified by someone less lazy than me.

Code: Select all

on handle_string(linein)

   set duration to last word of linein
   if (duration = "am") or (duration = "pm") then
      set wordsin to count of words of linein
      set hh to word (wordsin - 2) of linein
      set mm to word (wordsin - 1) of linein
      set secs to hh * 3600 + mm * 60
      set rightnow to time of (current date)
      set duration to secs - rightnow
   end if
   tell application "LaunchBar"
      display in large type linein after delay duration with sound "Glass"
      delay
   end tell
   
end handle_string

ptujec
Wizard
Wizard
Posts: 321
Joined: Fri Dec 19, 2008 11:36 am
Contact:

Re: Timer script: Display delayed messages (without hacks)

Postby ptujec » Tue Apr 01, 2014 6:28 pm

Nice! Thanks. I'm not really using am and pm. So I replaced those with "Uhr" so it works with German time format (e.g. "15 Uhr")

Code: Select all

on handle_string(linein)
   
   set duration to last word of linein
   if duration = "Uhr" then
      set wordsin to count of words of linein
      set hh to word (wordsin - 2) of linein
      set mm to word (wordsin - 1) of linein
      set secs to hh * 3600 + mm * 60
      set rightnow to time of (current date)
      set duration to secs - rightnow
   end if
   tell application "LaunchBar"
      display in large type linein after delay duration with sound "Glass"
      delay
   end tell
   
end handle_string

thymara
Posts: 10
Joined: Wed Mar 26, 2014 4:45 pm

Re: Timer script: Display delayed messages (without hacks)

Postby thymara » Tue Apr 01, 2014 10:59 pm

I didn't test very well, script is incorrect in the pm. correction applied.

Code: Select all

on handle_string(linein)
   
   set duration to last word of linein
   if (duration = "am") or (duration = "pm") then
      set wordsin to count of words of linein
      set hh to word (wordsin - 2) of linein
      if duration = "pm" then
         set hh to hh + 12
      end if
      set mm to word (wordsin - 1) of linein
      set secs to hh * 3600 + mm * 60
      set rightnow to time of (current date)
      set duration to secs - rightnow
   end if
   if duration < 0 then
      set linein to "start time has already passed"
   end if
   tell application "LaunchBar"
      display in large type linein after delay duration with sound "Glass"
      delay
   end tell
   
end handle_string

ptujec
Wizard
Wizard
Posts: 321
Joined: Fri Dec 19, 2008 11:36 am
Contact:

Re: Timer script: Display delayed messages (without hacks)

Postby ptujec » Wed Jun 25, 2014 10:34 am

I put the German version into a LB6 action.

Image

Download "Timer"

Icon: http://://aegeank.com/sketchactive/

This is the code I use for it:

Code: Select all

 on handle_string(linein)
   
   try
      
      set duration to last word of linein
      if duration = "Uhr" then
         set wordsin to count of words of linein
         set hh to word (wordsin - 2) of linein
         set mm to word (wordsin - 1) of linein
         set secs to hh * 3600 + mm * 60
         set rightnow to time of (current date)
         set duration to secs - rightnow
      end if
      tell application "LaunchBar"
         display in large type linein after delay duration with sound "Glass"
         delay
      end tell
      
   on error e
      tell application "LaunchBar" to display in notification center with title "Error!" subtitle e
   end try
   
   
end handle_string


Return to “LaunchBar Actions”

Who is online

Users browsing this forum: No registered users and 2 guests

cron