OK, I think this might be the correct bit for create_task:
on run argv
set theFilename to item 1 of argv
set theName to do shell script "head -n1 " & theFilename
set theNote to do shell script "tail -n+2 " & theFilename
tell application id "com.omnigroup.omnifocus2"
tell default document
tell quick entry
make new inbox task with properties {name:theName, note:theNote}
open
set note expanded of tree 1 to true
-- tell application "System Events" to keystroke tab
end tell
end tell
end tell
end run
I moved set note expanded of tree 1 to true
to after the open
command. It works for me now.
(Keep in mind AppleScript is not my day job. But now it works, so that might be the actual fix. :) )