Skip to content

Commit 9d02ec9

Browse files
authored
Merge pull request #184 from Naman23-coder/master
New Sending Mechanism 🎉
2 parents 4a86db1 + 77248a9 commit 9d02ec9

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

pywhatkit/core/core.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@
66
from webbrowser import open
77

88
import requests
9-
from pyautogui import click, hotkey, press, size, typewrite
9+
from pyautogui import (
10+
ImageNotFoundException,
11+
click,
12+
hotkey,
13+
locateOnScreen,
14+
moveTo,
15+
press,
16+
size,
17+
typewrite,
18+
)
1019

1120
from pywhatkit.core.exceptions import InternetException
1221

@@ -32,6 +41,18 @@ def close_tab(wait_time: int = 2) -> None:
3241
press("enter")
3342

3443

44+
def findtextbox() -> None:
45+
"""click on text box"""
46+
dir_path = os.path.dirname(os.path.realpath(__file__))
47+
location = locateOnScreen(f"{dir_path}\\data\\pywhatkit_smile1.png")
48+
try:
49+
moveTo(location[0] + 150, location[1] + 5)
50+
except Exception:
51+
location = locateOnScreen(f"{dir_path}\\data\\pywhatkit_smile.png")
52+
moveTo(location[0] + 150, location[1] + 5)
53+
click()
54+
55+
3556
def check_connection() -> None:
3657
"""Check the Internet connection of the Host Machine"""
3758

@@ -69,6 +90,7 @@ def send_message(message: str, receiver: str, wait_time: int) -> None:
6990
hotkey("shift", "enter")
7091
else:
7192
typewrite(char)
93+
findtextbox()
7294
press("enter")
7395

7496

@@ -116,7 +138,6 @@ def send_image(path: str, caption: str, receiver: str, wait_time: int) -> None:
116138
"""Sends the Image to a Contact or a Group based on the Receiver"""
117139

118140
_web(message=caption, receiver=receiver)
119-
120141
time.sleep(7)
121142
click(WIDTH / 2, HEIGHT / 2)
122143
time.sleep(wait_time - 7)
@@ -134,4 +155,5 @@ def send_image(path: str, caption: str, receiver: str, wait_time: int) -> None:
134155
else:
135156
hotkey("ctrl", "v")
136157
time.sleep(1)
158+
findtextbox()
137159
press("enter")
629 Bytes
Loading
656 Bytes
Loading

pywhatkit/whats.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def sendwhatmsg_instantly(
3333
time.sleep(4)
3434
pg.click(core.WIDTH / 2, core.HEIGHT / 2)
3535
time.sleep(wait_time - 4)
36+
core.findtextbox()
3637
pg.press("enter")
3738
log.log_message(_time=time.localtime(), receiver=phone_no, message=message)
3839
if tab_close:

0 commit comments

Comments
 (0)