Jump to content

GUI Running slow


Recommended Posts

I have to click the Save button multiple times for this code to work, and I also have to click the Exit button multiple times for the program to close.. any ideas?

Global $nCurVar, $nLastVar = ""

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $TreeView1 
        EndSwitch
    $nCurVar = Int(GUICtrlRead($InputNOP))
    If $nCurVar <> $nLastVar And $nCurVar > 0 And $nCurVar <= 1500 Then
        _GUICtrlComboBox_ResetContent($PNC1)
        For $i=1 To $nCurVar
            _GUICtrlComboBox_AddString($PNC1, $i)
        Next
        $nLastVar = $nCurVar
    ElseIf $nCurVar > 1500 Then
        MsgBox(0, "Error", "You must enter a number between 1 and 1500.")
        GUICtrlSetData($InputNOP, "")
    EndIf   
    $Answer1 = GUICtrlRead($InputJN)
    $Answer2 = GUICtrlRead($InputJT)
    $Answer3 = GUICtrlRead($InputSA)
    $Answer4 = GUICtrlRead($InputF)
    $Answer5 = GUICtrlRead($InputWO)
    $Answer6 = GUICtrlRead($InputWP)
    $Answer7 = GUICtrlRead($InputNOP)
    $msg = GUIGetMsg()
    Select
        Case $msg = $Save
            GUICtrlSetData($JN4, $Answer1)
            GUICtrlSetData($JT4, $Answer2)
            GUICtrlSetData($SA4, $Answer3)
            GUICtrlSetData($F4, $Answer4)
            GUICtrlSetData($WON4, $Answer5)
            GUICtrlSetData($WPN4, $Answer6)
            GUICtrlSetData($NOP4, $Answer7)
    EndSelect
WEnd

let me know if you need whole script or not. The rest is just GUI

children may smile; the wise ponder- Dr. Holmes of Hardvard Medical School on an Ether BingeLove Makes The World Go Round?So does five shots of tequila. What's your point?[quote name='Valik' date='Jun 5 2008, 05:13 PM']wraithdu, 24 hours. Said I have a bad attitude, just driving the point home with a ban.[/quote]This is classic. :)
Link to comment
Share on other sites

  • Moderators

If $nCurVar <> $nLastVar And $nCurVar > 0 And $nCurVar <= 1500 Then

That line and the loop after is probably the culprit.

You are probably in that loop (assuming of course because there isn't a working example) every time you press the button you require action on.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

If $nCurVar <> $nLastVar And $nCurVar > 0 And $nCurVar <= 1500 Then

That line and the loop after is probably the culprit.

You are probably in that loop (assuming of course because there isn't a working example) every time you press the button you require action on.

So seeing as how I wish to not allow anyone to ever be able to enter a value over 1500 in that input box, should I take that command line off to stop the loop or should I use OnEvent for my other commands so it pauses the loop to perform that action and then goes back to the loop. Or would this loop not even be necessary?

BTW, Thanks for pointing that out for me, the 'newbie' title fits me very well :)

children may smile; the wise ponder- Dr. Holmes of Hardvard Medical School on an Ether BingeLove Makes The World Go Round?So does five shots of tequila. What's your point?[quote name='Valik' date='Jun 5 2008, 05:13 PM']wraithdu, 24 hours. Said I have a bad attitude, just driving the point home with a ban.[/quote]This is classic. :)
Link to comment
Share on other sites

  • Moderators

So seeing as how I wish to not allow anyone to ever be able to enter a value over 1500 in that input box, should I take that command line off to stop the loop or should I use OnEvent for my other commands so it pauses the loop to perform that action and then goes back to the loop. Or would this loop not even be necessary?

BTW, Thanks for pointing that out for me, the 'newbie' title fits me very well :)

Well I would just make it a conditional action.

If user does this And count < 1500 Then do loop

The way I'm reading your code (mind you I don't really have a clue what the values mean), but it's seems it could "Always" be true, which means it's "Always" in a loop.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Ah, thanks. I don't understand how to really change much of that to make it true but not in a loop, so I moved the coding around to fit my needs..

Global $nCurVar, $nLastVar = ""

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $TreeView1 
        Case $msg = $Save
    $Answer1 = GUICtrlRead($InputJN)
    $Answer2 = GUICtrlRead($InputJT)
    $Answer3 = GUICtrlRead($InputSA)
    $Answer4 = GUICtrlRead($InputF)
    $Answer5 = GUICtrlRead($InputWO)
    $Answer6 = GUICtrlRead($InputWP)
    $Answer7 = GUICtrlRead($InputNOP)
            GUICtrlSetData($JN4, $Answer1)
            GUICtrlSetData($JT4, $Answer2)
            GUICtrlSetData($SA4, $Answer3)
            GUICtrlSetData($F4, $Answer4)
            GUICtrlSetData($WON4, $Answer5)
            GUICtrlSetData($WPN4, $Answer6)
            GUICtrlSetData($NOP4, $Answer7)
        EndSwitch
    $nCurVar = Int(GUICtrlRead($InputNOP))
    If $nCurVar <> $nLastVar And $nCurVar > 0 And $nCurVar <= 1500 Then
        _GUICtrlComboBox_ResetContent($PNC1)
        For $i=1 To $nCurVar
            _GUICtrlComboBox_AddString($PNC1, $i)
        Next
        $nLastVar = $nCurVar
    ElseIf $nCurVar > 1500 Then
        MsgBox(0, "Error", "You must enter a number between 1 and 1500.")
        GUICtrlSetData($InputNOP, "")
    EndIf
WEnd

I had Getmsg() twice, taking one out and keeping the other commands in Switch seems to help, (a little birdy gave me a push :))

Thank you very much, though. I will eventually have to change this loop at one point in a time or another, but I'll keep working with the program to brush up on more coding knowledge in hopes that I will eventually be able to find another way to put it [as I did not write the first loop myself, but it was given to me as an example on how to perform the action I wished]

Kudos!

children may smile; the wise ponder- Dr. Holmes of Hardvard Medical School on an Ether BingeLove Makes The World Go Round?So does five shots of tequila. What's your point?[quote name='Valik' date='Jun 5 2008, 05:13 PM']wraithdu, 24 hours. Said I have a bad attitude, just driving the point home with a ban.[/quote]This is classic. :)
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...