I use 10.8.5.
It looks to me like the problem may not so much the script, but what’s being passed to the script. Adding some code that logs the class of lemma might help clarify things.
It’s class text. I log it with the following test action when the look up action is stuck in setting the clipboard ” which seems to unstuck it, sometimes.
using terms from application "Quıcĸsıɩⅴεʀ"
on process text theObjs
(* on open files theObjs *)
-- TEST
(* begin test script *)
set the clipboard to theObjs
do shell script "logger -t 'AS DEBUG' dO value: " & theObjs & " - class: " & class of theObjs
(* end test script *)
-- DEBUG
--do shell script "echo " & quoted form of (theObjs as text) & " > ~/Desktop/as_debug.txt"
try
do shell script ¬
"echo 'STRING :: '" & quoted form of theObjs & " > ~/Desktop/as_debug.txt"
on error errMsg
do shell script ¬
"echo 'ERROR :: '" & quoted form of errMsg & " > ~/Desktop/as_debug.txt"
do shell script ¬
"echo 'STRING :: '" & quoted form of (theObjs as string) & " >> ~/Desktop/as_debug.txt"
end try
(* repeat with theObj in theObjs as list
--do shell script "logger -t 'AS DEBUG' " & theObj
--do shell script "echo " & theObj & " >> ~/Desktop/as_debug.txt"
end repeat *)
(* set myFile to open for access (path to desktop as text) & "as_debug.txt" with write permission
write theObjs to myFile
close access myFile *)
(* end open files *)
end process text
(* on get direct types
return {"NSFilenamesPboardType"} -- files and folders
return {"NSStringPboardType"} -- text or a string
return {"Apple URL pasteboard type"} -- URLs
return {"qs.command"} -- Quicksilver command
end get direct types *)
end using terms from
I fear you’re just hitting a bug. If com.apple.foundation.UserScriptService is being run each time, the script is being run via the mechanism designed for sandboxed apps – they are getting passed to a separate process for execution. I’m not sure what you can do to debug that, but you should probably log a bug with Apple (while not holding your breath; it sounds like it might be difficult to reproduce).
As I said it happens randomly ” if I see com.apple.foundation.UserScriptService, quit it and rerun the action, it sometimes runs as expected, then Quicksilver logs the error message from the first failed execution.
What I also found strange is the form of the error: “[value of var] doesn’t understand the set the clipboard to message”.
I’m testing some workarounds. One of them is
do shell script "echo " & quoted form of lemma & " | pbcopy"
instead of
set the clipboard to lemma
but then I need to add a backspace
keystroke "v" using {command down}
key code 51
keystroke return
as pasting adds a newline.
Maybe you guys know a more elegant way to circumvent this.