william price
william price

Reputation: 3

change datetime.weekday( ) to "MON"

I want the today variable to be whatever day of the week's x,y coordinates are. using datetime.weekday returns a 0 which I can't assign to a coordinate. I could use 7 if statements but that seems excessive. Is there better way?

MON = (340, 431)
TUE = (529, 432)
WED = (721, 436)
THUR = (912, 436)
FRI = (1107, 435)
SAT = (1293, 436)
SUN = (1484, 434)

dow = dt.today().weekday() #get day of week

if dow == 0:
    today = MON
if dow == 1:
    today = TUE

pyautogui.click(today) #if today is monday the x,y coordinates of (340, 431) will be here
time.sleep(1)

Upvotes: 0

Views: 162

Answers (1)

NuLo
NuLo

Reputation: 1528

Create an array with the coordinates and use dow as it's index:

coords = [(340, 431),(529, 432),(721, 436),(912, 436),(1107, 435),(1293, 436),(1484, 434)]

dow = dt.today().weekday()

today = coords[dow] # note that the first day of the week may not be monday

pyautogui.click(today)

Upvotes: 1

Related Questions