Text modification - Changing cases

Sharing and discussing custom actions for LaunchBar
ptujec
Wizard
Wizard
Posts: 321
Joined: Fri Dec 19, 2008 11:36 am
Contact:

Text modification - Changing cases

Post by ptujec » Mon Oct 26, 2009 11:05 pm

Since Snowleopard some of the service items are gone. You can still change transform text to upper or lower case with secondary click/transformations but ...
1) Thats not accessable through Launchbar because not a „real“ service but an extra category. …
2) I miss an option to capitalize only the first word of each sentence.

I couldn’t find anything good on the web …
Any ideas?

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

Re: Text modification - Changing cases

Post by iRounak » Tue Oct 27, 2009 11:28 am

you can try: http://u.nu/5zap3
Use system preferences>>keyboard and mouse>>keyboard to assign a keyboard shortcut.
or you can try UI scripting in applescript to click that item(item which changes case) in the Service Menu or wherever it is.
I don't use Snow Leopard, so I don't know where that item is.

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

Re: Text modification - Changing cases

Post by ptujec » Tue Oct 27, 2009 9:44 pm

iRounak wrote:you can try: http://u.nu/5zap3
Use system preferences>>keyboard and mouse>>keyboard to assign a keyboard shortcut.
or you can try UI scripting in applescript to click that item(item which changes case) in the Service Menu or wherever it is.
I don't use Snow Leopard, so I don't know where that item is.


It works with context menu but it doesn’t with LaunchBar unfortunately.

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

Re: Text modification - Changing cases

Post by iRounak » Wed Oct 28, 2009 6:08 am

It works with context menu but it doesn’t with LaunchBar unfortunately.

I did not understand you :? and apparently, you did not understand what i wrote either. :D Its better if an experienced LaunchBar user helps you. I have just switched from Quicksilver

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

Re: Text modification - Changing cases

Post by ptujec » Wed Oct 28, 2009 9:28 am

iRounak wrote:
It works with context menu but it doesn’t with LaunchBar unfortunately.

I did not understand you :? and apparently, you did not understand what i wrote either. :D Its better if an experienced LaunchBar user helps you. I have just switched from Quicksilver


No no, your suggestion helped. Its even accessible through LaunchBar but it wouldn’t do the job when used with LaunchBar. Maybe thats due to the changes which had to be done on LaunchBar because Services changed in Snowleopard.

norbert
Objective Development
Objective Development
Posts: 648
Joined: Thu Nov 09, 2006 6:30 pm

Re: Text modification - Changing cases

Post by norbert » Sat Oct 31, 2009 12:36 pm

ptujec wrote:Since Snowleopard some of the service items are gone. You can still change transform text to upper or lower case with secondary click/transformations but ...
1) Thats not accessable through Launchbar because not a „real“ service but an extra category. …
2) I miss an option to capitalize only the first word of each sentence.

I couldn’t find anything good on the web …
Any ideas?

You might try WordService from DEVON:
http://www.devon-technologies.com/download/

It's free and it provides a whole bunch of useful services, including case conversions like:

  • All Caps
  • Lowercase
  • Initial Caps Of Sentences
  • Initial Caps Of Words

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

Re: Text modification - Changing cases

Post by iRounak » Sat Oct 31, 2009 1:31 pm

You might try WordService from DEVON:
http://www.devon-technologies.com/download/

I also pointed to WordService when I gave my shortened url earlier :D

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

Re: Text modification - Changing cases

Post by ptujec » Sat Oct 31, 2009 1:33 pm

norbert wrote:
ptujec wrote:Since Snowleopard some of the service items are gone. You can still change transform text to upper or lower case with secondary click/transformations but ...
1) Thats not accessable through Launchbar because not a „real“ service but an extra category. …
2) I miss an option to capitalize only the first word of each sentence.

I couldn’t find anything good on the web …
Any ideas?

You might try WordService from DEVON:
http://www.devon-technologies.com/download/

It's free and it provides a whole bunch of useful services, including case conversions like:

  • All Caps
  • Lowercase
  • Initial Caps Of Sentences
  • Initial Caps Of Words


Thx. Thats what iRounak suggested. It works but not within LaunchBar.

norbert
Objective Development
Objective Development
Posts: 648
Joined: Thu Nov 09, 2006 6:30 pm

Re: Text modification - Changing cases

Post by norbert » Sat Oct 31, 2009 1:42 pm

iRounak wrote:I also pointed to WordService when I gave my shortened url earlier :D

Ah, I didn't follow the the shortened link, so I didn't realize that it links to WordService.

norbert
Objective Development
Objective Development
Posts: 648
Joined: Thu Nov 09, 2006 6:30 pm

Re: Text modification - Changing cases

Post by norbert » Sat Oct 31, 2009 1:47 pm

ptujec wrote:Thats what iRounak suggested. It works but not within LaunchBar.

I see, you are probably running a non-English system, do you? There's a bug in our current services implementation, causing localized services to fail. This will be fixed in 5.0.2.

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

Re: Text modification - Changing cases

Post by ptujec » Sat Oct 31, 2009 2:04 pm

norbert wrote:
ptujec wrote:Thats what iRounak suggested. It works but not within LaunchBar.

I see, you are probably running a non-English system, do you? There's a bug in our current services implementation, causing localized services to fail. This will be fixed in 5.0.2.


Good to hear!

sjk
Wizard
Wizard
Posts: 315
Joined: Thu Sep 13, 2007 9:46 pm
Location: Eugene
Contact:

Re: Text modification - Changing cases

Post by sjk » Sat Oct 31, 2009 2:41 pm

norbert wrote:
iRounak wrote:I also pointed to WordService when I gave my shortened url earlier :D

Ah, I didn't follow the the shortened link, so I didn't realize that it links to WordService.

I'd rather people didn't use URL shortening on forums because it obfuscates the target.

Edit: fixed missing "on" typo.
Last edited by sjk on Sat Oct 31, 2009 8:15 pm, edited 2 times in total.

norbert
Objective Development
Objective Development
Posts: 648
Joined: Thu Nov 09, 2006 6:30 pm

Re: Text modification - Changing cases

Post by norbert » Sat Oct 31, 2009 6:33 pm

ptujec wrote:I'd rather people didn't use URL shortening forums because it obfuscates the target.

Me too. I'd recommend to use named URLs instead. Example:

Code: Select all

[url=http://www.example.com/some/very/long/address/]Name of Target[/url]

sjk
Wizard
Wizard
Posts: 315
Joined: Thu Sep 13, 2007 9:46 pm
Location: Eugene
Contact:

Re: Text modification - Changing cases

Post by sjk » Sat Oct 31, 2009 8:23 pm

TinyURL links are tolerable with the preview feature enabled. Directly opening unknown targets with other URL shortening services bothers me.

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

Re: Text modification - Changing cases

Post by iRounak » Sun Nov 01, 2009 6:32 am

To ptujec:

It seems you know some applescripting (looking at your other posts)
so modify this to suit your needs:

Code: Select all

on handle_string(theString)
   ...................................................
tell application "LaunchBar"
perform action "Copy and Paste" with string sometext
hide
end handle_string
on change_case_of(this_text, this_case)
   if this_case is "mixed" then return mixedCase(this_text)
   if this_case is "lower" then
      set the comparison_string to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
      set the source_string to "abcdefghijklmnopqrstuvwxyz"
   else
      set the comparison_string to "abcdefghijklmnopqrstuvwxyz"
      set the source_string to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
   end if
   set the new_text to ""
   repeat with thisChar in this_text
      set x to the offset of thisChar in the comparison_string
      if x is not 0 then
         set the new_text to (the new_text & character x of the source_string) as string
      else
         set the new_text to (the new_text & thisChar) as string
      end if
   end repeat
   return the new_text
end change_case_of
to mixedCase(theText)
   set newText to {}
   repeat with myWord in (every word of theText)
      set end of newText to (change_case_of(first character of myWord, "upper") & change_case_of(rest of characters of myWord, "lower"))
   end repeat
   return newText as string
end mixedCase


If you can't make sense of the above script. Find the original script here: http://u.nu/52tq3
Its in the "Editing" folder.
(To others: I like to use URL shortening and its all scripted and a part of my workflow. And tinyurl is not tiny enough)

Post Reply