They all open a new window so you don’t loose your context in your current window.
This one sets the focus to the search field, ready to type:
-- New window and focus search field
activate application id "DNtp"
tell application "System Events"
tell process "DEVONthink 3"
keystroke "n" using {option down, command down}
delay 0.2
repeat with i from 1 to 10
try
set focused of text field 1 of group i of toolbar 1 of window 1 to true
exit repeat
end try
end repeat
end tell
end tell
This one sets the search field to the given text, e.g. a search prefix you use often and don’t want to type over and over again:
-- Set search field to text
activate application id "DNtp"
tell application "System Events"
tell process "DEVONthink 3"
keystroke "n" using {option down, command down}
delay 0.2
repeat with i from 1 to 10
try
set focused of text field 1 of group i of toolbar 1 of window 1 to true
set value of text field 1 of group i of toolbar 1 of window 1 to "name:"
--key code 36
exit repeat
end try
end repeat
end tell
end tell
The one above can also be used to directly start the search, just uncomment key code 36 (but if you don’t want to interact with the search field I think using search query from the dictionary makes more sense.)
The last one deletes the search field:
-- Delete search field
activate application id "DNtp"
tell application "System Events"
tell process "DEVONthink 3"
repeat with i from 1 to 10
try
set focused of text field 1 of group i of toolbar 1 of window 1 to true
set value of text field 1 of group i of toolbar 1 of window 1 to ""
exit repeat
end try
end repeat
end tell
end tell
If they at some point don’t work reliably try adjusting the delay. I don’t know the maximum of toolbar groups in DEVONthink 3, so if setting the delay doesn’t work try to set the repeat times higher.
Strange! After updating to Beta3 these aren’t working.
For one of the scripts, It brings up the window but the cursor(focus) doesn’t go to the search field and for the other it doesn’t execute the word I have input.
activate application id “DNtp”
tell application “System Events”
tell process “DEVONthink 3”
repeat with i from 1 to 10
try
set focused of text field 1 of group i of toolbar 1 of window 1 to true
set value of text field 1 of group i of toolbar 1 of window 1 to “”
exit repeat
end try
end repeat
end tell
end tell
activate application id “DNtp”
tell application “System Events”
tell process “DEVONthink 3”
keystroke “n” using {option down, command down}
delay 0.2
repeat with i from 1 to 10
try
set focused of text field 1 of group i of toolbar 1 of window 1 to true
set value of text field 1 of group i of toolbar 1 of window 1 to “choose”
–key code 36
exit repeat
end try
end repeat
end tell
end tell
You have curly quotes. Paste the code you posted in Script Editor and try to compile it. It won’t. Replace them with straight quotes (or copy the scripts from my first post) and it should work. I’ve got no idea how Beta 3 could have changed the quotes and believe that it doesn’t. However if you change scripts in the script menu restart DEVONthink 3 afterwards.
Thanks Pete but still not working.
I copied from your posts and pasted it in Scrip editor and still it doesn’t work
I even changed the delay to higher than 0.2 but still not working.
The scrip runs and It does bring up a new window but that’s it.
Set the repeat to 20 or even higher. I don‘t know how many UI groups the toolbar can have. If you use a large screen and added many toolbar items 10 repeats may not be enough (see my first post)z