Jump to content

Loop to close confirmation boxes does not work


Recommended Posts

Attached is a screenshot of my example.

I may have several charts on my Metastock program that I want to close. A confirmation box will pop up to ask me to confirm if I want to close each chart even though I want to close all. See attachment. post-24895-1242092270_thumb.png

The text inside the box varies according to the layout numbers: "Save changes to Layout5?" can be changed to "Save changes to Layout46?". My code below works only in closing once. It does not seem to find the next confirmation box.

CODE
Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",2)

Opt("WinSearchChildren", 1)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

Opt("WinTextMatchMode", 2)

#Include <WinAPI.au3>

WinWait("MetaStock Professional", "Save changes to Layo", 1)

Do

$hWin = WinGetHandle("MetaStock Professional", "Save changes to Layo")

_WinAPI_SetFocus($hWin)

WinActivate($hWin)

WinWaitActive($hWin,1)

Send("!n")

Until WinExists("MetaStock Professional", "Save changes to Layo") = 0

Can someone help with a proper code?

Link to comment
Share on other sites

While 1
$hWin = WinGetHandle("MetaStock", "Save changes to Layo")
If @error = 1 Then
ExitLoop
Else
WinActivate($hWin)
Send("!n")
EndIf
WEnd

[center]It's a question of mind over matter, if I don't mind, it doesn't matter.[/center]
Link to comment
Share on other sites

System26,

It still closes only one box with your code. I am wondering whether the Mcafee Antivirus is interfering.

Thomas

While 1
$hWin = WinGetHandle("MetaStock", "Save changes to Layo")
If @error = 1 Then
ExitLoop
Else
WinActivate($hWin)
Send("!n")
EndIf
WEnd
Link to comment
Share on other sites

EXODIUS,

You're right. I GOOFED. And it's working now. Thank you and thank you to System24 too.

Thomas

Do some of the confirmation boxes actually have the title "MetaStock Professional"? Your example image only shows "MetaStock"...

Edited by Mucho
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...