Sign in to follow this  
Followers 0
markkrj

Click ok on 2 different msgbox

7 posts in this topic

Hi, can you guys help me? i need a script that click "ok" on 2 different error messages. My 2 scripts are already working fine if the software that bring me the error is activated, But if isn't, I need to click on the first message to start the script.

first: 

while 1
; Wait for the window to become active...
$title = "Sistema Faraó - Apoio à Vendas"; the message title
WinWaitActive($title)
ControlClick($title, "OK", "[CLASS:Button;INSTANCE:1]")
WEnd
 
and then:
 
while 1
; Wait for the window to become active...
$title = "Sistema Faraó - Apoio à Vendas"; the message title
WinWaitActive($title)
ControlClick($title, "OK", "[CLASS:Button;INSTANCE:1]")
WEnd
 
I also wanna know if is possible to make this in a single script.
 
 

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Edit:

Wrong Topic :S

Edited by Danyfirex

Share this post


Link to post
Share on other sites

sorry about my english, this isn't my main language. With "first message" I wanna say the first error, because it comes in background, not in focus. So I need to bring it to foreground to the script work.

the scripts are the same excpet the title. Because I always get the two errors together.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Something like this...

$title1 = "Sistema Faraó - Apoio à Vendas"; the message title
$title2 = "Sistema Faraó - Apoio à Vendas"; the message title

While 1
    If WinExists($title1) Then
        WinActivate($title1)
        WinWaitActive($title1)
        ControlClick($title1, "", "[CLASS:Button;INSTANCE:1]")
    EndIf

    If WinExists($title2) Then
        WinActivate($title2)
        WinWaitActive($title2)
        ControlClick($title2, "", "[CLASS:Button;INSTANCE:1]")
    EndIf
    
    Sleep(250)
WEnd
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

If you run this in a loop, you will grab ALL visible windows of your process...it's very helpful for this kind of thing.

You can then grab the handle, get the text/title/controls of the window, and figure out how to proceed.

$a = _WinAPI_EnumProcessWindows($iPid)
_ArrayDisplay($a)

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Thanks guys!! Now it's working fine! Was tired of clicking lol

And John, realy the two scripts was exactly the same. The title should be different loool...Just fixed it in the code.. Thanks

Mod can close the topic if want to...

Edited by markkrj

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