Although ProFind has an Apple Script dictionary, it provides only rudimentary (=useless) functionality. So you have to use UI scripting to be able to execute even simple searches, which is quite a bit cumbersome. But it works, and is fast enough, especially if ProFind is already running, despite the many security-repeat-loops in my code.
Holding the option key while clicking on the [PF] icon in PopClip will only set PF’s search field to the selected value but not execute a search, thus giving you the opportunity to add / change the many search parameters PF provides before actually executing the search using return - you have to turn “Start Searches Automatically” in PF’s preferences to make that work. I guess you should have that one turned off anyway, because automatic search may (or may not?) interfere with UI scripting under certain circumstances.
And BTW, delete or comment out the last line of the script bevor installing if you do not want to find PopClip’s text selection on the clipboard automagically.
Hoping that somebody can make use of it.
Copy the code below into a text file named “ProFind.popcliptxt” and double click the file to install it in PopClip.
-- #popclip
-- name: ProFind
-- icon: square PF
-- language: applescript
on isOptionPressed(modFlags)
return ((modFlags div 524288) mod 2) = 1
end isOptionPressed
set modFlags to "{popclip modifier flags}" as integer
--display dialog modFlags
set popClipText to "{popclip text}"
tell application "ProFind" to activate
repeat
tell application "Finder" to set processPFExists to exists application process "ProFind"
if processPFExists then exit repeat
delay 0.2
end repeat
tell application "System Events"
tell process "ProFind"
repeat
if exists window 1 then exit repeat
delay 0.2
end repeat
tell text field 1 of window 1
set focused to true
repeat
set value to popClipText
delay 0.2
if value is popClipText then exit repeat
end repeat
if my isOptionPressed(modFlags) is false then
keystroke return
end if
end tell
end tell
end tell
set the clipboard to popClipText