08.13.07

AppleScript

Posted in AppleScript, Macintosh at 2:03 pm by Lazra

As you can see if you take a look at my tag-cloud, I really like AppleScript. It is so easy to implement simple tasks with a few lines. Most in OS X included applications support it and also many others. Shell scripts are also includable. It is so easy if you compare to other systems. Most parts of Linux are of course highly scriptable which I really like. It is a bit catchy to get into that but surely remunerative. Anyway, with AppleScript it is really easy to take the first steps. You can tell application “Finder” to empty the trash. Just as I wrote it.
tell application "Finder" to empty the tash
Or lets say "Hello World".

You can control many apps and your system. But not only that. It can handle variables, loops, functions and whatnots.

Take a look if you want to get more out of your Mac. There is a great page with many resources: http://macscripter.net/

I also recommend this free book for AppleScript starters by Bert Altenburg. http://www.fischer-bayern.de/as/as4as/AS4AS_e.pdf It teaches the basics. And with the help of the functionlist (+shift+o in the scripteditor) you have the knowledge to create quite useful, individual tools.

08.10.07

iCal countdown

Posted in AppleScript, Macintosh at 10:48 am by Lazra

I wrote an other little AppleScript for someone. It creates events in iCal as a countdown. First, you can choose one of your calendars. Then enter the start- and enddate. It will count down and say every day “x days left”. I tested it with my local date format, but it is supposed to work anywhere since the Mac knows his date format.

on run

tell application “iCal”

set cal_list to {}

repeat with x from number of calendars to 1 by -1
set the beginning of cal_list to name of calendar x
end repeat

set cal_list_string to “”
repeat with x from 1 to number of calendars
set cal_list_string to cal_list_string & (x as text) & ” – ” & item x of cal_list & return
end repeat

end tell

display dialog cal_list_string default answer “”
set cal_number to text returned of result as number

display dialog “start date” default answer “”
set anfangsdatum to date (text returned of result)

display dialog “end date” default answer “”
set enddatum to date (text returned of result)

repeat with anzahl_tage from 1 to 99999
if anfangsdatum + (anzahl_tage * 3600 * 24) is enddatum then
exit repeat
end if
end repeat

tell application “iCal”

tell calendar cal_number

set x_date to anfangsdatum

repeat with x from anzahl_tage to 0 by -1
set x_date to x_date + (3600 * 24)
set event_summary to “x & ” days left”
if x is not 1 then
set event_summary to “x & ” days left”
else
set event_summary to “one day left”
end if
make new event at the beginning with properties {summary:event_summary, start date:x_date, end date:x_date}
end repeat

end tell

end tell

end run

08.09.07

They use Macintosh!

Posted in Macintosh, study at 7:34 pm by Lazra

Well, some of them. I just came back from a math refresh course. And the lecturer used a Mac! And I think I have also seen other profs with Mac- or PowerBooks. But why did they tell me in the info material they sent me that Windows XP Pro or Vista Business is needed to integrate a notebook into their network? Was this Mac not integrated in the network? Or do profs have bizarre privileges? Or did they lie? I`ll find out… eventually.
Oh, and it did feel good to sit there with others just to learn. I really missed this.

08.07.07

New iMac, Mac mini, iLife, iWork…

Posted in Macintosh, software at 9:19 pm by Lazra

Apple just released the new iMac in a new robe. And up to 2.8GHz! Of course the new iLife is included and a demo of the new iWork. Don’t forget the new Mac mini with a Core2Duo now. I know, the price may be a bit high compared to the iMac. But what if you already have a screen? And have you ever seen one? It is sooo cute!

08.01.07

PathFinder as a MacUpdate Promo

Posted in Macintosh, software at 6:42 pm by Lazra

I just purchased PathFinder as a MacUpdate Promo for 20 Dollars. There are a bit more than 9 hours left. A really good offer. There are many representation and navigation options. I have to try it all out but I’m sure I will not regret this decision.

OmniOutliner to folder structure

Posted in AppleScript, Macintosh, OmniOutliner at 2:55 am by Lazra

An other useless AppleScript. OmniOutliner seems to be bundled with all new Apple computers. My idea is: Create a hierarchical structure in OO related to some kind of a project and export this to a folder structure in the filesystem to fill it with any kind of information.
The script exports a OPML file from OO to home/scriptfiles/ and reads the XML information out of it. It asks you for a folder to export the sub- and sub-sub… folders there. The OPML file stays, the script could be told to delete it. I like to stay.
I want to thank Skeeve who helped me with the handler which creates the folders. Just in case he reads this…..


on run

set inbetween to POSIX path of (path to home folder) & "scriptfiles/"

tell application "Finder"
try
make new folder at ((home as text)) with properties {name:"scriptfiles"}
end try
end tell

tell application "OmniOutliner"
export document 1 to inbetween & "oo.opml" as "OOOPMLDocumentType"

set selected_path to (choose folder) as string
set destination to POSIX path of selected_path

end tell

tell application "System Events"
set XMLfile to XML file (inbetween & "oo.opml")
set root to XML element 1 of XMLfile
set body to XML element "body" of root
my make_structure(body, destination)
end tell

end run

to make_structure(parent, current_path)
set done to false
tell application "System Events"
repeat with elt in (every XML element of parent whose name is "outline")
my make_structure(elt, current_path & (value of XML attribute "text" of elt) & "/")
set done to true
end repeat
end tell
if not done then
do shell script "mkdir -p " & quoted form of current_path
end if
end make_structure

Update on the Bookmarking thing

Posted in AppleScript, Macintosh, VoodooPad at 1:33 am by Lazra

There was a bug in this script. It took the wrong URL when multiple pages were opened. Never trust code from some stranger, I tell you. There is still a flaw, sometimes it changes the active Safari window for some or no reason. Buuut: Now there is a list of the acronyms and what’s their meaning. And the input works a bit different: type the acronym followed by a space and then the description. Page creation or direct addressing by pagename does not work anymore.
Here is the code. I edited it also in the previous post.

Edit: Ok, I hope I killed the flaw now. Script is updated again.

on run

tell application "Safari" to set new_bm_url to URL of document 1 of window 1
activate

set acronyms to {"s", "a", "g", "o", "d", "l"}
set pagenames to {"bm Science", "bm Apple", "bm Games", "bm Other", "bm Software Dev", "bm Read Later"}

set d_l to ""
repeat with x from 1 to number of items of acronyms
set d_l to d_l & item x of acronyms & " - " & item x of pagenames & return
end repeat

display dialog d_l as text default answer ""
set text_result to text returned of result

set acronym to first character of text_result
set bookmark_note to characters 3 thru (number of characters of text_result) of text_result as text

tell application "VoodooPad"

repeat with x from 1 to number of items of acronyms
if item x of acronyms is acronym then
set itemnumber to x
end if
end repeat

set pagename to item itemnumber of pagenames

append text bookmark_note & return & new_bm_url & return to page pagename of document 1

end tell

end run

07.30.07

Bookmarking with VoodooPad

Posted in AppleScript, Macintosh, VoodooPad at 5:57 pm by Lazra

Bookmarks in the browser (doesn’t matter which one) does not work for me. I figured this out yesterday after years of webbrowsing. Somehow I can never remember what categories I had or why I bookmarked this particular page. With some browsers you can add a comment to a bookmark, but you have to open the bookmark manager every time. There may be some plugins, but I want to stay flexible in the choice of my browser. Yes, it’s kind of weird. Anyway, I deliberated if I should just copy the links to my favourite app, VoodooPad. That’s soo last century. But wait, there’s this cool method of automation, AppleScript. So I wrote a little script which asks me for a page to append the bookmark. I defined some acronyms, “s” for science for example. And then it asks me for a note, so I can type in a few related words to remenber the content of the website. Still last century? Maybe. I don’t care, it’s much more pleasing to me this way. You could fill in your acronyms and pagenames in the lists at the beginning of the script. It behaves like this: If you use the acronym, it appends the Bookmark to its page. If you type in something else, it appends the bookmark to the page with this name and creates a new one if this page does not exist. Here is it, in case someone is interested. Which is quite unlikely.

on run

tell application "Safari" to set new_bm_url to URL of document 1 of window 1
activate

set acronyms to {"s", "a", "g", "o", "d", "l"}
set pagenames to {"bm Science", "bm Apple", "bm Games", "bm Other", "bm Software Dev", "bm Read Later"}

set d_l to ""
repeat with x from 1 to number of items of acronyms
set d_l to d_l & item x of acronyms & " - " & item x of pagenames & return
end repeat

display dialog d_l as text default answer ""
set text_result to text returned of result

set acronym to first character of text_result
set bookmark_note to characters 3 thru (number of characters of text_result) of text_result as text

tell application "VoodooPad"

repeat with x from 1 to number of items of acronyms
if item x of acronyms is acronym then
set itemnumber to x
end if
end repeat

set pagename to item itemnumber of pagenames

append text bookmark_note & return & new_bm_url & return to page pagename of document 1

end tell

end run

Sogudi

Posted in Macintosh, software at 5:48 pm by Lazra

I found an amazing plugin for Safari. I’m not a plugin-freak but this is so useful. It’s called Sogudi. I found it on a MacBreak Video. It lets you define short names for websites, an ovious example is w for Wikipedia. When you want to search something in Wikipedia, you type in your address bar “w ” and then your search term. For example “w voodoopad” to get the entry for “voodoopad”. There are many predefined websites, but you can define your own ones. This way I got rid of some bookmarks and also removed the google searchbox of Safari by editing the Toolbaritems.nib. Great idea.

07.26.07

MindMapper

Posted in Macintosh, visual at 6:05 pm by Lazra

Since I am a visual learner, it helpes me to have a map of my thoughts or of stuff I’m supposed to learn. One tool I knew from my Windows time was Freemind which is also available for Mac OS. I used it for some important exams and it helped a lot. The capabilities of this application are limited. I appreciate it a lot because it helped me to get into this kind of usage of a computer. It’s just not the solution for me. So I reached out into the unlimitted space of the web and found some other tools. All of them have their limits. I go threw some of them, but this is not a review. Just some random thoughts.

Novamind
Wow! All these colors… how horrible! But ok, it can be changed… I’m not against color, not at all, but just if it makes sense. Not just to be somehow exceptional. The quick creation of topics with the keyboard works to some extent. But what is that, the topics overlap each other in some cases?!? Not the way to go. The set of features is pretty good, but I can’t live with these issues.

OmniGraffle
This is not really a mindmapper, but it has a mindmap mode. So I tried it. For about five minutes. You have to create a sister-topic first and then press tab to make it a child. Can’t tell more because I stoped trying it at this point.

MyMind
Costs as much as Freemind which is good. The view is nice and pretty configurable. Just the handling doesn’t fit for me. I’ll keep it on my harddrive, just in case.

Tinderbox
Tinderbox is not a classical mindmapper. It’s hard to explain. There are notes which can be linked to other notes. The links have attributes themselves. You can make prototypes of notes to create categories of similar notes. Agents can gather notes depending on their attributes. The hierarchival structure is not visible in the map view, it works with layers. Andorments provide an additional possibility to gather notes on the same layer. It looks really interesting, but I didn’t manage to figure out how to use it in a productive way. And it’s expensive. I’ll keep it in my mind.

Graphviz
Not really a mindmap program and not meant to be. But on my research I found this and it helped me for A crappy map for VoodooPad.

Incubator
Nice. The look is very clean. The handling works very well, you can quickly create a map with just the keyboard. This also works with some other tools, but this one act just like I expect it. I didn’t find a way to make links between topics outside the hierarchical structure. I often want to make something like:
a has property b and c also but a and c are on different positions in the tree. Know what I mean? The kind of structure you could easily represent in a table. Sometimes I use color to support this, but it’s not a very well solution. Maybe concept maps would work better for me, but all the tools I looked at were kind of crappy (just kind of!). My favourite feature: Create links to a new page! Just rightclick any subtopic and make a new page with this subtopic as main idea. Then you can click on the arrow next to the subtopic in the main view to get to its own page. Kind of an infinite workspace. Infinite is goood! I really like that. The feature set may not be so huge but it does what I want it to do. It’s the tool of my choice. One downside is, it’s not applescriptable. Sad.

Next page