66from webbrowser import open
77
88import 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
1120from 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+
3556def 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" )
0 commit comments