Accessing clipboard through software built on Python

Thomas Jollans tjol at tjol.eu
Sun Oct 28 15:58:34 EDT 2018


On 27/10/2018 20:50, Musatov wrote:
> On Saturday, October 27, 2018 at 11:12:35 AM UTC-5, Marko Rauhamaa wrote:
>> Michael Torrie <torriem at gmail.com>:
>>> As far as I know it's not possible for an application to directly yank
>>> highlighted text from another application.
>>
>> That's an age-old pattern in X11. I don't know if Wayland supports it.
>>
>> Application 1 holds a selection (usually highlighted) and Application 2
>> wants to copy the selection. No clipboard is needed. Application 2
>> simply asks for the selection. The request is relayed to Application 1,
>> which generates the response:
>>
>> <URL: https://en.wikipedia.org/wiki/X_Window_selection#Selections>
>>
>>
>> Marko
> 
> I work from a web database of users and I continually have to copy email address and user ID to two separate fields on a Salesforce.com page.
> 
> I go to the webpage, highlight email address then copy.
> Then go to Salesforce page, and paste.
> Then go back to the webpage, then copy the User ID.
> Then go back to Salesforce page, and paste.
> 
> I think it would be much more efficient to:
> On webpage, copy emailaddress and user ID.
> Then go to Salesforce and paste email address and user ID.
> 

As this is all on the web, it's probably easier to work in the browser
rather than at the display manager level, i.e.: build a browser
extension or something instead. You'll almost certainly have easier
access to selected text (not in Python, though).

Really though you might want to take a step back and take the web page
out the the equation completely. Salesforce must have an API, right? And
the email addresses you're copying are presented in some regular format
you might be able to parse (using beautifulsoup or something)? Or maybe
the data source has an API, even? Or a database you can access?

Surely, you could write a program that somehow gets (all) the data you
want to copy from whatever server you get them from, gives you an
opportunity to do whatever checks you have to do by hand, and then feeds
the data into the database they go in in the end – or gives the data to
you in a format that makes that last step easy. Right?

All I'm saying is: if you're going to try to automate a job, you might
as well do it with conviction ^_^

If you insist on getting the selected text with something like
autohotkey, my hunch is that the simplest way to do this would be to
inject Ctrl+C, wait a moment, and then retrieve the clipboard content.



More information about the Python-list mailing list