1

This is my code It performs keep_click_attendance_link() enter code here function until JustBefore time is reached and then at EndTime it performs the leave_the_meeting() function

import pyautogui
import time
import pause
import datetime
import schedule
YEAR = 2020
MONTH = 11
DATE = 6
HOUR = 13
MINUTES = 3
SECONDS = 15
now = datetime.datetime.now()
EndTime = now.replace(hour=HOUR, minute=MINUTES, second=SECONDS, microsecond=0)
JustBefore= now.replace(hour=HOUR, minute=MINUTES-1, second=SECONDS, microsecond=0)

def leave_the_meeting():
  pyautogui.click(1198, 1072)
  time.sleep(3)
  pyautogui.click(1443, 998)
  time.sleep(1)
  pyautogui.click(1398, 933)
 
def click_attendance_link():
      pyautogui.click(1665, 674)
      time.sleep(9)

def keep_click_attendance_link():
  while datetime.datetime.now() < JustBefore:
    click_attendance_link()
    # Sleep for 60 secs before trying again
    time.sleep(9)
    


keep_click_attendance_link()

while datetime.datetime.now() < EndTime:
    # Sleep for 1 sec intervals:
    time.sleep(1)

  # eventually Leave the meeting at Endtime
leave_the_meeting()    


So what I want is it to stop the function keep_click_attendance_link() when the attendance link is clicked. The teacher sends the link at any random time, so I had to program it to continuously click at that spot until 1 minute before the EndTime which is JustBefore. The meeting is on zoom client not on the web browser.

karel
  • 5,489
  • 46
  • 45
  • 50
Chinar
  • 7
  • 4

2 Answers2

0

First of all, don't skip lesson.

Secondly, to do what you intend to do, for educational purpose only, you will need a mechanism to detect whether the button has appeared yet. Since you can't directly communicate with the zoom client, you will need to detect pixel by pixel in the screen and analyze whether the color of that pixel/area is the color for the attendance button.

To do that, you will need to find the color code for your button first. It can be simply done by screen capture and put that in any image processing software, even Paint. After you have your color, you can use Pillow module to analyze that particular spot, more on that here.

After the checking mechanism is done, you can integrate that into your code and stop the function execution once the button has been detected.

def check_attendance_link_presence():
    # check it here
    pass

def keep_click_attendance_link():
    clicked = False
    while datetime.datetime.now() < JustBefore and not clicked:
        presence = check_attendance_link_presence()
        if presence:
            click_attendance_link()
            clicked = True
        # Sleep for 60 secs before trying again
        time.sleep(60)

p.s. I intentionally not to include the code for the presence checking here for the sake of encouraging you to spend time learning it while you are "taking a break" from your lessons.

kennysliding
  • 2,783
  • 1
  • 10
  • 31
  • Well, thank you for your help. Is this what you expected https://justpaste.it/7wfr5 – Chinar Nov 06 '20 at 11:48
  • Yea... I tried to put it but its not working. This is the whole code https://justpaste.it/7vwx0 I cut out some functions and merged them before adding checking of the link and it was working fine. I think the problem is in `check_attendance_link()` fuction – Chinar Nov 06 '20 at 13:00
0

Maybe: Define a variable something like clicked = False, and in the attendance function set it to True. Then modify the While in the other function with an and clicked == False. So your while cycle only loops till the clicked flag is False, but after it clicked the attendance, it'll change to True, and the cycle stops.

I think it would be more elegant with callbacks tough.

Ray_Sch
  • 21
  • 3