-
Notifications
You must be signed in to change notification settings - Fork 24
/
Selection.applescript
36 lines (28 loc) · 1.13 KB
/
Selection.applescript
1
use sys : application "System Events"-- Use the following delay to choose an application window-- and highlight some text. Then ensure that the window remains-- in focus until the script terminates.delay 5set P to the first process whose frontmost is trueset _W to a reference to the first window of Pset _U to a reference to ¬ (UI elements of P whose ¬ name of attributes contains "AXSelectedText" and ¬ value of attribute "AXSelectedText" is not "" and ¬ class of value of attribute "AXSelectedText" is not class)tell sys to if (count _U) ≠ 0 then ¬ return the value of ¬ attribute "AXSelectedText" of ¬ _U's contents's first itemset _U to a reference to UI elements of _Wtell sys to repeat while (_U exists) tell (a reference to ¬ (_U whose ¬ name of attributes contains "AXSelectedText" and ¬ value of attribute "AXSelectedText" is not "" and ¬ class of value of attribute "AXSelectedText" is not class)) ¬ to if (count) ≠ 0 then return the value of ¬ attribute "AXSelectedText" of its contents's first item set _U to a reference to (UI elements of _U)end repeat"No selection found."