user2726634
user2726634

Reputation: 77

Sending data to a Window with AutoIt Python

I am using Selenium and AutoIT to upload images to a site. Now I need to choose a file from the "File Upload" Window in Firefox and click Enter. So this is the AutoIT part of the code:

driver.find_element_by_xpath("/html/body/div[2]/div/div[2]/div/div/ul[1]/li/button").click()
    autoit.win_wait_active("File Upload", 5)
    autoit.send(os.path.join(mpath,"1.jpg"))
    autoit.send("{ENTER}")

This script works fine Now the problem is the Window needs to be active on my computer in order for the file to be uploaded and so I cannot do any other work while the script is running. How do I send the same data without making the window active?

Upvotes: 1

Views: 1763

Answers (1)

m.elewa
m.elewa

Reputation: 306

use this instead:

    autoit.win_wait("[CLASS:#32770;TITLE:Open]", 60)
    autoit.control_send("[CLASS:#32770;TITLE:Open]", "Edit1", os.path.join(mpath,"1.jpg"))
    autoit.control_click("[CLASS:#32770;TITLE:Open]", "Button1")

Upvotes: 2

Related Questions