Thursday, August 16, 2018

#1 2018-06-04 10:54:46 pm

jbh
Member
Registered: 2017-04-05
Posts: 5

applescript to copy text which extends off page

I'm trying to use applescript to copy the text which lies between two known UI elements in a Safari window.  Using cliclick and  Applescript Toolbox I can see how to select the relevant text if the two critical UI elements are both visible in the window (because their screen co-ordinates can be found).  But what if  one of the UI elements lies outside the screen?  Is there a way of selecting the text for copying under those circumstances?


Filed under: safari, applescript

Offline

 

#2 2018-06-05 02:17:53 pm

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 282

Re: applescript to copy text which extends off page

If you know the UI elements, I'd forget about UI scripting with clickclick and just get the page source and locate the HTML for the known UI elements and grab the text between them.

Applescript:


tell application "Safari" to set pageHTML to source of the front document

That text may contain additional HTML or CSS formatting elements that need to be removed... or maybe you need to render those elements and copy the resulting rich text? I still think it would be easier and more reliable to deal with those issues than to UI script it.

If you can point us to an example webpage and let us know what the UI delimiters are, we might be able to be more helpful.


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)