Jump to content

Press ok if specified box appears


Recommended Posts

Hi guys:

Im totally new to programming at all, but I sure got the idea. So it would be very nice if s.o. could help me with the following:

I want the script to wait until a specific window appears (Window Info);

CODE
>>>> Window <<<<

Title: Please Register!

Class: RBWindow

Position: 313, 307

Size: 398, 128

Style: 0x94C00000

ExStyle: 0x00000101

>>>> Control <<<<

Class: Button

Instance: 1

ID:

Text: OK

Position: 478, 397

Size: 69, 23

ControlClick Coords: 50, 14

Style: 0x50000001

ExStyle: 0x00000000

>>>> Mouse <<<<

Position: 528, 411

Cursor ID: 0

Color: 0xC7D5E7

>>>> StatusBar <<<<

>>>> Visible Text <<<<

OK

>>>> Hidden Text <<<<

As soon as this window appears the OK button should be pressed (no delay necessary), either thru Mouse or Enter button.

After OK is pressed the window will disappear but pop up again within a few secs till 2 mins.

I've already skim read thru the help and forums but haven't yet found what I wanted.

If you were so kind as to write this specific script I'd be very pleased.

Thank you very much

RoSh

Link to comment
Share on other sites

Try this:

While 1
WinWait("Please Register!")
If WinExists("Please Register!") Then
WinActivate("Please Register!")
Send("{ENTER}")
WEnd
thank you very much Ill try this.

One question:

will the script stay active and repeat automatically?

RoSh

Link to comment
Share on other sites

Try this:

While 1
WinWait("Please Register!")
If WinExists("Please Register!") Then
WinActivate("Please Register!")
Send("{ENTER}")
WEnd
sorry when I try to run this it says:

Line 7 (File "C:\........\OK Script 1.au3):

WEnd

Error: "Wend statement with no matching "While" statement.

Link to comment
Share on other sites

...Error: "Wend statement with no matching "While" statement.

Which is a secret code phrase meaning - missing EndIf:
While 1
    WinWait("Please Register!")
    If WinExists("Please Register!") Then
        WinActivate("Please Register!")
        Send("{ENTER}")
    EndIf
WEnd
Edited by herewasplato

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

Link to comment
Share on other sites

with

CODE
WinWait("Please Register!")

If WinExists("Please Register!") Then

WinActivate("Please Register!")

Send("{ENTER}")

repeat

EndIf

it gives me the error:

Line 5 (File "c:\.....-.-)

repeat

^ ERROR

Error: Error parsing function call.

?

Link to comment
Share on other sites

Oh, sry, I had a mistake in my script. It's fixed now. And yes, this script will repeat automatically, look at While...WEnd in AutoIt v3 help file.

EDIT: There is no "repeat" function, that's why your script gives you an error. While...WEnd takes care of repeating your code.

Edited by poisonkiller
Link to comment
Share on other sites

with

CODE
WinWait("Please Register!")

If WinExists("Please Register!") Then

WinActivate("Please Register!")

Send("{ENTER}")

repeat

EndIf

it gives me the error:

Line 5 (File "c:\.....-.-)

repeat

^ ERROR

Error: Error parsing function call.

?

Ok this was just what I tried meanwhile

IT WORKS!

thank you so very much herewasplato!!

I think I'll keep using this scripts, they seem to be very useful for anything and Im interested in such fiddly stuff.

Have a nice evening

RoSh

Link to comment
Share on other sites

Take note of the WinWaitActive that I edited into my last code post...

ok if I understand that right the script will wait until the window is really active right?

It works without but thanks anyway.

And if the window that was active before shall be displayed afterwards?

CODE
While 1

WinWait("Please Register!")

If WinExists("Please Register!") Then

WinActivate("Please Register!")

Send("{ENTER}") and

Send("{Alt+Tab}") ;<-----this is my first idea. How is it right?

EndIf

WEnd

How would this really work?

Thanks

Link to comment
Share on other sites

ok if I understand that right the script will wait until the window is really active right?

It works without but thanks anyway.

And if the window that was active before shall be displayed afterwards?

CODE
While 1

WinWait("Please Register!")

If WinExists("Please Register!") Then

WinActivate("Please Register!")

Send("{ENTER}") and

Send("{Alt+Tab}") ;<-----this is my first idea. How is it right?

EndIf

WEnd

How would this really work?

Thanks

If

Send("{ENTER}") and

Send("{Alt+Tab}") ;<-----this is my first idea. How is it right?

is supposed to be like 1 line you need to put a _ after and so

Send("{ENTER}") and_

Send("{Alt+Tab}") ;<-----this is my first idea. How is it right?

Link to comment
Share on other sites

ok if I understand that right the script will wait until the window is really active right?...

Well, it is not a question of it being "really active" it is a question of timing. The first code posted (once fixed) takes about 500 ms to execute before it gets to the send line of code. The second method that I posted takes 750 ms before that send happens. Both will work until you start attempting to speed up the code by using an Opt/WinWaitDelay line. In other words, the window needs to be ready to accept the ENTER that you send to it. WinWaitActive helps with that. In your first post, you said that you wanted it to be a fast script. By default, it will be relatively slow unless you use the Opt line.

...And if the window that was active before shall be displayed afterwards?...

The "z order" of the windows is not changed. In your first post, you said that pressing ENTER would make the window of interest disappear. Once it has disappeared, then the window that was active before the pop up should be active after the pop up goes away.

Send("{ENTER}") and

Send("{Alt+Tab}") ;<-----this is my first idea. How is it right?

"and" is in not valid syntax here

the alt tab is not needed

Edited by herewasplato

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

Link to comment
Share on other sites

Well, it is not a question of it being "really active" it is a question of timing. The first code posted (once fixed) takes about 500 ms to execute before it gets to the send line of code. The second method that I posted takes 750 ms before that send happens. Both will work until you start attempting to speed up the code by using an Opt/WinWaitDelay line. In other words, the window needs to be ready to accept the ENTER that you send to it. WinWaitActive helps with that. In your first post, you said that you wanted it to be a fast script. By default, it will be relatively slow unless you use the Opt line.

The "z order" of the windows is not changed. In your first post, you said that pressing ENTER would make the window of interest disappear. Once it has disappeared, then the window that was active before the pop up should be active after the pop up goes away.

Send("{ENTER}") and

Send("{Alt+Tab}") ;<-----this is my first idea. How is it right?

"and" is in not valid syntax here

the alt tab is not needed

Ok thanks

That was what I said indeed, but when the Window appears, the program it comes from also maximizes and will stay there. This is why I want the script to "Alt+Tab".

Thanks again and in advance!

RoSh

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