from tkinter import *
import time
from pyperclip import copy
import pyautogui as g
root = Tk()
root.title('连续发送器(怼人神器)')
root.geometry('480x400')
def paste(chinese):
if(v_c.get()==3):
copy(chinese)
g.hotkey('command', 'v')
else :
copy(chinese)
g.hotkey('ctrl', 'v')
# pyinstaller -F -w text.py
def a():
a_g = str(a.get('0.0', 'end'))
b_g = int(b.get())
c_g = int(c.get())
time.sleep(c_g)
#g.moveTo(1588, 802, duration = 1)
#g.click()
if (v_c.get()) == 1:
for i in range(b_g):
# 输入l like python
#g.typewrite(a_g)
paste(a_g)
# 按下回车
g.press('enter')
time.sleep(0.01)
elif (v_c.get()) == 2:
for i in range(b_g):
# 输入l like python
#g.typewrite(a_g)
paste(a_g)
# 按下回车
g.press('ctrl'+'enter')
time.sleep(0.01)
elif (v_c.get()) == 3:
for i in range(b_g):
# 输入l like python
#g.typewrite(a_g)
paste(a_g)
# 按下回车
g.press('enter')
time.sleep(0.01)
frame = Frame(root)
frame.place(x = 120, y = 50)
b = Button(root, text = '发送(迅速点击发送窗口)', font = ('楷书', 18), command = a)
b.place(x = 10, y = 340)
Label(root, text = ' 内容 ', font = ('楷书', 18)).place(x = 10, y = 50)
gun_song_tiao_y = Scrollbar(frame)
gun_song_tiao_x = Scrollbar(frame, orient=HORIZONTAL)
a = Text(frame, font = ('楷书', 14), fg = 'blue', width=30, height=10 ,wrap='none')
gun_song_tiao_y.pack(side=RIGHT,fill=Y)
gun_song_tiao_x.pack(side=BOTTOM, fill=X)
a.pack()
gun_song_tiao_y.config(command=a.xview)
gun_song_tiao_x.config(command=a.yview)
a.config(yscrollcommand=gun_song_tiao_y.set)
a.config(xscrollcommand=gun_song_tiao_x.set)
Label(root, text = '发送次数', font = ('楷书', 18)).place(x = 10, y = 300)
var1 = StringVar()
var1.set('20')
b = Entry(root, font = ('楷书', 18), fg = 'blue', textvariable=var1)
b.place(x = 120, y = 300)
var = StringVar()
var.set('5')
Label(root, text='准备时间', font = ('楷书', 18)).place(x = 10, y = 10)
c = Entry(root, font = ('楷书', 18), fg = 'blue', textvariable=var)
c.place(x = 120, y = 10)
Label(root, text='发送方式', font = ('楷书', 18)).place(x=10, y=250)
v_c = IntVar()
v_c.set(1)
enter_r = Radiobutton(root ,text='Enter' ,font = ('楷书', 17), variable = v_c, value=1)
enter_r.place(x=120, y=250)
c_enter_r = Radiobutton(root, text='Ctrl+Enter', variable = v_c, value=2 ,font = ('楷书', 17))
c_enter_r.place(x=200 ,y=250)
c_enter_r = Radiobutton(root, text='Enter(MAC)', variable = v_c, value=3 ,font = ('楷书', 17))
c_enter_r.place(x=310 ,y=250)
root.mainloop()