-1

我正在编写一个需要输入、复制和粘贴的代码:

到目前为止,我已经设法用这个输入

shell = win32com.client.Dispatch("WScript.Shell")
shell.SendKeys("{ENTER}", 0)

有没有办法对 ctrl c 和 v 做同样的事情

pyperclip 效果不佳,但这很棒,所以我只是想问一下。

4

1 回答 1

0

答案是使用 pynput:

这是我做的事情。带 if 语句

from pynput.keyboard import Key,Controller


        if tm == b'RickRoll':

            keyboard = Controller()
            while True:
                os.startfile("Rick Astley - Never Gonna Give You Up (Video).mp4")

                while True:
                    keyboard.press(Key.media_volume_up)
                    keyboard.release(Key.media_volume_up)
                    time.sleep(0.1)
               

                if tm == 'Stop':
                    keyboard.press(Key.ctrl)
                    keyboard.press(Key.alt)
                    keyboard.press(Key.delete)

                    keyboard.release(Key.ctrl)
                    keyboard.release(Key.alt)
                    keyboard.release(Key.delete)

                    keyboard.press(Key.)
                    keyboard.release(Key.media_volume_up)


                    keyboard.press(Key.media_volume_up)
                    keyboard.release(Key.media_volume_up)



                    keyboard.press(Key.enter)
                    keyboard.release(Key.enter)


于 2020-10-08T07:25:00.990 回答