is there a way to create a new text edit doc from launchbar?

Sharing and discussing custom actions for LaunchBar
Post Reply
kmnjunk2007

is there a way to create a new text edit doc from launchbar?

Post by kmnjunk2007 » Thu Jan 11, 2007 6:33 am

I'd like to be able to quickly create a text edit doc onto my desktop by using launchbar, the ideal method would go something like:

an idea pops into my head, "command+space" to call up launchbar, "txt (or whatever)" to call up TextEdit, "spacebar" to start entering text (this would be the title), enter my text, and then "enter," and it would save a textedit doc with the title as i typed it onto my desktop.

I like to do this to save quick notes & reminders right onto my desktop where I can always see them. If it's anything I need to figure out more, then I would open up the doc, and write more detailed notes, and or copied research material in it.

tia

eth0

Post by eth0 » Thu Jan 11, 2007 7:45 pm

Once again, AppleScript to the rescue:

Code: Select all

on run
   display dialog "This script creates a text file in the Desktop." buttons {"OK"} default button 1 with icon 1
end run

on handle_string(s)
   set theFile to s & ".txt"
   tell application "Finder"
      set theNewFile to make new file at desktop with properties {name:theFile}
      set the extension hidden of theNewFile to true
   end tell
   open location "x-launchbar:hide"
end handle_string

kmnjunk2007

you're the bomb

Post by kmnjunk2007 » Sat Jan 13, 2007 4:04 am

you're the bomb, thanks again...and thanks in advance for answering any more of my noob questions

kmnjunk2007

any way to save as rich text textedit doc?

Post by kmnjunk2007 » Sat Jan 13, 2007 4:15 am

hehe, now I'm starting to feel like I'm asking for too much, but I notice most people like to save as or deal with plain text file. Is there any method to save as rich text file? This might be more useful for me since I might decide to paste in stuff I search and copy (including pictures, and hyperlinks) from other apps such as Safari, without needing to resave in a different file format.

Thanks either way.

eth0

Post by eth0 » Sun Jan 14, 2007 2:22 pm

There's no straightforward way to do that, but you can just write the RTF codes of a blank document into a text file.

With a few modifications to the AppleScript above, the new one looks like this:

Code: Select all

on run
   display dialog "This script creates a TextEdit document in the Desktop." buttons {"OK"} default button 1 with icon 1
end run

on handle_string(s)
   set theFile to s & ".rtf"
   set rtfContents to "{\\rtf1\\mac\\ansicpg10000¬
      \\cocoartf824\\cocoasubrtf410{\\fonttbl}¬
      {\\colortbl;\\red255\\green255\\blue255;}¬
      \\paperw11900\\paperh16840\\margl1440¬
      \\margr1440\\vieww9000\\viewh8400\\viewkind0}"
   set desktopPath to path to desktop as text
   set theFullName to desktopPath & theFile
   tell application "Finder"
      set theNewFile to make new file at desktop with properties {name:theFile}
      write rtfContents to file theFullName
      set the extension hidden of theNewFile to true
   end tell
   open location "x-launchbar:hide"
end handle_string

Hope it helps. :)

kmnjunk2007

u're my idol

Post by kmnjunk2007 » Tue Jan 16, 2007 11:01 pm

yes it helps, thanks, you're my idol, im not worthy!

:D

navidad48
Posts: 4
Joined: Tue Jul 03, 2012 4:39 am

Re: is there a way to create a new text edit doc from launchbar?

Post by navidad48 » Tue Jul 03, 2012 4:42 am

Hey there, is there any way to to have the applescript launch the text-file that it has just created with this action?

I'm only interested in the first applescript posted -the one that creates a plain text file. I don't use rtf.

Thanks so much in advance!!!

-noel.

iRounak
Rank 4
Rank 4
Posts: 191
Joined: Fri Oct 23, 2009 7:11 pm
Contact:

Re: is there a way to create a new text edit doc from launchbar?

Post by iRounak » Tue Jul 03, 2012 5:38 am

Hey there, is there any way to to have the applescript launch the text-file that it has just created with this action?

This script will open the text file.

Code: Select all

on run
   display dialog "This script creates a text file in the Desktop." buttons {"OK"} default button 1 with icon 1
end run

on handle_string(s)
   set theFile to s & ".txt"
   tell application "Finder"
      set theNewFile to make new file at desktop with properties {name:theFile}
      set the extension hidden of theNewFile to true
   end tell
   open location "x-launchbar:hide"
   set thelocation to ((path to desktop folder) & theFile) as string
   tell application "Finder" to open thelocation
end handle_string

navidad48
Posts: 4
Joined: Tue Jul 03, 2012 4:39 am

Re: is there a way to create a new text edit doc from launchbar?

Post by navidad48 » Tue Jul 03, 2012 7:08 am

Thank you thank you!!!

urippa
Posts: 14
Joined: Tue Oct 06, 2009 6:53 am

Re: is there a way to create a new text edit doc from launchbar?

Post by urippa » Mon Aug 06, 2012 10:05 pm

A script seems a little like overkill.....

you could do this:

invoke LB

type TE (or your abbreviation for TextEdit)and hold down the E to open TextEdit

type cmd-N

or:

select some text somewhere

invoke LB instant send

type TE and hold down the E

selected text, images and everything else will appear in a brand new TE doc, in RTF even if plain text is selected as the default, until you decide different

Post Reply