Jump to content

WinWaitActive wait forever...


Jaw7
 Share

Recommended Posts

Here is my script.

The ControlCommand in second line is dealing with a combobox. When it makes its seleciton, my program will automatically open "Dialog 2".

But it seems that the script stucked at WinWaitActive while actually the dialog is active.

I'm sure it's not a matching problem. Because:

When the script stucked, I move my mouse and close manually "Dialog 2", and select the combobox to make it open "Dialog 2" again. This time, WinWaitActive find its target and the script just passed.

So have you ever faced this kind of problems?

WinWaitActive("Dialog 1")
ControlCommand("Dialog 1","",225,"SelectString","string")
WinWaitActive("Dialog 2")
$st = ControlSetText("Dialog 2", "", 7000, "11" )
MsgBox(1,"test",$st)
Link to comment
Share on other sites

What I'm guessing is that Dialog 2 isn't being activated or set as the active window at all. Or Dialog 2 isn't active long enough for your script to notice it being active.

Thanks for the reply.

After that, I tried to add WinActivate before WinWaitActive. Make the whole script like this:

WinWaitActive("Dialog 1")
ControlCommand("Dialog 1","",225,"SelectString","string")
WinActivate("Dialog 2")
WinWaitActive("Dialog 2")
$st = ControlSetText("Dialog 2", "", 7000, "11" )
MsgBox(1,"test",$st)

But it act just like the previous one.

Link to comment
Share on other sites

So have you ever faced this kind of problems?

Yes.

Try adding WinWait:

WinWaitActive("Dialog 1")
ControlCommand("Dialog 1","",225,"SelectString","string")

WinWait("Dialog 2")
WinActivate("Dialog 2")
WinWaitActive("Dialog 2")
$st = ControlSetText("Dialog 2", "", 7000, "11" )
MsgBox(1,"test",$st)

If that does not work for you, add timeouts and check the return from each Win... line.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Yes.

Try adding WinWait:

WinWaitActive("Dialog 1")
ControlCommand("Dialog 1","",225,"SelectString","string")

WinWait("Dialog 2")
WinActivate("Dialog 2")
WinWaitActive("Dialog 2")
$st = ControlSetText("Dialog 2", "", 7000, "11" )
MsgBox(1,"test",$st)

If that does not work for you, add timeouts and check the return from each Win... line.

I tried this. WinWait also can't find Dialog 2. I guess WinExists can't work either.

And I just notice that Dialog 1 and Dialog 2 use a same class name. Is that the reason?

Link to comment
Share on other sites

I tried this. WinWait also can't find Dialog 2. I guess WinExists can't work either.

And I just notice that Dialog 1 and Dialog 2 use a same class name. Is that the reason?

I'm not sure, but I've had some windows that AutoIt could never find the title. Last resort might be the Pixel functions. Once you know that it is there, then you might have to click on it via AutoIt and do the steps you mentioned here:

When the script stucked, I move my mouse and close manually "Dialog 2", and select the combobox to make it open "Dialog 2" again. This time, WinWaitActive find its target and the script just passed.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

There shouldn't be a problem if the dialogs have the same class name since you are using titles to match them. The only scenario I can think of now is that you are using the wrong title to match the dialog. Try reviewing whether the titles are correct, using the Window Info Tool.

you could also try putting this at the top of your script to make your title matching return true on partial matches.

Opt("WinTitleMatchMode", 2)
Edited by omikron48
Link to comment
Share on other sites

@omikron48 Thanks for your method but it still doesn't work. I'm sure I wrote the right title of Dialog 2, because when I trigger it manually, it could be found. So partial match can't solve my problem.

@jinyue115 The script stucked at WinWait("Dialog 2"), not ControlSetText. So I believe this won't work either.

@herewasplato I will try to find some pixel functions. Thank you for your help!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...