Sign in to follow this  
Followers 0
benson

help on window detection

6 posts in this topic

For example, i'm currently running a set of processes that changes configurations for a program.

It's being looped using While WEnd loop. there are times it just keeps on going with the process and there are times when a window with an ok button pops up (like a msgbox).

my code uses the SelectString to change the combo box options. when a particular selection is made, it automatically pops up the msgbox.

While .....

set ComboBox item using SelectString

If WinExists("pop up box") Then

WinActivate("pop up box")

WinWaitActive("pop up box")

ControlClick("pop up box", "", "Button1") ; ok button

EndIf

Wend

the above code doesn't seem to work with the whole program but it works if i simulate manually, select the item in the combo and run the WinExists alone.

How do i make AutoIt detect the new window and click the ok button of the new window automatically.

Thanks.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Wait a second didn't see your code ( USE CODE TAGS) . are you sure it is button 1? Try using a window handle incase there is something messing up with the window titles.

Edited by Thatsgreat2345

Share this post


Link to post
Share on other sites

Wait a second didn't see your code ( USE CODE TAGS) . are you sure it is button 1? Try using a window handle incase there is something messing up with the window titles.

yep im sure everything else is working. i even tried putting a msgbox inside the if WinExist statement. The msgbox doesnt pop up. but if i simulate the program manually, it works.

is it possible that using select string will select a combo item before it is even processed?

Share this post


Link to post
Share on other sites

yep im sure everything else is working. i even tried putting a msgbox inside the if WinExist statement. The msgbox doesnt pop up. but if i simulate the program manually, it works.

is it possible that using select string will select a combo item before it is even processed?

Possibly, to tell you the truth I've had trouble with MsgBoxes popping up before with IE windows and I never did figure out how to detect them and never knew why they weren't being detected. But add some sleep in there as it may be a possibility.

Share this post


Link to post
Share on other sites

If WinExists("pop up box") Then
WinActivate("pop up box")
WinWaitActive("pop up box")
ControlClick("pop up box", "", "Button1"); ok button
EndIf

You might be having an issue with the redundant WinWaitActive tag. The line before that you already told the popup to activate, you probably dont need the winwait.

Other than that, it might be the ControlClick("pop up box", "", "Button1") where the second set of quotes should contain the text of the button.

Try making it ControlClick("pop up box", "Ok", "Button1") and see if that works, otherwise sending a {space} or {enter} would make it go away.

Share this post


Link to post
Share on other sites

If WinExists("pop up box") Then
WinActivate("pop up box")
WinWaitActive("pop up box")
ControlClick("pop up box", "", "Button1"); ok button
EndIf

You might be having an issue with the redundant WinWaitActive tag. The line before that you already told the popup to activate, you probably dont need the winwait.

Other than that, it might be the ControlClick("pop up box", "", "Button1") where the second set of quotes should contain the text of the button.

Try making it ControlClick("pop up box", "Ok", "Button1") and see if that works, otherwise sending a {space} or {enter} would make it go away.

done that, same problem. is it possible that the ControlCommand("WIN", "TAB", "ComboBox1", "SelectString", "ITEM") im using makes the window select the item causing the msg box to pop up even before reaching the line? ive tried using msgbox to check whether the script is running but it doesnt work.

MsgBox(0,"1","1")

ControlCommand("MSG", "TAB", "ComboBox1", "SelectString", "ITEM")

MsgBox(0,"1","2")

Output of the above code is:

MsgBox 1 pops up, then the popup window with the ok button displays before popping up MsgBox 2. It seems

Share this post


Link to post
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
Sign in to follow this  
Followers 0