Jump to content

Click ok on 2 different msgbox


markkrj
 Share

Go to solution Solved by JohnOne,

Recommended Posts

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.
 
 
Link to comment
Share on other sites

Link to comment
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.

Link to comment
Share on other sites

  • Solution

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.

Link to comment
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.
Link to comment
Share on other sites

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
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...