diff --git a/pywhatkit/core/core.py b/pywhatkit/core/core.py index 094c48b..2f424c2 100644 --- a/pywhatkit/core/core.py +++ b/pywhatkit/core/core.py @@ -4,7 +4,8 @@ from platform import system from urllib.parse import quote from webbrowser import open - +import pyperclip +import platform import requests from pyautogui import click, hotkey, locateOnScreen, moveTo, press, size, typewrite @@ -100,16 +101,14 @@ def send_message(message: str, receiver: str, wait_time: int) -> None: """Parses and Sends the Message""" _web(receiver=receiver, message=message) - time.sleep(7) - click(WIDTH / 2, HEIGHT / 2 + 15) - time.sleep(wait_time - 7) + time.sleep(wait_time) if not check_number(number=receiver): - for char in message: - if char == "\n": - hotkey("shift", "enter") - else: - typewrite(char) - findtextbox() + pyperclip.copy(message) + if platform.system() == "Darwin": + hotkey("command", "v") + else: + hotkey("ctrl", "v") + time.sleep(1) press("enter") diff --git a/pywhatkit/whats.py b/pywhatkit/whats.py index 72dc831..67ac01e 100755 --- a/pywhatkit/whats.py +++ b/pywhatkit/whats.py @@ -17,11 +17,11 @@ def sendwhatmsg_instantly( - phone_no: str, - message: str, - wait_time: int = 15, - tab_close: bool = False, - close_time: int = 3, + phone_no: str, + message: str, + wait_time: int = 30, + tab_close: bool = False, + close_time: int = 3, ) -> None: """Send WhatsApp Message Instantly""" @@ -46,7 +46,7 @@ def sendwhatmsg_instantly( def sendimg_or_video_immediately( phone_no: str, path: str, - wait_time: int = 15, + wait_time: int = 30, tab_close: bool = False, close_time: int = 3, ) -> None: @@ -84,7 +84,7 @@ def sendimg_or_video_immediately( def sendwhatdoc_immediately( phone_no: str, path: str, - wait_time: int = 15, + wait_time: int = 30, tab_close: bool = True, close_time: int = 3, ) -> None: @@ -120,13 +120,13 @@ def sendwhatdoc_immediately( def sendwhatmsg( - phone_no: str, - message: str, - time_hour: int, - time_min: int, - wait_time: int = 15, - tab_close: bool = False, - close_time: int = 3, + phone_no: str, + message: str, + time_hour: int, + time_min: int, + wait_time: int = 30, + tab_close: bool = False, + close_time: int = 3, ) -> None: """Send a WhatsApp Message at a Certain Time""" if not core.check_number(number=phone_no): @@ -164,13 +164,13 @@ def sendwhatmsg( def sendwhatmsg_to_group( - group_id: str, - message: str, - time_hour: int, - time_min: int, - wait_time: int = 15, - tab_close: bool = False, - close_time: int = 3, + group_id: str, + message: str, + time_hour: int, + time_min: int, + wait_time: int = 30, + tab_close: bool = False, + close_time: int = 3, ) -> None: """Send WhatsApp Message to a Group at a Certain Time""" @@ -202,11 +202,11 @@ def sendwhatmsg_to_group( def sendwhatmsg_to_group_instantly( - group_id: str, - message: str, - wait_time: int = 15, - tab_close: bool = False, - close_time: int = 3, + group_id: str, + message: str, + wait_time: int = 30, + tab_close: bool = False, + close_time: int = 3, ) -> None: """Send WhatsApp Message to a Group Instantly""" @@ -219,13 +219,13 @@ def sendwhatmsg_to_group_instantly( def sendwhatsmsg_to_all( - phone_nos: List[str], - message: str, - time_hour: int, - time_min: int, - wait_time: int = 15, - tab_close: bool = False, - close_time: int = 3, + phone_nos: List[str], + message: str, + time_hour: int, + time_min: int, + wait_time: int = 30, + tab_close: bool = False, + close_time: int = 3, ): for phone_no in phone_nos: sendwhatmsg( @@ -234,14 +234,14 @@ def sendwhatsmsg_to_all( def sendwhats_image( - receiver: str, - img_path: str, - time_hour: int, - time_min: int, - caption: str = "", - wait_time: int = 15, - tab_close: bool = False, - close_time: int = 3, + receiver: str, + img_path: str, + time_hour: int, + time_min: int, + caption: str = "", + wait_time: int = 30, + tab_close: bool = False, + close_time: int = 3, ) -> None: """Send Image to a WhatsApp Contact or Group at a Certain Time"""