66from webbrowser import open
77
88import requests
9- from pyautogui import click , hotkey , press , size , typewrite
9+ from pyautogui import click , hotkey , press , size , typewrite , locateOnScreen , ImageNotFoundException , moveTo
1010
1111from 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+
3545def 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" )
0 commit comments