My Program should send whatsapp message using pywhatkit library by taking input from user by speech recognition.
This is the function that send message.
def WhatsApp():
speak("For Whom should i send message")
Contacts = {
'mom' : 63XXXXXXX, # these are numbers (hidden)
'karthik' : 75XXXXXXx,
'me' : 81XXXXXXX,
'jayaram' : 99XXXXXXXX
}
to = takeCommand() #takes my voice input using speech_recognition
speak("what message should i send")
msg = takeCommand()
speak(f"sending message to {to}")
try:
pwt.sendwhatmsg_instantly(f"+91{Contacts[to]}",msg,5,True,15)
except Exception as e:
speak(f"error sending message")
print(e)
When i say send whatsapp message to my Voice assistant it will ask me for whom to send and what msg it should send.
I used pywhatkit send whatsapp msg instantly function so that msg could send fastly but its just opening whatsapp web and returning back.
My Problem :
Note:
Please help me find a better way to do this sending message instantly through pywhatkit and to solve the error.
Try to use pyautoguit
module. Add pyautogui.press(“enter”)
after
pwt.sendwhatmsg_instantly(f"+91{Contacts[to]}",msg,5,True,15)
Also, there is can be issues if you use multiple displays.