Ankit404butfound / PyWhatKit

Send WhatsApp message at certain time and many other things.
MIT License
1.34k stars 294 forks source link

method not send message need to type to send in prompt #301

Open jaccon opened 1 year ago

jaccon commented 1 year ago

I really dont know how it works. Im use the MacOS and i can schedule the message but the automation is only to write a message in Whatsapp Web prompt ? the message cant send auto ?

Vashesh08 commented 1 year ago

Hi, You can try this: https://github.com/Vashesh08/PyWp

contsili commented 1 year ago

Hi @jaccon, to solve this issue you can simulate pressing the Enter key with Python code. To do that, you can use selenium (https://github.com/SeleniumHQ/selenium). For example:

import pywhatkit
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

pywhatkit.sendwhatmsg_instantly("+0XXXXXX","This is a text",15)

# Create a new instance of the Chrome driver
driver = webdriver.Chrome()

# Navigate to the website
driver.get("https://web.whatsapp.com/")

# Simulate pressing the Enter key
webdriver.ActionChains(driver).send_keys(Keys.RETURN).perform()

It is a bit slow but should work.

mrgcuy commented 11 months ago

Hey, I have the same issue, and already tried with Selenium, but my browser is Brave. I tried googling how to use Selenium with Brave, but nothing worked. Do you know any work around? Thanks!

Vashesh08 commented 11 months ago

@mrgcuy https://stackoverflow.com/questions/47158434/how-to-run-selenium-tests-on-the-brave-web-browser. You can try this out. Try checking the path and binaries as well as whether Chromium Version is matching with ChromeDriver Version. Also, I think a more appropriate place to ask this question would be https://github.com/SeleniumHQ/selenium here.

basb7 commented 9 months ago

Recently I have the equal problem. I solved added this line in file core the lib pywhatkit.

def send_message(message: str, receiver: str, wait_time: int) -> None:
    _web(receiver=receiver, message=message)
    time.sleep(7)
    click(WIDTH / 2, HEIGHT / 2)
    time.sleep(wait_time - 7)
    if not check_number(number=receiver):
        for char in message:
            if char == "\n":
                hotkey("shift", "enter")
            else:
                typewrite(char)
    time.sleep(5)  #Line add
    press("enter")