The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Script to copy iCal todos into Omnifocus inbox? (http://forums.omnigroup.com/showthread.php?t=17771)

danielcompton 2010-09-03 09:39 PM

Script to copy iCal todos into Omnifocus inbox?
 
Hi guys

I have a Nokia 2865 phone which I sync with my mac. This lets me sync todos to iCal along with my calendar and address book. I can get to my todo list with a single button press from the home screen of the Nokia.

I currently use my phones todo list as an inbox to capture events, actions or ideas which I can then sync to my mac when I get home to process them into Omnifocus and delete them from the to do list in iCal.

I have just installed Omnifocus and am wondering how it would be possible to script the process of copying the note title (that's all that the notes contain) and then making these as new inbox items in Omnifocus. I did a google search and forum search but couldn't find anything.

I have zero scripting experience but am reasonably clued up about macs and would be happy to troubleshoot it with someone else who was a bit more experienced in writing applescripts.

Thanks, Daniel.

EDIT: I realised this would be better in OmniFocus Extras forums so I reposted it [URL="http://forums.omnigroup.com/showthread.php?p=84883#post84883"]here[/URL]. I would remove this post but I can't.

danielcompton 2010-09-04 01:16 AM

Script to copy iCal todos into Omnifocus inbox?
 
Hi guys

I have a Nokia 6120 phone which I sync with my mac through iSync. It runs Symbian 3rd edition FP1. This lets me sync todos to iCal along with my calendar and address book. I can get to my todo list with a single button press from the home screen of the Nokia.

I currently use my phones todo list as an inbox to capture events, actions or ideas which I can then sync to my mac when I get home to process them into Omnifocus and delete them from the to do list in iCal.

I have just installed Omnifocus and am wondering how it would be possible to script the process of copying the note title (that's all that the notes contain) and then making these as new inbox items in Omnifocus. I did a google search and forum search but couldn't find anything.

I have zero scripting experience but am reasonably clued up about macs and would be happy to troubleshoot it with someone else who was a bit more experienced in writing applescripts.

Thanks, Daniel.

RobTrew 2010-09-04 03:36 AM

The file from the Nokia is a text file of simple lines without any substructure, where each line needs to become an inbox item name ?

(I remember an earlier Nokia setup in which each note was a separate text file, and did sketch [URL="http://forums.omnigroup.com/showthread.php?t=5068"]a script[/URL] for that, but I imagine the current setup might be a bit different).

[COLOR="White"]--[/COLOR]

danielcompton 2010-09-04 05:04 AM

Hi Rob, I didn't realise that was how it worked. The phone is running symbian 3 and is a 6120. My last Nokia was a 2865 and I got the two confused.

I'm more interested in solving this via the route of - Nokia to do >sync to iCal > create new note in the OF inbox > delete old note. I currently sync via bluetooth and it works really simply and syncs contacts and my calendar as well.

I'm not sure how to do this but in my head it would be
1. Sync with phone
2. Get title of first to do
3. Make new OF action from title
4. Delete to do
5. Repeat 2-4 until number of to do's is 0.

My thought for a slightly more advanced version would be to have the script only copy across and delete notes that started with a ".". That way I could start a OF action by first placing a period and then writing the note into my phone and still have the option of using the to do as a list for things to check off. That would be a lot more complex though...

cjlemonier 2010-09-04 11:55 AM

Something like this - Be Careful!!!! This would delete all of the todos from iCal.

[CODE]tell application "iCal"
set theCalendars to every calendar
repeat with theCalendar in theCalendars
set theTodos to every todo in theCalendar
repeat with theTodo in theTodos
set theTodoSummary to summary of theTodo
tell application "OmniFocus" to tell default document
make new inbox task with properties {name:theTodoSummary}
end tell
delete theTodo
end repeat
end repeat
end tell[/CODE]

Chris

danielcompton 2010-09-04 03:23 PM

Thanks heaps Chris, that's perfect. When I get a bit more proficient with Applescript I might twiddle to add further features but this is awesome.

Much thanks, Daniel.

danielcompton 2010-09-04 05:17 PM

I fiddled a bit more and looked at [URL="http://hohle.net/scrap_post.php?post=204"]this site[/URL] to get a bit more info and I have cobbled [B]cjlemonier's[/B] script together with the one at the link.

Now you just need to activate the script and it will sync the phone and mac and 'cut' the todos synced from the phone/iCal to do list and paste them into the Omnifocus inbox. The other change is that this now activates iSync if it wasn't running and then closes it after the script has run.

Here it is, again be careful anyone else running this because this will delete todos from iCal.

[CODE]tell application "System Events"
set iSyncIsRunning to (count of (every process whose name is "iSync")) > 0
end tell

tell application "iSync"
activate
synchronize
-- wait until sync status != 1 (synchronizing)
repeat while (syncing is true)
end repeat
set syncStatus to sync status
set lastSync to last sync
end tell

tell application "iCal"
set theCalendars to every calendar
repeat with theCalendar in theCalendars
set theTodos to every todo in theCalendar
repeat with theTodo in theTodos
set theTodoSummary to summary of theTodo
tell application "OmniFocus" to tell default document
make new inbox task with properties {name:theTodoSummary}
end tell
delete theTodo
end repeat
end repeat
end tell

if syncStatus = 2 and not iSyncIsRunning then
tell application "iSync" to quit
end if[/CODE]

This is my first applescript and there are possibly errors or bad practices in the way that I've done this but it seems to work for me.

danielcompton 2010-09-04 06:01 PM

This is a further update on the script, it launches OmniFocus if it wasn't running already and hides it from view (whether or not it was running). I got help from [URL="http://hints.macworld.com/article.php?story=20090127130957369"]here[/URL]. Ideally the script would leave OmniFocus at whatever window focus it was originally at (or hidden) and close it after if it was not already open. That will have to wait for another day though when I actually understand what to do and not just how to copy and paste :p.

I'm not sure why but it apparently helps telling OF to activate twice (according to the link). It's not as elegant as I would like but it gets the job done :).

[CODE]tell application "System Events"
set iSyncIsRunning to (count of (every process whose name is "iSync")) > 0
end tell

tell application "OmniFocus" to activate
tell application "OmniFocus" to activate
tell application "Finder"
set visible of process "OmniFocus" to false
end tell

tell application "iSync"
activate
synchronize
-- wait until sync status != 1 (synchronizing)
repeat while (syncing is true)
end repeat
set syncStatus to sync status
set lastSync to last sync
end tell

tell application "iCal"
set theCalendars to every calendar
repeat with theCalendar in theCalendars
set theTodos to every todo in theCalendar
repeat with theTodo in theTodos
set theTodoSummary to summary of theTodo
tell application "OmniFocus" to tell default document
make new inbox task with properties {name:theTodoSummary}
end tell
delete theTodo
end repeat
end repeat
end tell

if syncStatus = 2 and not iSyncIsRunning then
tell application "iSync" to quit
end if[/CODE]


All times are GMT -8. The time now is 01:14 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.