Sign in to follow this  
Followers 0
SorryButImaNewbie

Do.... Until WinActivate stuck (nested in If... Then)

5 posts in this topic

Hello everyone!

Sorry if this question should be in the generel help forum (it is there as well, also worded a bit differently, I solved many of the things i asked there, while another problem poped up)

As the title suggest, my problem is that once the window I'm waiting for in my Do until loop is poped up, the script stops. Tried to MsgBox to see if its leave the Do.. Until and has a problem with Endif but it seems that it stuck right at the end of the until line. Everything else works as intended (even if my logic is stupid sometimes, but Im a beginner so its okey for now)

Could it be the problem that both possible popup window has the same title? (thats why i definde the texts)

The code should try codes from an array i wrote inside the script in a textbox, but all codes can be used twice a day, so when it says that the code was used already, it jumps to tne next one until it finds a code that the other program accept.

The code as it follow

If WinExists("Információ", "Elérte a maximális napi vásárlási mennyiséget! ( 2 )") Then
Do
WinKill("Információ", "Elérte a maximális napi vásárlási mennyiséget! ( 2 )") ;message about code used 2 today already
$i = $i + 1
ControlFocus($handle, "", "TEdit1") ;entering the specification to the window/form where I try the next code
Send("{CTRLDOWN}v{CTRLUP}")
ControlClick($handle, "", "[CLASSNN:TAdvBitBtn23]")
WinWaitActive("Befizetés")
Local $handle3 = WinGetHandle("Befizetés") ;adding  the specification to the window/form where I try the next code
ControlSend($handle3, "", "[CLASSNN:TComboBox3]", "ü{ENTER}") 
ControlSend($handle3, "", "[CLASSNN:TEdit5]", $arrayEuroShell[$i])
ControlClick($handle3, "", "[CLASSNN:TBitBtn2]")
Sleep(1000)
Until WinActive("Információ", "Sikeres jegyvásárlás!") ;message of succesfull code entry
MsgBox(0, "Teszt", "Jelentem ki jöttünk a Do.... Until ágból!") ;test MsgBox
;~  ----------------------------------------------------???????????????????????????????????????????????????-------------------------------------- ;here is where i stuck (messagebox doesnt apper)
EndIf
 
Local $handleinfo = WinGetHandle("Információ", "Sikeres jegyvásárlás!") 
ControlClick($handleinfo, "", "[CLASSNN:TBitBtn1]")

 

Thank you for your help, and sorry if I shouldn't post these kind of questions here

 

Share this post


Link to post
Share on other sites



instead of waiting for a window to be active, wait for it to exist or is visible, then activate it.

also if you put this tray icon option in, you can hover over the tray icon for your script while it is running and see the exact line number that your script is running, or hanging on.

Opt("TrayIconDebug", 1)

:alien:

1 person likes this

if @error Then
	MsgBox(262192,"",@ComputerName&" slaps "&@UserName&" around a bit with a large trout!")
	EndIf

>Exit code: 0

REAL search results

"Yeah yeah yeah, patience. How long will that take?"  -Ed Gruberman

Share this post


Link to post
Share on other sites

Ohhh my god thank you!!!

I never have thought of that that this simple line showed me... It seems like Do.. Until wants to run once more after the until expression was fullfiled. I concluded this by traytip showing me that script stands at line 760 which is WinWaitActivate("Befizetés")... I commented it out and tried with a sleep(1000) instead of it. It works, thank you so much alienclone!!! I stuck with this problem for 3 days for around 20 hours now.

Do you happend to know if Do.. Until runs one more time after the until expression is fullfiled as i assumed? Or is this because of something else?

(thank you again!!)

Share this post


Link to post
Share on other sites

do until will only run once unless inside something like While() WEnd.

you are probably mistaken if it seems to repeat.

:alien:


if @error Then
	MsgBox(262192,"",@ComputerName&" slaps "&@UserName&" around a bit with a large trout!")
	EndIf

>Exit code: 0

REAL search results

"Yeah yeah yeah, patience. How long will that take?"  -Ed Gruberman

Share this post


Link to post
Share on other sites

well it seems to repeat, actually its sure, since it runs again and again.

thank you anyway, Opt("TrayIconDebug", 1) will speed up my work in the future as well :)

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