首页 > 解决方案 > python中的Pywhatkit不向whatsapp组发送消息

问题描述

我正在使用 tkinter 并在 gui 中获取用户的输入,并通过单击按钮在 pywhatkit 的帮助下发送消息,但它只是打开 whatsapp(仅打开组 whatsapp)而且它没有给我任何错误请告诉我怎么能我解决它

编辑 - 现在我收到一个错误 -

whats = pg.getWindowsWithTitle("WhatsApp")[0]
IndexError: list index out of range

我的代码 -

# Text Box for mobile number and text

mobileNumber = Text(root, height=1, width=20, font="Calibri")
text = Text(root, height=4, width=17, font="Calibri")

hour = Text(root, height=1, width=20, font="Calibri")
minute = Text(root, height=1, width=20, font="Calibri")

# creating button


def click():
    finalMobileNumber = mobileNumber.get(1.0, "end-1c")
    finalText = text.get(1.0, "end-1c")
    finalText = str(finalText)
    finalHour = hour.get(1.0, "end-1c")
    finalHour = int(finalHour)
    finalMinute = minute.get(1.0, "end-1c")
    finalMinute = int(finalMinute)

我只在 if 语句中遇到问题

if "https" in finalMobileNumber:
    pywhatkit.sendwhatmsg_to_group(finalMobileNumber, finalText, finalHour, finalMinute)
else:
    pywhatkit.sendwhatmsg("+91" + finalMobileNumber, finalText, finalHour, finalMinute)


btn = Button(root, text="Send Message", command=click)

标签: python

解决方案


推荐阅读