How to save multiple things from clipboard and then paste them all at once into google sheets

Viewed 90

My idea is to be able to save a list of items from the windows clipboard, then press a keybind to paste them into google sheets (each on their own line), clearing the contents of the list at the same time. Outside of this the clipboard would function normally, so maybe some sort of option to toggle when it starts saving items as a list would be needed.

In my head it sounds like something that would be theoretically possible, but I have extremely minimal coding skills so I don't know where to start...

I appreciate any help!

Edit: Got it to work!

import pyperclip
import win32api
import pyautogui
import time

def main(alist,n):
    pyperclip.copy("")
    while True:
        alt    = win32api.GetAsyncKeyState(0xA4)
        v      = win32api.GetAsyncKeyState(0x56)
        lclick = win32api.GetAsyncKeyState(0x01)
        time.sleep(0.1)
        if alt and v:
            if n == 1:
                n = 0
                time.sleep(.5)
                pyperclip.copy("")
                while alist != []:
                    astring = alist[0]
                    pyautogui.write(astring)
                    time.sleep(0.05)
                    pyautogui.press("enter", presses=1)
                    time.sleep(0.05)
                    del alist[0]
        if lclick:
            time.sleep(0.05)
            data = pyperclip.paste()
            if data[:3] == "41.":
                if len(alist) != 0:
                    if data != (alist[-1]):
                        n = 1
                        alist.append(data)
                if len(alist) == 0:
                    n = 1
                    alist.append(data)
main([],0)```
0 Answers
Related