asweigart / pyautogui

A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.
BSD 3-Clause "New" or "Revised" License
10.22k stars 1.24k forks source link

Add function to drag & drop file #825

Closed thenewguy closed 9 months ago

thenewguy commented 9 months ago

It would be helpful if there was a drag & drop file option. It would be helpful if the file could be provided as a file path on disk and then given coordinates of where to drop on screen.

mikigo commented 9 months ago

Maybe you can give it a try

pyautogui.locateOnScreen()
pyautogui.dragTo()
thenewguy commented 9 months ago

In my mind I was thinking of a drag and drop by image path.

I think that yours would work if the file explorer was open - but would not work for what I am doing as the application is the only image displayed on the headless screen.

I was hoping to simulate what you've described. I'll close this issue as too specific. I've solved my problem with a different solution