rearrange the options on the screen by dragging to their correct position
#the initial position of the options is dictionary opt_pos
the desired order is myrespo
#the problem is e.g. when “C” is dragged to the position of “A” , circular shif will take place on the screen.
the code need follow or track where each options shifted and move to their shifted position and rearrange them according to myrespo list
opt_pos = {"A": (100, 200), "B": (300, 400), "C": (500, 600), "D": (700, 800)}
myrespo = ["C", "B", "D", "A"]
tracking = {}
for index, goto in enumerate(myrespo):
if index == 0:
pyautogui.moveTo(opt_pos[goto])
pyautogui.dragTo(opt_pos["A"], duration=0.4)
if goto == "A":
tracking["A"] = opt_pos["A"]
tracking["B"] = opt_pos["B"]
tracking["C"] = opt_pos["C"]
tracking["D"] = opt_pos["D"]
elif goto == "B":
tracking["A"] = opt_pos["B"]
tracking["B"] = opt_pos["A"]
tracking["C"] = opt_pos["C"]
tracking["D"] = opt_pos["D"]
elif goto == "C":
tracking["A"] = opt_pos["C"]
tracking["B"] = opt_pos["A"]
tracking["C"] = opt_pos["B"]
tracking["D"] = opt_pos["D"]
elif goto == "D":
tracking["A"] = opt_pos["D"]
tracking["B"] = opt_pos["A"]
tracking["C"] = opt_pos["B"]
tracking["D"] = opt_pos["C"]
elif index == 1:
pyautogui.moveTo(tracking[goto])
pyautogui.dragTo(opt_pos["B"], duration=0.4)
if goto == "A":
print("skipped")
elif goto == "B":
print("skipped")
elif goto == "C":
tracking["B"] = opt_pos["C"]
tracking["C"] = opt_pos["B"]
elif goto == "D":
tracking["B"] = opt_pos["D"]
tracking["C"] = opt_pos["B"]
tracking["D"] = opt_pos["C"]
elif index == 2:
pyautogui.moveTo(tracking[goto])
pyautogui.dragTo(opt_pos["C"], duration=0.4)
pyautogui.moveTo(opt_pos["submit"])
pyautogui.click()