Sign in to follow this  
Followers 0
koushik

Optimizing the code - From Polling to events

6 posts in this topic

Here is a working code for a function i wrote.

CODE

Func WaitTillLoad($title)

while True

$text = ControlGetText ( $title, "OK", 2 )

sleep (20)

if $text == "OK" Then

Return

EndIf

Wend

EndFunc

This works fine - but it polls constantly for the change of the text in the control. Is it possible to achieve teh same functionality with some event mechanism?\

Cheers

Koushik

Share this post


Link to post
Share on other sites



Here is a working code for a function i wrote.

CODE

Func WaitTillLoad($title)

while True

$text = ControlGetText ( $title, "OK", 2 )

sleep (20)

if $text == "OK" Then

Return

EndIf

Wend

EndFunc

This works fine - but it polls constantly for the change of the text in the control. Is it possible to achieve teh same functionality with some event mechanism?\

Cheers

Koushik

Perhaps you could check for this control with an AdLibEnable() function. That would allow your script to get other things done while periodically checking for this control.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Perhaps you could check for this control with an AdLibEnable() function. That would allow your script to get other things done while periodically checking for this control.

:)

AdLibEnable() also would result in polling - which would be less frequent than the polling involved in the given code - but is there something totally event based?

The GUI event mode mentioned in the help file - is it of any use?

Thanks

Koushik

Share this post


Link to post
Share on other sites

AdLibEnable() also would result in polling - which would be less frequent than the polling involved in the given code - but is there something totally event based?

The GUI event mode mentioned in the help file - is it of any use?

Thanks

Koushik

The Gui OnEvent mode is for GUIs you create.

I'm guessing that your function is waiting for an external program window to load, not an AutoIt Gui?

Give us some more information (about the program you're waiting for) and we might be able to help...

Share this post


Link to post
Share on other sites

The Gui OnEvent mode is for GUIs you create.

I'm guessing that your function is waiting for an external program window to load, not an AutoIt Gui?

Give us some more information (about the program you're waiting for) and we might be able to help...

The OK button is created in the window based on whether the page is loaded or not. So when the ok button is available I can retrieve some information which is loaded.

Get me?

Share this post


Link to post
Share on other sites

If there's no other instance of "OK" in the AutoIt-detectable text of any controls, a simple WinWait($title, "OK") would work.


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

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