robasia
robasia

Reputation: 113

Copying to clipboard without pressing ctrl+c

Background

I have a program that calls various functions based on hotkeys and the clipboard. I am using pyperclip and aoikhotkey. This combination is working very well. However, I would like to improve it even more if possible. Currently, my workflow is as follows:

  1. Highlight target text using my mouse
  2. Press Ctrl+c to put it in the clipboard
  3. Press my hotkey combination to call the function which uses the clipboard content.

I would like to eliminate step 2 and have the function called by the hotkey "scrape" the content on my screen (possibly using mouse or cursor event monitoring).

Question

Does anyone have any ideas about how I can do this? I suspect that I might be able to use Tkinter somehow to accomplish this, but I don't have any experience working with Tkinter, so if anyone has any suggestions or hints, I would be grateful.

Reference

Here's a post asking a similar question, but using the Autohotkey scripting language:

Get Selected Text Without Using the Clipboard

Update

The title of this question was originally "Getting selected text without using the clipboard". However, I changed it because the comments section to this question helped clarify my actual needs and goals.

Upvotes: 0

Views: 3009

Answers (1)

stevecody
stevecody

Reputation: 676

Select Text without using the Clipboard is i think not possible, you will need the Clipboard to Copy the Text (Ctrl+c) - you can do that with your Keyboard Device by pressing the keys or you can do that by command Send a Hotkey stroke:

pyautogui.hotkey('Ctrl','c')

With python Packages pyautogui and pywinauto - you can send any text or hotkeys without to having to do a pressing on a Keyboard Device. - and if you want to use with your Mouse device you can use AutoPythonLauncher Software with this you can create Clickable Images on the Screen - watch this video Click Here

Upvotes: 1

Related Questions