Accessing clipboard through software built on Python

2018-10-27 Thread Musatov
I am wondering if Python could be used to write a program that allows:

1. Highlight some text
2. Ctl+HOTKEY1 stores the string of text somewhere as COPIEDTEXT1
3. Highlight another string of text
4. Ctl+HOTKEY1 stores another string of text somewhere as COPIEDTEXT2

THEN

5. Ctl+HOTKEY2 pastes COPIEDTEXT1
6. Ctl+HOTKEY2 pastes COPIEDTEXT2

I found "pyperclip" and "Tkinter" but I don't know where to start.

Thanks,

Musatov
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Accessing clipboard through software built on Python

2018-10-27 Thread Michael Torrie
Couple of questions:
On 10/27/2018 07:17 AM, Musatov wrote:
> I am wondering if Python could be used to write a program that allows:
> 
> 1. Highlight some text
> 2. Ctl+HOTKEY1 stores the string of text somewhere as COPIEDTEXT1

This text comes from where?  Another application?

> 3. Highlight another string of text
> 4. Ctl+HOTKEY1 stores another string of text somewhere as COPIEDTEXT2
> 
> THEN
> 
> 5. Ctl+HOTKEY2 pastes COPIEDTEXT1

Gets pasted where?

> 6. Ctl+HOTKEY2 pastes COPIEDTEXT2

As far as I know it's not possible for an application to directly yank
highlighted text from another application.  The first application would
have to first copy that text to the clipboard (Control-C in that app)
and then the second application could grab it from the clipboard
(ctrl-hotkey1) and then store it in its own variables.  Ctrl-hotkey2
could then push the text back into the clipboard and then you can ctrl-V
paste it in the other application.  This type of functionality is known
often found in clipboard manager programs.

> I found "pyperclip" and "Tkinter" but I don't know where to start.
Here's another file that demonstrates accessing the clipboard on the
Linux, Mac, and Windows:

https://github.com/Shizmob/clippy/blob/master/clip.py

As for the hotkey stuff, that's also dependent on the operating system.
Google for something like "python global hotkey linux" to get an example
of how to implement that.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Accessing clipboard through software built on Python

2018-10-27 Thread Marko Rauhamaa
Michael Torrie :
> 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:

https://en.wikipedia.org/wiki/X_Window_selection#Selections>


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Accessing clipboard through software built on Python

2018-10-27 Thread Bob Gailer
On Oct 27, 2018 9:20 AM, "Musatov"  wrote:
>
> I am wondering if Python could be used to write a program that allows:
>
> 1. Highlight some text
> 2. Ctl+HOTKEY1 stores the string of text somewhere as COPIEDTEXT1
> 3. Highlight another string of text
> 4. Ctl+HOTKEY1 stores another string of text somewhere as COPIEDTEXT2
>
> THEN
>
> 5. Ctl+HOTKEY2 pastes COPIEDTEXT1
> 6. Ctl+HOTKEY2 pastes COPIEDTEXT2
>

What operating system are you using? If it is Windows I recommend you take
a look at a program called autohotkey.
> I found "pyperclip" and "Tkinter" but I don't know where to start.
>
> Thanks,
>
> Musatov
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Accessing clipboard through software built on Python

2018-10-27 Thread Musatov
On Saturday, October 27, 2018 at 10:28:00 AM UTC-5, Michael Torrie wrote:
> Couple of questions:
> On 10/27/2018 07:17 AM, Musatov wrote:
> > I am wondering if Python could be used to write a program that allows:
> > 
> > 1. Highlight some text
> > 2. Ctl+HOTKEY1 stores the string of text somewhere as COPIEDTEXT1
> 
> This text comes from where?  Another application?
>From a webpage.
> 
> > 3. Highlight another string of text
> > 4. Ctl+HOTKEY1 stores another string of text somewhere as COPIEDTEXT2
> > 
> > THEN
> > 
> > 5. Ctl+HOTKEY2 pastes COPIEDTEXT1
> 
> Gets pasted where?
Unto a savable field on another webpage.
> 
> > 6. Ctl+HOTKEY2 pastes COPIEDTEXT2
> 
> As far as I know it's not possible for an application to directly yank
> highlighted text from another application.  The first application would
> have to first copy that text to the clipboard (Control-C in that app)
> and then the second application could grab it from the clipboard
> (ctrl-hotkey1) and then store it in its own variables.  Ctrl-hotkey2
> could then push the text back into the clipboard and then you can ctrl-V
> paste it in the other application.  This type of functionality is known
> often found in clipboard manager programs.
Yes, I understand but they all involve putting one piece of text unto the 
clipboard at a time.

I want COPYFIELD1
   COPYFIELD2
   PASTEFIELD1
   PASTEFIELD2

Without having to look at the damn clipboard manager! And no more than two 
hotkey combinations.

It would make my job so much easier, and easier for many other workers doing 
the same job.
> 
> > I found "pyperclip" and "Tkinter" but I don't know where to start.
> Here's another file that demonstrates accessing the clipboard on the
> Linux, Mac, and Windows:
> 
> https://github.com/Shizmob/clippy/blob/master/clip.py
Thank you.> 
> As for the hotkey stuff, that's also dependent on the operating system.
> Google for something like "python global hotkey linux" to get an example
> of how to implement that.
Ok
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Accessing clipboard through software built on Python

2018-10-27 Thread Musatov
On Saturday, October 27, 2018 at 11:12:35 AM UTC-5, Marko Rauhamaa wrote:
> Michael Torrie :
> > 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:
> 
> 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.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Accessing clipboard through software built on Python

2018-10-27 Thread Musatov
On Saturday, October 27, 2018 at 11:40:57 AM UTC-5, Bob Gailer wrote:
> On Oct 27, 2018 9:20 AM, "Musatov"  wrote:
> >
> > I am wondering if Python could be used to write a program that allows:
> >
> > 1. Highlight some text
> > 2. Ctl+HOTKEY1 stores the string of text somewhere as COPIEDTEXT1
> > 3. Highlight another string of text
> > 4. Ctl+HOTKEY1 stores another string of text somewhere as COPIEDTEXT2
> >
> > THEN
> >
> > 5. Ctl+HOTKEY2 pastes COPIEDTEXT1
> > 6. Ctl+HOTKEY2 pastes COPIEDTEXT2
> >
> 
> What operating system are you using? If it is Windows I recommend you take
> a look at a program called autohotkey.
> > I found "pyperclip" and "Tkinter" but I don't know where to start.
> >
> > Thanks,
> >
> > Musatov
> > --
> > https://mail.python.org/mailman/listinfo/python-list

I will look at autohotkey.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Accessing clipboard through software built on Python

2018-10-27 Thread Marko Rauhamaa
Musatov :

> 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.

Theoretically possible. In practice, probably not so much because both
applications must be aware of a special user-id-plus-email-address
selection data type.

What should be possible, though is:

 * select the email address with the left mouse button on the web page
 * middle click on the Salesforce page to copy it there
 * same for the user name

Similarly, drag-and-drop should work.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Accessing clipboard through software built on Python

2018-10-27 Thread Gregory Ewing

Musatov wrote:

From a webpage.


Does it always come from the same web site? If so, you may be able
to scrape the web page to get the username and address, and then
have hot keys for pasting them.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: Accessing clipboard through software built on Python

2018-10-27 Thread Musatov
Yes, same site every time.
-- 
https://mail.python.org/mailman/listinfo/python-list


Is it possible to connect an awaitable to a Future, basically turning it into a Task?

2018-10-27 Thread Russell Owen

I’m using asyncio and I’d like to add an item to an object that others 
can wait on immediately and which eventually I will want to use to track a 
coroutine. In other words I want something like:

class Info:
def __init__(self):
self.done_task = asyncio.Future()

info = Info()
# do other stuff, but eventually
coro = ...
asyncio.connect_future(coro, info.done_task)

I can certainly live without this, it simply requires adding an additional 
task made with asyncio.ensure_future and using that to set the result of 
done_task.

But it would be a lot more elegant to just have the one future (especially if 
I have to cancel the wait, as I have to keep the extra task around so I can 
cancel it). So...just wondering if I missed something.

Regards,

Russell


-- 
https://mail.python.org/mailman/listinfo/python-list