I have an AppleScript that I run from the toolbar. Its purpose is to rename an item (such as a PDF file) based upon similar items found by “See Also”. The script opens a dialog box and presents a list of possible names to choose between, along with “cancel” and “OK” buttons. If you click on a choice and click on “OK”, the name of the item is changed to that chosen from the dialog box.
The script works fine, but here’s my question. Before I run the script, the item is highlighted in blue. After I run the script and the item has been renamed, it is now highlighted in gray rather than blue. I would prefer that the item stay blue, since what I usually do next is type “Control-C” to file the item in the proper group, and that requires the item to be highlighted in blue, not gray, I just get the “error doink sound” if I type “Control-C” when the item is gray. I first have to click on the item to make it blue again, and then I can type “Control-C”.
This is how the script ends:
set name of theRecord to choiceName
end tell
Is there something else I can add to the script after “set name” to highlight theRecord to be blue rather than gray? Thanks!
@pete31, you’re absolutely right, the script is taking the focus. However, I just tried both “activate” on its own, and then "activate application “DEVONthink 3"”, but neither worked. Thanks anyway!
Thanks. Your script works fine over here, after choosing from the dialog the focus is back on the item list (i.e. the selected record is highlighted in blue).
I’m still on macOS 10.14.6, so this might explain the difference (but I don’t think so).
How are you running the script? Via DEVONthink’s script menu?
I’m on MacOS 12.4. I’m running the script in the toolbar by adding it to Library/Application Scripts/com.devon-technologies.think3/Toolbar . I’ll try via the script menu instead and see if that makes a difference.
set theChoice to choose from list chooseFromListItems & {theWidthPlaceholder} with prompt "Rename record to:" default items (item 1 of chooseFromListItems) with title ""
with
tell application "SystemUIServer"
activate
set theChoice to choose from list chooseFromListItems & {theWidthPlaceholder} with prompt "Rename record to:" default items (item 1 of chooseFromListItems) with title ""
end tell
activate
@pete31 I just wanted to thank you again - keeping my fingers on the keyboard has really sped up my workflow. BTW, I now have the script both on the toolbar and in the script menu, and I use the latter to customize keyboard shortcuts (in Apple Preferences) for DT to have an app keyboard shortcut for the script. Works great!
Just one minor note:
Instead of parent 1 I would recommend to use location group as this property is identical to the location shown in the user interface whereas parent 1 might also be a tag but not the shown location.