Skip to content

Commit 28cc0e1

Browse files
committed
basic fixes
1 parent cd5594f commit 28cc0e1

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

pywhatkit/core/core.py

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

88
import requests
9-
from pyautogui import click, hotkey, press, size, typewrite
9+
from pyautogui import click, hotkey, press, size, typewrite, locateOnScreen, ImageNotFoundException, moveTo
1010

1111
from pywhatkit.core.exceptions import InternetException
1212

@@ -32,6 +32,16 @@ def close_tab(wait_time: int = 2) -> None:
3232
press("enter")
3333

3434

35+
def findtextbox() -> None:
36+
"""click on text box"""
37+
try:
38+
location = locateOnScreen(os.path.join('data', 'pywhatkit_smile1.png'))
39+
except ImageNotFoundException:
40+
location = locateOnScreen(os.path.join('data','pywhatkit_smile.png'))
41+
moveTo(location[0] + 150, location[1] + 5)
42+
click()
43+
44+
3545
def check_connection() -> None:
3646
"""Check the Internet connection of the Host Machine"""
3747

@@ -69,6 +79,7 @@ def send_message(message: str, receiver: str, wait_time: int) -> None:
6979
hotkey("shift", "enter")
7080
else:
7181
typewrite(char)
82+
findtextbox()
7283
press("enter")
7384

7485

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

118129
_web(message=caption, receiver=receiver)
119-
120130
time.sleep(7)
121131
click(WIDTH / 2, HEIGHT / 2)
122132
time.sleep(wait_time - 7)
@@ -134,4 +144,5 @@ def send_image(path: str, caption: str, receiver: str, wait_time: int) -> None:
134144
else:
135145
hotkey("ctrl", "v")
136146
time.sleep(1)
147+
findtextbox()
137148
press("enter")

pywhatkit/whats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import time
22
import webbrowser as web
33
from datetime import datetime
4-
from typing import Optional
54
from urllib.parse import quote
65

76
import pyautogui as pg
@@ -29,6 +28,7 @@ def sendwhatmsg_instantly(
2928
time.sleep(4)
3029
pg.click(core.WIDTH / 2, core.HEIGHT / 2)
3130
time.sleep(wait_time - 4)
31+
core.findtextbox()
3232
pg.press("enter")
3333
log.log_message(_time=time.localtime(), receiver=phone_no, message=message)
3434
if tab_close:

0 commit comments

Comments
 (0)