jacexh / pyautoit

Python binding for AutoItX3.dll
MIT License
269 stars 74 forks source link

Does not detect the windows #26

Closed Franjey closed 4 years ago

Franjey commented 5 years ago

image

Upload windows after clicking "Upload Picture" in Instagram:

image

import autoit
from time import sleep

autoit.win_wait_active("Abrir", 5)
autoit.control_focus("Abrir", 1148)
sleep(2)
autoit.control_set_text("Abrir", 1148, "Text example")

autoit.autoit.AutoItError: timeout on wait for activate window

Any idea? I am running the script while the window is open.

Edit: I ran the same (ignoring the escape controls) code in SciTE editor (autoit scripting language) and works properly:

HotKeySet("^!x", "MyExit")
Local $Text = "C:\Users\Francisco\PycharmProjects\Instagram\Ipod_Touch.jpg"

; Script Start - Add your code below here
WinWaitActive("Abrir", "", 5)

; Set input focus to the edit control of Notepad using the handle returned by WinWait.
ControlFocus("Abrir", "", 1148)

; Wait for 2 seconds.
Sleep(2000)

; Send Text
ControlSetText("Abrir", "", 1148, $Text)

ControlClick("Abrir","", 1)

Func MyExit()
    Exit
EndFunc   ;==>MyExit
michealchew commented 5 years ago

Hi,

Please try to change the following line: autoit.win_wait_active("Abrir", 5) => autoit.win_activate("Abrir")

As win_wait_active is not activating your instagram upload photo directory browsing window automatically but it is waiting for it to be active. Use win_activate to force it to be active.

Yoong Loong