You are not logged in.
In this example we will return the string from NSPasteboardNameFind
Its pasteboard type of command+f or in english "Find..."
When we use that command we could search for a string in document. We could also return that
string from ASObjC.
So type anything in textfield of find command in any application, press done, run the script below.
ex.
Applescript:
use framework "Foundation"
use framework "AppKit"
use scripting additions
set pasteboardFind to current application's NSPasteboard's pasteboardWithName:(current application's NSPasteboardNameFind)
set rawData to (current application's NSString's alloc()'s initWithData:(pasteboardFind's dataForType:"public.utf8-plain-text") encoding:(current application's NSUTF8StringEncoding)) as text
Applescript:
use framework "Foundation"
use framework "AppKit"
use scripting additions
-- Set NSPasteboardNameFind
set theString to (display dialog "" default answer "")'s text returned
set pasteboardFind to current application's NSPasteboard's pasteboardWithName:(current application's NSPasteboardNameFind)
pasteboardFind's setString:(current application's NSString's stringWithString:theString) forType:"public.utf8-plain-text"
-- Get NSPasteboardNameFind
set rawData to (current application's NSString's alloc()'s initWithData:(pasteboardFind's dataForType:"public.utf8-plain-text") encoding:(current application's NSUTF8StringEncoding)) as text
-- Or
set thePasteboardFind to pasteboardFind's stringForType:"public.utf8-plain-text") as text
Last edited by Fredrik71 (2021-01-10 08:59:44 am)
The purpose to study someone else art is not to add, its to make less more.
Offline