Jump to content

Recommended Posts

Hello everyone!

I'm trying to polish some of my functions now that I botched up my GUI and basic functions, and have a somewhat realiable code. I happen to have a few questions, to which I would like to get some insight from you.

I have an "old" problem with my script. While it works with the PDFCreator (1.7.1 but I think It just got updated a few days ago)  it sometimes seems to skip ControlSetText. I don't know why this happens but I developed a habbit of double up on it, which decresed the occurrence of these bugs but it's far from a solution, and it isnt even an elegant bandage on it. Anyidea why this could happen? In some other functions I used the click on the said coordinates twice then send Delete and type the name i want, that seems to work well.

Another problem is, that sometimes when I try to make the script to click on a button, it simply doesnt do that, or since everytime this button is the Save button  (in this example at least)  which is the highlighted button on the form I simply used Send("{ENTER}") but it doesnT perform on a 100% neither. Because of this I'm experimenting with the WinWaitActivate 's timeut function. I'm trying to make it so if the window that should pop up next isn't activateing, the script tries to click on the Save button again. When I tried to test it, I commented out the first Save button click to see how it works, and It basicly Jumped a "nameing syntax" ahead (sorry don't really know how else to say it) so instead of blablabla(1) it wrote blablabla(2) and tried to save like that. I think this is because of a logical error from my part, but can't seem to figure it out (Once I get it wrok I think I will write it as a different function and call it everytime i need it, that would make the code a bit more tidy)

Also a the beginning of the code I try to handle the possibility of the PDFCreator signaling that there is a new update to download, I tried to check for the MsgBox but it didn't work when a real update came while i was working and it stuck. Makeing things worst I'm not sure how to test it effectivly without actuaql software update, should I try to write a MsgBox for i myself? I don't think thats a dependable test of the script.

I would also like to check the Text from the textbox PDFCreator use for saving the PDFs, to see if it's at least something like it should be, I already have a solution for that, and I gonna check for it now but I think this is already a pretty impressive wall of text so thank you if you even read through it. I maybe ask other questions later. Ask anything and I try to provide what you asks for.

Thanks again

Code: 

ControlClick("Megerősítés", "Igen", "[CLASSNN:TBitBtn2]")
    Sleep(500)
    WinWaitActive("Információ", "Sikeres Topup feltöltés")
    WinKill("Információ", "Sikeres Topup feltöltés")
    Sleep(3000)
    If WinActivate("PDFCreator", "Újabb verzió érhető el:") Then ;PDF Creator new version handleing
        WinClose("PDFCreator", "Újabb verzió érhető el:")
    EndIf
    WinWaitActive("PDFCreator")
    Sleep(500)
    ControlFocus("PDFCreator", "", "ThunderRT6TextBox5")
    Sleep(1000)
    Local $date = "\" & ControlGetText("PDFCreator", "", "[CLASSNN:ThunderRT6TextBox5]")
    Local $TopUpdate = "TeszttTopUp_KP_Euro_sztornó_vásárlás" & ControlGetText("PDFCreator", "", "[CLASSNN:ThunderRT6TextBox5]")
    Local $TopUpdate2 = "TeszttTopUp_KP_Euro_számla_sztornó_vásárlás" & ControlGetText("PDFCreator", "", "[CLASSNN:ThunderRT6TextBox5]")
    Sleep(500)
    WinActivate("Folyószámla", "")
    ControlClick("Folyószámla", "", "[CLASSNN:TAdvBitBtn12]")
    WinActivate("Információ", "")
    Sleep(500)
    Local $Egyenleg = WinGetHandle("Információ", "")
    _ScreenCapture_CaptureWnd(@MyDocumentsDir & $date & "egyenleg.jpg", $Egyenleg)
    Sleep(400)
    WinKill("Információ")
    WinActivate("PDFCreator")
    Sleep(2000)
    ControlSetText("PDFCreator", "", "ThunderRT6TextBox6", $TopUpdate & "(1)")
    Sleep(500)
    ControlSetText("PDFCreator", "", "ThunderRT6TextBox6", $TopUpdate & "(1)")
    ControlClick("PDFCreator", "", "[CLASSNN:ThunderRT6CommandButton7]")
    Sleep(300)
    WinWaitActive("Mentés másként", "", 10)
    If WinWaitActive = 0 Then
        WinActivate("PDFCreator")
        ControlClick("PDFCreator", "", "[CLASSNN:ThunderRT6CommandButton7]")
        WinWaitActive("Mentés másként", "", 10)
    EndIf
    Sleep(300)
    Send("{ENTER}")
    WinWaitActive("PDFCreator","",10)
    If WinWaitActive("PDFCreator") = 0 Then
        ControlClick("Mentés Másként","","[CLASSNN:Button1]")
        WinWaitActive("PDFCreator","",10)
    EndIf
    Sleep(1000)
    ControlSetText("PDFCreator", "", "ThunderRT6TextBox6", $TopUpdate & "(2)")
    Sleep(1000)
    ControlSetText("PDFCreator", "", "ThunderRT6TextBox6", $TopUpdate & "(2)")
    ControlClick("PDFCreator", "", "[CLASSNN:ThunderRT6CommandButton7]")
    Sleep(300)
    WinWaitActive("Mentés másként", "", 10)
    If WinWaitActive = 0 Then
        WinActivate("PDFCreator")
        ControlClick("PDFCreator", "", "[CLASSNN:ThunderRT6CommandButton7]")
        WinWaitActive("Mentés másként", "", 10)
    EndIf
    Sleep(300)
    Send("{ENTER}")
    WinWaitActive("PDFCreator","",10)
    If WinWaitActive("PDFCreator") = 0 Then
        ControlClick("Mentés Másként","","[CLASSNN:Button1]")
        WinWaitActive("PDFCreator","",10)
    EndIf
    Sleep(1000)
    ControlSetText("PDFCreator", "", "ThunderRT6TextBox6", $TopUpdate2 & "(1)")
    Sleep(1000)
    ControlSetText("PDFCreator", "", "ThunderRT6TextBox6", $TopUpdate2 & "(1)")
    ControlClick("PDFCreator", "", "[CLASSNN:ThunderRT6CommandButton7]")
    Sleep(300)
    WinWaitActive("Mentés másként", "", 10)
    If WinWaitActive = 0 Then
        WinActivate("PDFCreator")
        ControlClick("PDFCreator", "", "[CLASSNN:ThunderRT6CommandButton7]")
        WinWaitActive("Mentés másként", "", 10)
    EndIf
    Sleep(300)
    Send("{ENTER}")
    WinWaitActive("PDFCreator","",10)
    If WinWaitActive("PDFCreator") = 0 Then
        ControlClick("Mentés Másként","","[CLASSNN:Button1]")
        WinWaitActive("PDFCreator","",10)
    EndIf
    Sleep(1000)
    ControlSetText("PDFCreator", "", "ThunderRT6TextBox6", $TopUpdate2 & "(2)")
    Sleep(1000)
    ControlSetText("PDFCreator", "", "ThunderRT6TextBox6", $TopUpdate2 & "(2)")
    ControlClick("PDFCreator", "", "[CLASSNN:ThunderRT6CommandButton7]")
    Sleep(300)
    WinWaitActive("Mentés másként", "", 10)
    If WinWaitActive = 0 Then
        WinActivate("PDFCreator")
        ControlClick("PDFCreator", "", "[CLASSNN:ThunderRT6CommandButton7]")
        WinWaitActive("Mentés másként", "", 10)
    EndIf
    Sleep(300)
    Send("{ENTER}")

    WinActivate("Folyószámla")
    ControlClick("Folyószámla", "Topup sztornó (utolsó)", "[CLASSNN:TAdvBitBtn13]") ; Miért van Befizetés ablak?
    
    WinActivate("Megerősítés")
    
    Send("{ENTER}")
    WinWaitActive("Megerősítés")
    ControlClick("Megerősítés", "", "[CLASSNN:TBitBtn1]")
    
    Sleep(500)
    WinWaitActive("PDFCreator","",10)
    If WinWaitActive("PDFCreator") = 0 Then
        ControlClick("Mentés Másként","","[CLASSNN:Button1]")
        WinWaitActive("PDFCreator","",10)
    EndIf
Link to comment
Share on other sites

The function itselfs is trying to automate some testing which was done by the users before, it hast to handle a lot of different windows as they popup reporting different "irrelevant things" or ask for extra conformation, so These are the different winwaitactive -> winkill same window. I think the code is hard to read for anyone else, I use tidyAutoIt but this doesn't prevent me to write very simplistic codes, sorry for that

Link to comment
Share on other sites

The best way to do debugging, especially on a complex script, is to set up value (variable etc) testing.

The three methods I use, are

[1] Msgbox

[2] Console in SciTE.

[3] Writing to file (txt or ini)

There are debug programs available too.

In many cases, you are the only one who is in a position to do an effective debug, especially where dependencies (etc) are involved.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

The script is not really large enough to prevent you from adding it to a new script one or more lines at a time and testing if the script works up to that point. If you run into a problem this way then ask on the forums.

One thing I see that is unnecessary is the sleep after the winwait. That's what winwait is for. That being said I too sometimes add a sleep after a winwait.

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

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

×
×
  • Create New...