How to script this? (create a list of search results or a smart group)

I always assign a unique identifier (UID) as the prefix of the name (and also as aliases now) of each reference article/material and always include the UID in my notes whenever I cite or reference to the article/material. For me, using UID is a more efficient way of search than using author name or academic citation format in the environment of DT2/3. When I need to find where/how/what I have cited/used a specific article/material, I can obtain the precise search results by entering the UID and with a scope.

There are many ways to automate the process, but the most suitable way for me is to produce the same outcome of a direct search entry or a smart group (i.e. a main window with a list of hits) by:
(1) create a new main window and use system events to send a string to search field such as (myUID) scope:(the group/s for my notes). But sending keystrokes and string doesn’t seems like the best way.
(2) Is there a way to create a smart group by script? (I have over a thousand of reference article/material so pre-creating smart groups is neither feasible nor necessary)
(3) Can this be achieved by a search URL with an UID as global search string in a database, and can I specify a search scope in the URL (I’m guessing no)?

Thanks in advance

You could set the “search query” of viewer windows to perform a search, e.g.

tell application id "DNtp" to set search query of viewer window 1 to "kind:any"

In version 3 that’s also possible but limited to local smart groups inside databases. Here’s a simple example:

tell application id "DNtp"
	set theRecord to create record with {name:"test", type:smart group} in current group
	set search predicates of theRecord to "kind:any"
end tell

This is perfect!
Thanks you very much again!