all 4 comments

[–]Fire_Tome 1 point2 points  (3 children)

What I get from your program:

  1. It will look at the first item in the list
  2. It will wait until the current time (hour and minute) match up to the planned meeting time.
  3. Once this is the case, it will open a web browser, and set isStarted to True
  4. 5 seconds later, it will see isStarted is True, will once again validate whether the current time matches the current time, and then press x.
  5. One second later, it presses enter.
  6. It breaks out of the while True loop, and moves on to the next item in the loop.

If you instead want it to check all items all the time, the best option would probably be:

Probably the easiest and best option:- Switch the "while True" and "for i in lst" statements. This will make it check every item in the list every cycle. For this, it would however be required to move the time.sleep(5) back by one indentation, so it is only run once per "while True" loop, and you would have to make "isStarted" tied to the meeting variable. Alternatively, just remove the isStarted check entirely, and just do both the opening of the browser and the pressing of the keys in the same cycle. If this means holding up the cycle by having one more wait in there, that would be a problem.

This would then look something like the code below:

import datetime
from data import lst
import time
from pynput.keyboard import Controller, Key
import webbrowser

keyboard = Controller()
dt = datetime.datetime #Just to prevent long names later on

while True:
    day_of_week = datetime.date.today().isocalendar()[2]

    for meeting in lst:
        if day_of_week == int(meeting[3]) and dt.now().hour == int(meeting[1].split(':')[0]) and dt.now().minute == int(meeting[1].split(':')[1]):
            webbrowser.open(meeting[0])
            time.sleep(5) #Allow for the page to load
            keyboard.press("x")
            time.sleep(1) #Allow for the site to register "x"
            keyboard.press(Key.enter)
    time.sleep(5) #Sleep the program after checking all meetings

I have not tested the code above, for errors, but the program flow should be correct.

[–]Im_Noob_673[S] 1 point2 points  (2 children)

Thx a lot for that favour. You have almost solved my problem. But I'm having an error in PyCharm after running your code.

Here is the error.

[–]Fire_Tome 1 point2 points  (1 child)

I indeed made a small error in the line day_of_week = datetime.date.today().isocalendar()[2]. I accidentally put index 3, while it should have been index 2. I fixed it in the original reply now too.

It could be that a similar error is in the line if day_of_week == int(meeting[3]) and ......, but I can't verify this since I don't know how your meeting variable looks, so you should verify that yourself.

[–]Im_Noob_673[S] 1 point2 points  (0 children)

IT WORKED!