Jump to content

code doesn't go in to an If loop, while I think it should


Go to solution Solved by SorryButImaNewbie,

Recommended Posts

Hello!

I try to develope a script that works with the checking accounts (hope this is the right word for it, but doesnt really matter) in my company's data base. During a listing, I want it to select a random account, however the accounts on the list can be 2 different kind, and only one of them is eligible for the work I want to do with it.

When the "wrong" kind of account is selected, there is a MsgBox with "Információ" title (type:0, and an other one after this, and then a third where I could do the changes I want to do, but the system wont allow it even if I try, (the software we got and use is crappy, I had many laugths testing it, and still have some today :) , it is full with logical errors, and just simply stupid/meaningless solutions)

My plan is to make the script wait and check for this "Információ" window, and act accordingly if it pops up or not.

My code:

If Not WinExists("UDUsziMainForm") Then
        MsgBox(0, "Üzenet", "Nem találom az UD_üszit, kérem indítsa el a programot!")
        $TopUp_KP_EURORun = False
        Return
    EndIf
    Local $UD_usziPID = WinGetHandle("UDUsziMainForm")
    WinActivate($UD_usziPID, "")
    WinActivate("UDUsziMainForm")
    Sleep(500)
    WinMove($UD_usziPID, "", 0, 0)
    WinActivate("UDUsziMainForm")
    MouseClick("", 600, 45)
    MouseClick("", 385, 90)
    $WindowWaitCheck = WinWaitActive("Objektum kiválasztása", "", 3)
    If $WindowWaitCheck = 0 Then
        WinActivate("UDUsziMainForm")
        MouseClick("", 600, 45)
        MouseClick("", 385, 90)
        Sleep(1000)
        WinMove("Objektum kiválasztása", "", 0, 0)
    EndIf
    WinMove("Objektum kiválasztása", "", 0, 0)
    MouseClick("", 44, 234)
    Sleep(100)
    MouseClick("", 100, 300, 2)
    WinWaitActive("Folyószámla", "") 
    Sleep(500)
    ;MsgBox(0, "Aaargggghh!", "I'm a pirate!!") debugging
    Local $Random = Random(1, 50)
    #cs ;part commented out so I arrive to a kind of account for sure, that is the "wrong" kind, to test how the script deal with it
    For $a = 1 To Random(1, 5)
        ControlSend("Folyószámla", "", "[CLASSNN:TAdvQueryGrid1]", "{PGDN 3}")
    Next
    For $a = 1 To $Random
        ControlSend("Folyószámla", "", "[CLASSNN:TAdvQueryGrid1]", "{DOWN}")
    Next
    #ce
    ControlClick("Folyószámla", "", "[CLASSNN:TAdvBitBtn15]")
    Sleep(1000) ;Here comes to code I made to handle the situation

    $WindowWaitCheck = WinWaitActive("Információ", "", 5)
    If $WindowWaitCheck = 0 Then
        WinClose("Információ", "")
        Sleep(1500)
        WinClose("Információ", "")
        Sleep(1500)
        WinClose("Befizetés", "")
        For $a = 1 To $Random
            ControlSend("Folyószámla", "", "[CLASSNN:TAdvQueryGrid1]", "{DOWN}")
        Next
        ControlClick("Folyószámla", "", "[CLASSNN:TAdvBitBtn15]")
        $WindowWaitCheck = WinWaitActive("Információ", "", 5)
    EndIf

    $WindowWaitCheck = WinWaitActive("Befizetés", "", 5)
    If $WindowWaitCheck = 0 Then
        ControlClick("Folyószámla", "", "[CLASSNN:TAdvBitBtn15]")
    EndIf
    Send("{TAB}E")
    ControlSetText("Befizetés", "", "[CLASSNN:TEdit4]", "5000")
    ControlSetText("Befizetés", "", "[CLASSNN:TEdit3]", "100")
    ControlClick("Befizetés", "", "[CLASSNN:TBitBtn2]")

Console on debug mode:

If Not WinExists("UDUsziMainForm") Then
0566: 0-0: Local $UD_usziPID = WinGetHandle("UDUsziMainForm")
0567: 0-0: WinActivate($UD_usziPID, "")
0568: 0-2: WinActivate("UDUsziMainForm")
0569: 0-1: Sleep(500)
0570: 0-0: WinMove($UD_usziPID, "", 0, 0)
0571: 0-0: WinActivate("UDUsziMainForm")
0572: 0-1: MouseClick("", 600, 45)
0573: 0-0: MouseClick("", 385, 90)
0574: 0-0: $WindowWaitCheck = WinWaitActive("Objektum kiválasztása", "", 3)
0575: 0-0: If $WindowWaitCheck = 0 Then
0582: 0-0: WinMove("Objektum kiválasztása", "", 0, 0)
0583: 0-0: MouseClick("", 44, 234)
0584: 0-0: Sleep(100)
0585: 0-0: MouseClick("", 100, 300, 2)
0586: 0-0: WinWaitActive("Folyószámla", "") ;ide egy If loop?
0587: 0-0: Sleep(500)
0594: 0-0: Local $Random = Random(1, 50)
0595: 0-0: #cs
0606: 0-0: ControlClick("Folyószámla", "", "[CLASSNN:TAdvBitBtn15]")
0607: 0-0: Sleep(1000)
0608: 0-0: $WindowWaitCheck = WinWaitActive("Információ", "", 5)
0609: 0-0: If $WindowWaitCheck = 0 Then
0624: 0-0: $WindowWaitCheck = WinWaitActive("Befizetés", "", 5)
0625: 0-0: If $WindowWaitCheck = 0 Then
0626: 0-0: ControlClick("Folyószámla", "", "[CLASSNN:TAdvBitBtn15]")
0627: 0-0: EndIf
0628: 0-0: Send("{TAB}E")
0629: 0-0: ControlSetText("Befizetés", "", "[CLASSNN:TEdit4]", "5000")
0630: 0-0: ControlSetText("Befizetés", "", "[CLASSNN:TEdit3]", "100")
0631: 0-0: ControlClick("Befizetés", "", "[CLASSNN:TBitBtn2]")
0632: 0-0: WinWaitActive("Megerősítés", "")
 
Edit:Also in line 0594 in the console ( Local $Random = Random(1, 50)) is colored red and highlighted with yellow, but no error message or anything and it runs
 
I also attached a pic with the window and AU3Info.
 
Thank you for the help! (also if you see some stupid dyntax, or something that should be done better feel free to point it out :) )

post-88591-0-50587800-1424258807_thumb.p

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