0

The function P_10 is supposed randomly select a path from the dictionary Pic_10 and write it to pic_loc. Then the function py_auto is supposed to move the mouse cursor windows, explore the address bar, then write in the path to the folder.

It moves the cursor to the address bar but does not write anything.

Why is this code not working?

import pyautogui
import random
a = 287
b = 60
def py_auto():
    pyautogui.moveTo(a,b, duration = 1)
    pyautogui.click(a,b)
    pyautogui.write(pic_loc)

pic_loc =r""

Ovs_a_325 = r"D:\HOUSE PICS\10 marla\3F Ovs a ext @325"
OVB_8_425 = r"D:\HOUSE PICS\10 marla\8 overseas b @425"
ovb_40a_330 = r"D:\HOUSE PICS\10 marla"
tulip_47_350 =r"D:\HOUSE PICS\10 marla\47-c tulip @ 350"

Pic_10 = {
    1:Ovs_a_325,
    2:OVB_8_425,
    3:ovb_40a_330,
    4:tulip_47_350}
def P_10():
    global pic_loc
    pic_loc = random.choice(list(Pic_10.values()))
P_10()
py_auto()

for some reason pyautogui.write(pic_loc) is blue

noob
  • 33
  • 6
  • added pic for some reason pyautogui.write() is blue instead of yellow – noob Dec 25 '22 at 17:25
  • I'm not sure if this is related, but check out [this answer of mine](https://stackoverflow.com/questions/40619304/python-simulating-enter-keypress-in-a-game/65275819#65275819). Also, try running as Admin if you can – Minh-Long Luu Dec 26 '22 at 12:10

0 Answers0