-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathduplicate_code.py
More file actions
750 lines (680 loc) · 26.7 KB
/
duplicate_code.py
File metadata and controls
750 lines (680 loc) · 26.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
# @Dimitry Ermakov
# @2/24/2024
# CRUD = Create, Read, Update, and Delete
import time
from tracemalloc import start
import keyboard
import pyperclip
from tqdm import tqdm
import pyautogui
from pyautogui import ImageNotFoundException
from datetime import datetime
from main_shared_functions import (
cord_click,
extract_text_from_coordinates,
extract_digits_from_text,
)
from windows_main import play_sound
import sys
x_scale = 1
y_scale = 1
delay = 0.05
confidence = 0.7
CRM_cords = (0, 0)
cutOffTopY = 0
cutOffBottomY = 900
pyautogui.FAILSAFE = True
youtube = True
pyautogui.PAUSE = delay
PRIMARY_EMAIL = "windowsTarget/primary_email.png"
def find_and_click_image(
image_filename, biasx=0, biasy=0, up_or_down=None, max_attempts=50
):
global cutOffTopY, delay, MAX_ATTEMPTS, x_scale, y_scale, cutOffBottomY, confidence
box = None
attempts = 0
if image_filename == "images_duplicate/comment.png":
confidence = 0.9
while box is None and attempts < max_attempts:
try:
box = pyautogui.locateOnScreen(
image_filename,
confidence=confidence,
region=(
0,
cutOffTopY,
round(2880 * x_scale),
round(cutOffBottomY * 2 * y_scale),
),
)
except ImageNotFoundException:
if attempts > max_attempts:
play_sound("audio/alert_notification.mp3")
time.sleep(2)
attempts += 1
if box is None and up_or_down and up_or_down != "NULL":
factor = 200 if up_or_down == "up" else -200
pyautogui.scroll(factor)
time.sleep(delay * 2)
continue
time.sleep(delay * 5)
print(image_filename)
if box is not None:
x, y, width, height = box
x = box.left + width / 2 + biasx
y = box.top + height / 2 + biasy
if up_or_down != "NULL":
cord_click((x, y))
return x, y
else:
return None, None
def cutoff_section_of_screen(image_filename):
global delay, x_scale, y_scale, confidence
box = None
while box is None:
box = pyautogui.locateOnScreen(
image_filename,
confidence=confidence,
region=(0, 0, round(2880 * x_scale), round(1800 * y_scale)),
)
time.sleep(delay * 5)
_, y, width, height = box
image_cords_x = (box.left) + width / 2
image_cords_y = (box.top) + height / 2
return round(y), (image_cords_x, image_cords_y)
def get_screen_dimensions():
screen_width, screen_height = pyautogui.size()
return screen_width / 1440, screen_height / 900, screen_height
def form_adder(text, start_date, end_date):
find_and_click_image("images_duplicate/communications.png")
find_and_click_image("windowsTarget/add.png")
time.sleep(3)
# find_and_click_image("windowsTarget/solicit_code.png")
# time.sleep(1)
keyboard.write(text)
time.sleep(1)
pyautogui.press("tab")
if start_date is not None:
keyboard.write(start_date)
pyautogui.press("tab")
if end_date is not None:
keyboard.write(end_date)
pyautogui.press("tab", presses=2)
pyautogui.press("enter")
time.sleep(4)
find_and_click_image("images_duplicate/dup_review.png")
time.sleep(2)
pyautogui.press("down", presses=12)
def is_date(date_str):
try:
parts = date_str.split("/")
if len(parts) != 3:
return False
month, day, year = map(int, parts)
if month < 1 or month > 12:
return False
if day < 1 or day > 31:
return False
if year < 1000:
return False
return True
except ValueError:
return False
def extract_text_with_conditions(image_path, x_offset, y_offset, bias=0):
attempts = 0
extracted_text = ""
x, y = find_and_click_image(image_path, up_or_down="NULL")
while (extracted_text == "" or not is_date(extracted_text)) and attempts < 30:
extracted_text = extract_text_from_coordinates(
x + x_offset,
y + y_offset + bias,
x + x_offset + 100,
y + y_offset + bias + 25,
).replace("(", "")
print(f"Text: {extracted_text}")
attempts += 1
if attempts >= 30:
play_sound("audio/alert_notification.mp3")
mute_computer()
extracted_text = pyautogui.prompt(title="fix", default=f"{extracted_text}")
unmute_computer()
return extracted_text
def process_answer(answer, start_date, end_date):
if start_date and "*" in start_date:
bias = (int(start_date[1]) - 1) * 25
start_date = extract_text_with_conditions(
"images_duplicate/start_date.png", -45, 45, bias
)
if start_date and "+1" in start_date:
start_date = extract_text_with_conditions(
"images_duplicate/add_start.png", -58, 13
)
if start_date and "+1x" in start_date:
start_date = extract_text_with_conditions(
"images_duplicate/add_start.png", -58, 13
)
start_date = subtract_one_day(start_date)
if end_date and "*" in end_date:
bias = (int(end_date[1]) - 1) * 25
end_date = extract_text_with_conditions(
"images_duplicate/end_date.png", -45, 45, bias
)
if end_date and "+2" in end_date:
end_date = extract_text_with_conditions(
"images_duplicate/source_target.png", 755, 36
)
if end_date and "+2x" in end_date:
end_date = extract_text_with_conditions(
"images_duplicate/source_target.png", 755, 36
)
end_date = subtract_one_day(end_date)
if answer == "+1":
add3 = extract_text_with_conditions("images_duplicate/add_start.png", -58, 13)
opt_form(add3, start_date, True)
elif answer == "+2":
add3 = extract_text_with_conditions(
"images_duplicate/source_target.png", 755, 36
)
opt_form(add3, start_date, True)
elif answer == "-1":
add4 = extract_text_with_conditions("images_duplicate/add_start.png", -58, 13)
opt_form(add4, start_date, False)
elif answer == "-2":
add4 = extract_text_with_conditions(
"images_duplicate/source_target.png", 755, 36
)
opt_form(add4, start_date, False)
elif answer == "q":
find_and_click_image("images_duplicate/comment.png", 0, 25)
find_and_click_image("windowsTarget/sites.png")
pyautogui.press("tab", presses=2)
pyautogui.press("enter", presses=2)
keyboard.write("DE") # Make dynamic TODO
pyautogui.press("tab", presses=2)
pyautogui.press("enter")
sys.exit()
elif answer == "1" and start_date:
print(start_date)
opt_form(start_date, end_date, True)
elif answer == "0" and start_date:
opt_form(start_date, end_date, False)
elif answer == "ntm":
form_adder("No Text Messages", start_date, end_date)
elif answer == "nc":
form_adder("No Contact", start_date, end_date)
elif answer == "np":
form_adder("No Postal Mailings", start_date, end_date)
elif answer == "nfr":
form_adder("No Fund Raising", start_date, end_date)
elif answer == "cca":
form_adder("CCA", start_date, end_date)
elif answer == "itae":
form_adder("Invite to Area Events", start_date, end_date)
elif answer == "h":
form_adder("Hostels", start_date, end_date)
elif answer == "ndmf":
form_adder("No Direct Mail Fundraising", start_date, end_date)
elif answer == "ndo":
form_adder("No NDO Direct Mail Fundraising", start_date, end_date)
elif answer == "ne":
form_adder("No Email", start_date, end_date)
elif answer == "io":
form_adder("Imprimis Only", start_date, end_date)
elif answer == "ni":
form_adder("No Imprimis", start_date, end_date)
elif answer == "000":
form_adder("No Imprimis", "4/6/2019", "10/15/2023")
elif answer == "nm":
form_adder("No NDO Money Enclosed Mailings", start_date, end_date)
elif answer == "cyea":
form_adder("CYEA Only", start_date, end_date)
elif answer == "nsrn":
form_adder("No Sell/Rent Name", start_date, end_date)
elif answer.isdigit():
delete_specifc_form(
"images_duplicate/review_down.png", 0, (80 + ((int(answer) - 1) * 25))
)
def opt_form(start_date, end_date, opt_in):
find_and_click_image("images_duplicate/target_select.png", 0, 40)
if opt_in:
find_and_click_image("images_duplicate/opt_in_button.png")
else:
find_and_click_image("images_duplicate/opt_in_button.png", 100)
time.sleep(3)
pyautogui.press("tab", presses=2)
if start_date is not None:
keyboard.write(start_date)
pyautogui.press("tab")
if end_date is not None:
keyboard.write(end_date)
pyautogui.press("tab", presses=7) # TODO test
pyautogui.press("enter")
# time.sleep(3)
# find_and_click_image(PRIMARY_EMAIL, up_or_down="NULL")
# pyautogui.press("down", presses=12)
# time.sleep(1)
def delete_specifc_form(image, biasx=30, biasy=0):
while True:
x, y = find_and_click_image(image, biasx, biasy)
if x == None and y == None:
break
find_and_click_image("mergeConflictImages/delete.png")
find_and_click_image("images_duplicate/yes.png")
if image == "images_duplicate/review_down.png":
break
time.sleep(3)
# find_and_click_image(
# PRIMARY_EMAIL,
# 0,
# 0,
# "NULL",
# )
# pyautogui.press("down", presses=12)
# time.sleep(1)
def allowed_constituencies():
x, y = find_and_click_image(
"mergeConflictImages/constitencies.png", up_or_down="NULL"
)
# print(x, y)
amount = ""
attempts = 0
while amount == "" and attempts < 30:
amount = extract_text_from_coordinates(x + 45, y - 10, x + 450, y + 10) # TODO
print(f"Text: {amount}")
attempts += 1
listAmount = amount.split(" ")
text = [
"Trustee",
# "Prospect",
# " Prospect",
# "prospect",
"Student",
"Staff",
# "Planned Giver",
# "Parent",
# "Major Donor",
# "Grandparent",
"Faculty",
"Academy Student",
# "Alumnus - Graduated",
# "Alumnus - Not Graduated",
# "Donor",
]
for x in listAmount:
if x in text:
return -1
return 0
def merge_request():
find_and_click_image("images_duplicate/comment.png", 0, 25)
find_and_click_image("windowsTarget/sites.png")
pyautogui.press("tab", presses=2)
pyautogui.press("enter", presses=2)
keyboard.write("DE") # Make dynamic TODO
pyautogui.press("tab", presses=2)
pyautogui.press("enter")
# find_and_click_image("images_duplicate/save.png")
time.sleep(1)
find_and_click_image("images_duplicate/comment.png", 0, 0, "NULL")
find_and_click_image("images_duplicate/return.png")
def print_string_difference_and_similarity(string1, string2):
diff_count = 0
total_chars = min(len(string1), len(string2))
match_count = 0
for i, (char1, char2) in enumerate(zip(string1, string2)):
if (
char1 != char2
and (i == 0 or char1 != string1[i - 1])
and (i == len(string1) - 1 or char1 != string1[i + 1])
):
print(f"Difference found at index {i}: '{char1}' != '{char2}'")
diff_count += 1
else:
match_count += 1
similarity_percent = (match_count / total_chars) * 100
print(f"Percentage of similarity between the strings: {similarity_percent:.2f}%")
print(f"Total differences found: {diff_count}")
def end_time_recording(start_time):
end_time = time.time()
duration = end_time - start_time
log_file = "time_log_duplicate.txt"
print(f"{duration:.2f}")
with open(log_file, "a") as f:
f.write(f"{duration:.2f}\n")
# def codes_num_finder():
# time.sleep(1)
# x, y = find_and_click_image("images_duplicate/review_sol.png", up_or_down="NULL")
# x, y = int(x), int(y)
# # print(x, y)
# pyautogui.doubleClick(x + 105, y)
# pyperclip.copy("")
# keyboard.press_and_release("ctrl+c")
# time.sleep(0.25)
# found_text = int(pyperclip.paste())
# print(found_text)
# return found_text
def codes_num_finder():
time.sleep(1)
x, y = find_and_click_image("images_duplicate/review_sol.png", up_or_down="NULL")
# print(x, y)
amount = None
x = int(x)
y = int(y)
while not amount:
amount = extract_digits_from_text(
extract_text_from_coordinates(x + 80, y - 20, x + 120, y + 20)
)
print(f"Solicit Codes: {amount}")
return int(amount)
import time
from ctypes import cast, POINTER
from comtypes import CLSCTX_ALL
from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume
def mute_computer():
global youtube
if not youtube:
devices = AudioUtilities.GetSpeakers()
interface = devices.Activate(IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
volume = cast(interface, POINTER(IAudioEndpointVolume))
volume.SetMute(1, None)
def unmute_computer():
global youtube
if not youtube:
devices = AudioUtilities.GetSpeakers()
interface = devices.Activate(IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
volume = cast(interface, POINTER(IAudioEndpointVolume))
volume.SetMute(0, None)
def opt_finder(bias=0):
time.sleep(1)
x, y = find_and_click_image("images_duplicate/pref.png", up_or_down="NULL")
# print(x, y)
x = int(x)
y = int(y)
amount = None
attempts = 0
while not amount and attempts < 20:
amount = extract_text_from_coordinates(
x - 45, y + 45 + bias, x + 30, y + 70 + bias
)
if amount:
print(f"opt one: {amount}")
attempts += 1
if amount == "Opt-out" or amount == "opt-out":
amount = False
elif amount == "":
amount = None
else:
amount = True
return amount
from datetime import datetime, timedelta
def subtract_one_day(date_string):
try:
date_obj = datetime.strptime(date_string, "%Y-%m-%d")
except ValueError:
try:
date_obj = datetime.strptime(date_string, "%m/%d/%Y")
except ValueError:
print("Failed to parse date: ", date_string)
return date_string
previous_day = date_obj - timedelta(days=1)
previous_day_string = previous_day.strftime("%m/%d/%Y")
return previous_day_string
def main():
global delay, x_scale, y_scale, cutOffBottomY, cutOffTopY, CRM_cords
x_scale, y_scale, cutOffBottomY = get_screen_dimensions()
with open("bias.txt", "r") as file:
bias = int(file.read().strip()) * 25
add1 = -1
add2 = 25
play = 0
cutOffTopY, CRM_cords = cutoff_section_of_screen("windowsTarget/blackbaudCRM.png")
while True:
# print(bias)
find_and_click_image("windowsTarget/updates.png", 0, 25)
while True:
if bias >= 12 * 25:
bias += 4
find_and_click_image(
"images_duplicate/target_lookup_id.png", -30, (30 + bias)
) # +25 for bias
if allowed_constituencies() == -1:
pyautogui.alert(
text="This constituent is not allowed to be solicited",
title="Error",
button="OK",
)
x5, y5 = find_and_click_image("images_duplicate/return.png", 0, 0, "NULL")
add5 = ""
attempts = 0
# print(x5, y5)
while (add5 == "" or add5.index("%") == -1) and attempts < 30:
add5 = extract_text_from_coordinates(
x5 + (-50), y5 + (35), x5 + (30), y5 + (65)
)
print(f"Text: {add5}")
attempts += 1
if attempts >= 30:
add5 = pyautogui.prompt(title="fix percent", default=f"-1")
if add5 == "0":
add5 == "100.00%"
pyautogui.press("down", presses=5)
if add5 != "100.00%" and add5 != "10.00%":
time.sleep(1)
x2, y2 = find_and_click_image(
"images_duplicate/source_target.png", 0, 51
)
x1, y1 = find_and_click_image(
"images_duplicate/target_select.png", 0, 50
)
y1 -= 50
y2 -= 50
attempts = 0
if add1 != add2:
add1 = "0"
add2 = 0
play_sound("audio/alert_notification.mp3")
mute_computer()
play = -1
add = pyautogui.prompt(
text="Addresses Correct?",
title="Addresses",
default="y",
)
unmute_computer()
if add == "z":
with open("bias.txt", "r+") as file:
bias_value = int(file.read().strip()) + 1
file.seek(0)
file.write(str(bias_value))
bias = bias_value
break
else:
add = "y"
find_and_click_image("images_duplicate/target_select.png", 0, 50)
time.sleep(1)
find_and_click_image("images_duplicate/source_target.png", 0, 51)
if add == "z":
play_sound("audio/alert_notification.mp3")
mute_computer()
play = -1
additional = pyautogui.prompt(
text="Addresses Correct?",
title="Addresses",
default="y",
)
unmute_computer()
if additional == "y":
find_and_click_image(
"images_duplicate/target_select.png", 0, 50
)
time.sleep(1)
find_and_click_image(
"images_duplicate/source_target.png", 0, 51
)
answer = None
while True:
# * = copy, +1 = add1, +2 = add2
option_mapping = {
"1": ("2.2.", 3, "0", True),
"2": ("1 *3 x.3.3.+2.", 3, "0", False),
"3": ("1 *3.3.3.", 3, "22", False),
"4": ("1 *2.2.2.", 2, "0", None),
"5": ("2.2.+1.", 3, "0", True),
"6": ("2.2.2.+1.", 4, "30", False),
"7": ("2.", 2, "0", True),
"8": ("1 *1.1.", 1, "0", False),
"9": ("0 *2.3.3.+2.", 3, "31", True),
"10": ("2.+1.", 2, "0", False),
"11": ("3.3.+1.", 4, "0", False),
"12": ("3.+2.", 3, "0", None),
"13": ("2.2.2.2.+1.", 5, "0", False),
"14": ("3.3.3.+1.", 5, "0", True),
"15": ("0 *3.4.4.+1.", 4, "0", True),
"17": ("3.3.3.3.+1.", 5, "0", False),
"16": ("2.2.+2.", 3, "0", True), # None
"18": ("0 *3.3.3.3.+2.", 4, "0", True),
"19": ("1.+2.", 1, "0", None),
"20": ("1.1.1.1.1 x.0 x.+2.", 4, "0", True),
"21": ("4.4.4.4.", 6, "0", False), # None
"22": ("0 *1.2.2.+2.", 2, "0", False),
"23": ("0 *2.2.2.2.+1.", 3, "0", None),
"24": ("1.0 *2.2.2.2.+1.", 4, "0", False),
"25": ("1.0 *2.2.2.2.+2.", 4, "0", False),
"26": ("1 *3 x.3.3.+1.", 3, "0", False),
"27": ("0 *3.4.4.+2.", 4, "0", True),
"28": ("2.2.2.2.2.+1.", 6, "0", False),
"29": ("0 *1.2.2.+1.", 2, "0", False),
"30": ("1 *3.3.3.3.", 4, "0", False),
"31": ("+1.0 *1.2.3.+2.", 2, "0", False),
"32": ("-1.1 *3.3.3.3.000.+2.", 3, "0", False),
}
code_num = codes_num_finder()
opt_one = ""
opt_two = ""
opt_one = opt_finder()
if code_num > 1:
opt_two = opt_finder(25)
if code_num == 1 and opt_one == None:
defaultGuess = option_mapping["19"][0]
elif code_num == 1:
defaultGuess = option_mapping["8"][0]
elif code_num == 2 and opt_one == False and opt_two == None:
defaultGuess = option_mapping["10"][0]
elif code_num == 2 and (
(opt_one == True and opt_two == None)
or (opt_one == True and opt_two == True)
):
defaultGuess = option_mapping["7"][0]
elif code_num == 2 and opt_one == None:
defaultGuess = option_mapping["4"][0]
elif code_num == 2 and opt_one == False:
defaultGuess = option_mapping["10"][0]
elif code_num == 3 and opt_one == True and opt_two == None:
defaultGuess = option_mapping["16"][0]
elif code_num == 3 and opt_one == False:
defaultGuess = option_mapping["3"][0]
elif code_num == 3 and opt_one == True:
defaultGuess = option_mapping["9"][0]
elif code_num == 3 and opt_one == None and opt_two == False:
defaultGuess = option_mapping["23"][0]
elif code_num == 3 and opt_one == None:
defaultGuess = option_mapping["12"][0]
elif code_num == 4 and opt_one == True and opt_two == None:
defaultGuess = option_mapping["18"][0]
elif code_num == 4:
defaultGuess = option_mapping["6"][0]
elif code_num == 5 and opt_one == None and opt_two == False:
defaultGuess = option_mapping["14"][0]
elif code_num == 5 and opt_one == False and opt_two == None:
defaultGuess = option_mapping["14"][0]
elif code_num == 5 and opt_one == True and opt_two == None:
defaultGuess = option_mapping["18"][0]
elif code_num == 5 and opt_one == False:
defaultGuess = option_mapping["13"][0]
elif code_num == 5 and opt_one == True:
defaultGuess = option_mapping["13"][0]
elif code_num == 6 and opt_one == False and opt_two == None:
defaultGuess = option_mapping["28"][0]
elif code_num == 6:
defaultGuess = option_mapping["21"][0]
elif code_num == 8:
defaultGuess = "4.4.4.4.4."
else:
defaultGuess = ""
filtered_options = [
f"{key}| {value[0]}| Commas: {value[1]}| Time: {value[2]}| Opt-in/out: {value[3]}"
for key, value in option_mapping.items()
if value[1] == code_num
]
# Join the filtered options into the text variable
text = "\n".join(filtered_options)
if play == 0:
play_sound("audio/alert_notification.mp3")
mute_computer()
option = pyautogui.prompt(
text=text,
default=defaultGuess,
)
unmute_computer()
if "//" in option:
option = pyautogui.prompt(
text=text,
default=option_mapping[option.replace("//", "")][0],
)
if option in option_mapping:
option = option_mapping[option][0]
if option == "q":
find_and_click_image("images_duplicate/comment.png", 0, 25)
find_and_click_image("windowsTarget/sites.png")
pyautogui.press("tab", presses=2)
pyautogui.press("enter", presses=2)
keyboard.write("DE") # Make dynamic TODO
pyautogui.press("tab", presses=2)
pyautogui.press("enter")
sys.exit()
elif option == "z":
print("Skip")
with open("bias.txt", "r+") as file:
bias_value = int(file.read().strip()) + 1
file.seek(0)
file.write(str(bias_value))
bias = bias_value * 25
find_and_click_image("images_duplicate/return.png")
break
start_index = 0
while option.find("x", start_index) != -1:
index = option.find("x", start_index)
guessX = extract_text_with_conditions(
"images_duplicate/start_date.png", -45, 45
)
guessX = subtract_one_day(guessX)
print(guessX)
# guessX = pyautogui.prompt(
# text="Replace x at index {}: ".format(index), default=guessX
# )
option = option[:index] + guessX + option[index + 1 :]
start_index = index + 1
start_time = time.time()
print(option)
commands = option.split(".")
commands_length = len(commands)
with tqdm(
total=commands_length, desc="Processing Commands", unit="command"
) as pbar:
for index, command in enumerate(commands):
parts = command.strip().split(" ")
answer = parts[0] if len(parts) > 0 else None
start_date = parts[1] if len(parts) > 1 else None
end_date = parts[2] if len(parts) > 2 else None
process_answer(answer, start_date, end_date)
if index != len(commands) - 1:
time.sleep(3)
pbar.update(1)
if commands[-1].strip().split(" ")[0] != "":
defaultGuess = ""
continue
if commands[-1].strip().split(" ")[0] == "":
merge_request()
end_time_recording(start_time)
break
if __name__ == "__main__":
main()