Here’s a new version that doesn’t rely on the presence of the inbox alias in the sidebar.
It does rely on the macOS shortcut ⇧⌘G that opens a sheet in save dialogs in which the user can type a path. So if you’re using this shortcut e.g. in Keyboard Maestro make sure your macro doesn’t overwrite the shortcut in Finder.
Please give it a try.
-- Import selected Thunderbird mail(s) into DEVONthink inbox
set thePath to POSIX path of (path to application support from user domain) & "DEVONthink 3/Inbox"
activate application "Thunderbird"
tell application "System Events"
tell process "Thunderbird"
try
set theMenuItem to a reference to menu item 1 of menu 1 of menu item 7 of menu 1 of menu bar item 3 of menu bar 1
if enabled of theMenuItem = false then error "Please select some mails"
click theMenuItem
set foundDialog to false
repeat 20 times
if subrole of window 1 = "AXDialog" then
set foundDialog to true
exit repeat
else
delay 0.1
end if
end repeat
if foundDialog = false then error "No dialog found"
try
keystroke "g" using {command down, shift down}
set foundSheet to false
repeat 20 times
if sheet 1 of window 1 exists then
set foundSheet to true
exit repeat
else
delay 0.1
end if
end repeat
if foundSheet = false then error "No sheet found"
set value of combo box 1 of sheet 1 of window 1 to thePath
key code 36
delay 0.2
key code 36
on error
error "Can't set path in sheet"
end try
on error error_message number error_number
if the error_number is not -128 then
tell application id "DNtp"
activate
display alert "Thunderbird" message error_message as warning
end tell
return
end if
end try
end tell
end tell
tell application id "DNtp" to activate