Finder + Things (CulturedCode) Integration

Hello,
I'm almost a newbie here.
I'm trying to let automagically interact Things (ToDo list app) with the finder through an hazel rule.
A typical situation is: I receive a file in mail and I want to remember to process it (read, sign or whatever).
The workflow ideally would be:
- while saving the file adding a finder tag (for hazel to process the file)
- running an applescript that:
1.get the name of the file
2. get the file path of the file to create a clickable link in things notes
3. open a dialog to choose the prefix for the name of the todo in things (i.e.: choose between "read", "sign", "whatever"
I'm not a scripter but I managed to write a script that works when run outside hazel:
The first commented lines define the prefix but I guess user interaction in scripts in hazel is not allowed (I got an error message about this), am I right?
So without user interaction the script simply creates a ToDo in Things which appears at it follows:
The point is that if I run the script from an hazel rule I get an error message: "Can't make POSIX path of \"\" "
So two questions:
- What am I missing?
- some real scripter can write a better code? For example I was not able to find a way to create a more "elegant" name for the clickable link instead of the file path....
Thanks, any help appreciated

I'm almost a newbie here.
I'm trying to let automagically interact Things (ToDo list app) with the finder through an hazel rule.
A typical situation is: I receive a file in mail and I want to remember to process it (read, sign or whatever).
The workflow ideally would be:
- while saving the file adding a finder tag (for hazel to process the file)
- running an applescript that:
1.get the name of the file
2. get the file path of the file to create a clickable link in things notes
3. open a dialog to choose the prefix for the name of the todo in things (i.e.: choose between "read", "sign", "whatever"
I'm not a scripter but I managed to write a script that works when run outside hazel:
- Code: Select all
--set actionChoices to {"1. Leggi:", "2. Studia:", "3. Process:"}
--set theChoice to choose from list actionChoices with prompt "Cosa --vuoi fare con questo file?:" default items {"Leggi:"}
--theChoice
--set myChoice to theChoice as text
tell application "Finder"
set theFile to the selection as text
set finderSelList to selection as alias list
if finderSelList ≠ {} then
tell application "System Events"
if quit delay ≠ 0 then set quit delay to 0
repeat with i in finderSelList
set contents of i to name of (contents of i)
end repeat
end tell
set AppleScript's text item delimiters to linefeed
finderSelList as text
end if
set the clipboard to "file://" & POSIX path of theFile
tell application "Things3"
set newToDo to make new to do ¬
with properties {name:"Process:" & finderSelList, notes:the clipboard}
end tell
end tell
The first commented lines define the prefix but I guess user interaction in scripts in hazel is not allowed (I got an error message about this), am I right?
So without user interaction the script simply creates a ToDo in Things which appears at it follows:
Process: NAME OF THE FILE
[Notes] clickable link in the form of "file:///Users/whatevere/mypdf.pdf
The point is that if I run the script from an hazel rule I get an error message: "Can't make POSIX path of \"\" "
So two questions:
- What am I missing?
- some real scripter can write a better code? For example I was not able to find a way to create a more "elegant" name for the clickable link instead of the file path....
Thanks, any help appreciated
