Skip to content

Commit 3efccf5

Browse files
document send instantly
1 parent 30063ba commit 3efccf5

File tree

4 files changed

+91
-58
lines changed

4 files changed

+91
-58
lines changed

pywhatkit/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
# Version 5.2
1+
""" Version 5.2
22
# Status: Stable
33
# Documentation: https://github.com/Ankit404butfound/PyWhatKit/wiki
44
# Report Bugs and Feature Requests here: https://github.com/Ankit404butfound/PyWhatKit/issues
55
# For further Information, Join our Discord: https://discord.gg/62Yf5mushu
6-
6+
"""
77
__VERSION__ = "Version 5.3 (Stable)"
88

99
from platform import system
1010

1111
from pywhatkit.ascii_art import image_to_ascii_art
1212
from pywhatkit.handwriting import text_to_handwriting
1313
from pywhatkit.mail import send_hmail, send_mail
14-
from pywhatkit.misc import info, playonyt, search, show_history, take_screenshot
14+
from pywhatkit.misc import info, playonyt, search, show_history
1515
from pywhatkit.sc import cancel_shutdown, shutdown
1616
from pywhatkit.whats import (
1717
open_web,
@@ -20,7 +20,8 @@
2020
sendwhatmsg_to_group,
2121
sendwhatmsg_to_group_instantly,
2222
sendwhats_image,
23-
sendwhatdoc_immediately
23+
sendwhatdoc_immediately,
24+
sendimg_or_video_immediately
2425
)
2526

2627
_system = system().lower()

pywhatkit/core/core.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,32 @@ def findtextbox() -> None:
4646
click()
4747

4848

49+
def find_link():
50+
dir_path = os.path.dirname(os.path.realpath(__file__))
51+
location = locateOnScreen(f"{dir_path}\\data\\link.png")
52+
print(location)
53+
try:
54+
moveTo(location[0] + location[2]/2, location[1] + location[3]/2)
55+
click()
56+
except Exception:
57+
location = locateOnScreen(f"{dir_path}\\data\\link2.png")
58+
moveTo(location[0] + location[2]/2, location[1] + location[3]/2)
59+
print(location)
60+
click()
61+
def find_document():
62+
dir_path = os.path.dirname(os.path.realpath(__file__))
63+
location = locateOnScreen(f"{dir_path}\\data\\document.png")
64+
print(location)
65+
moveTo(location[0] + location[2]/2, location[1] + location[3]/2)
66+
click()
67+
68+
def find_photo_or_video():
69+
dir_path = os.path.dirname(os.path.realpath(__file__))
70+
location = locateOnScreen(f"{dir_path}\\data\\photo_or_video.png")
71+
print(location)
72+
moveTo(location[0] + location[2]/2, location[1] + location[3]/2)
73+
click()
74+
4975
def check_connection() -> None:
5076
"""Check the Internet connection of the Host Machine"""
5177

File renamed without changes.

pywhatkit/whats.py

Lines changed: 60 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717

1818

1919
def sendwhatmsg_instantly(
20-
phone_no: str,
21-
message: str,
22-
wait_time: int = 15,
23-
tab_close: bool = False,
24-
close_time: int = 3,
20+
phone_no: str,
21+
message: str,
22+
wait_time: int = 15,
23+
tab_close: bool = False,
24+
close_time: int = 3,
2525
) -> None:
2626
"""Send WhatsApp Message Instantly"""
2727

@@ -42,12 +42,13 @@ def sendwhatmsg_instantly(
4242
if tab_close:
4343
core.close_tab(wait_time=close_time)
4444

45-
def sendwhatimg_immediately(
46-
phone_no: str,
47-
path: str,
48-
wait_time: int = 15,
49-
tab_close: bool = False,
50-
close_time: int = 3,
45+
46+
def sendimg_or_video_immediately(
47+
phone_no: str,
48+
path: str,
49+
wait_time: int = 15,
50+
tab_close: bool = False,
51+
close_time: int = 3,
5152
) -> None:
5253
"""Send WhatsApp Message Instantly"""
5354

@@ -64,8 +65,10 @@ def sendwhatimg_immediately(
6465
(ps_x, ps_y) = pg.size()
6566
as_x = ps_x / 1920
6667
as_y = ps_y / 1080
67-
pg.click(671 * as_x, 964 * as_y)
68-
pg.click(675 * as_x, 878 * as_y)
68+
core.find_link()
69+
time.sleep(1)
70+
core.find_photo_or_video()
71+
6972
pyperclip.copy(os.path.abspath(path))
7073
print("Copied")
7174
time.sleep(1)
@@ -81,12 +84,13 @@ def sendwhatimg_immediately(
8184
keyboard.release("enter")
8285
if tab_close:
8386
core.close_tab(wait_time=close_time)
87+
8488
def sendwhatdoc_immediately(
85-
phone_no: str,
86-
path: str,
87-
wait_time: int = 15,
88-
tab_close: bool = False,
89-
close_time: int = 3,
89+
phone_no: str,
90+
path: str,
91+
wait_time: int = 15,
92+
tab_close: bool = True,
93+
close_time: int = 3,
9094
) -> None:
9195
"""Send WhatsApp Message Instantly"""
9296

@@ -103,8 +107,9 @@ def sendwhatdoc_immediately(
103107
(ps_x, ps_y) = pg.size()
104108
as_x = ps_x / 1920
105109
as_y = ps_y / 1080
106-
pg.click(671 * as_x, 964 * as_y)
107-
pg.click(677 * as_x, 625 * as_y)
110+
core.find_link()
111+
time.sleep(1)
112+
core.find_document()
108113
pyperclip.copy(os.path.abspath(path))
109114
print("Copied")
110115
time.sleep(1)
@@ -121,14 +126,15 @@ def sendwhatdoc_immediately(
121126
if tab_close:
122127
core.close_tab(wait_time=close_time)
123128

129+
124130
def sendwhatmsg(
125-
phone_no: str,
126-
message: str,
127-
time_hour: int,
128-
time_min: int,
129-
wait_time: int = 15,
130-
tab_close: bool = False,
131-
close_time: int = 3,
131+
phone_no: str,
132+
message: str,
133+
time_hour: int,
134+
time_min: int,
135+
wait_time: int = 15,
136+
tab_close: bool = False,
137+
close_time: int = 3,
132138
) -> None:
133139
"""Send a WhatsApp Message at a Certain Time"""
134140
if not core.check_number(number=phone_no):
@@ -166,13 +172,13 @@ def sendwhatmsg(
166172

167173

168174
def sendwhatmsg_to_group(
169-
group_id: str,
170-
message: str,
171-
time_hour: int,
172-
time_min: int,
173-
wait_time: int = 15,
174-
tab_close: bool = False,
175-
close_time: int = 3,
175+
group_id: str,
176+
message: str,
177+
time_hour: int,
178+
time_min: int,
179+
wait_time: int = 15,
180+
tab_close: bool = False,
181+
close_time: int = 3,
176182
) -> None:
177183
"""Send WhatsApp Message to a Group at a Certain Time"""
178184

@@ -204,11 +210,11 @@ def sendwhatmsg_to_group(
204210

205211

206212
def sendwhatmsg_to_group_instantly(
207-
group_id: str,
208-
message: str,
209-
wait_time: int = 15,
210-
tab_close: bool = False,
211-
close_time: int = 3,
213+
group_id: str,
214+
message: str,
215+
wait_time: int = 15,
216+
tab_close: bool = False,
217+
close_time: int = 3,
212218
) -> None:
213219
"""Send WhatsApp Message to a Group Instantly"""
214220

@@ -221,13 +227,13 @@ def sendwhatmsg_to_group_instantly(
221227

222228

223229
def sendwhatsmsg_to_all(
224-
phone_nos: List[str],
225-
message: str,
226-
time_hour: int,
227-
time_min: int,
228-
wait_time: int = 15,
229-
tab_close: bool = False,
230-
close_time: int = 3,
230+
phone_nos: List[str],
231+
message: str,
232+
time_hour: int,
233+
time_min: int,
234+
wait_time: int = 15,
235+
tab_close: bool = False,
236+
close_time: int = 3,
231237
):
232238
for phone_no in phone_nos:
233239
sendwhatmsg(
@@ -236,14 +242,14 @@ def sendwhatsmsg_to_all(
236242

237243

238244
def sendwhats_image(
239-
receiver: str,
240-
img_path: str,
241-
time_hour: int,
242-
time_min: int,
243-
caption: str = "",
244-
wait_time: int = 15,
245-
tab_close: bool = False,
246-
close_time: int = 3,
245+
receiver: str,
246+
img_path: str,
247+
time_hour: int,
248+
time_min: int,
249+
caption: str = "",
250+
wait_time: int = 15,
251+
tab_close: bool = False,
252+
close_time: int = 3,
247253
) -> None:
248254
"""Send Image to a WhatsApp Contact or Group at a Certain Time"""
249255

0 commit comments

Comments
 (0)