Sign in to follow this  
Followers 0
Neoborn

Erase Array and Stop Loop After MSG...

3 posts in this topic

Hello guys,

I have a script I have created that does what I want except for two things:

1. The reset button doesn't work properly when I click it, it deletes and then gives me an error if I post in new numbers and click go.

2. It will keep looping infinitely. I would like it to get to the end of the list and then give a message if go button is clicked again i.e. "You have reached the end of the list!" etc.

Here is the code:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=TheThing.exe
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include <Array.au3>

#Region ### START Koda GUI section ###

$Form1_1 = GUICreate("The Thing", 222, 116, 500, 400)
$Button2 = GUICtrlCreateButton("Go!", 149, 42, 70, 31, 0)
$Button1 = GUICtrlCreateButton("Reset", 149, 4, 70, 31, 0)

$Edit1 = GUICtrlCreateEdit("", 10, 4, 128, 92, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))
$Input1 = GUICtrlCreateInput("", 179, 80, 36, 21)
GUICtrlSetState(-1, $GUI_DISABLE)
$Label1 = GUICtrlCreateLabel("Total:", 147, 83, 31, 17)
$Checkbox1 = GUICtrlCreateCheckbox("Cases", 11, 99, 51, 12)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Opt("WinTitleMatchMode", 2)

Global $j = 1
Dim $avArray[1], $Inp_res2, $Inp_res1, $w

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2
            $Inp_res1 = GUICtrlRead($Edit1, 0);read the contents of the control
            $Inp_res2 = StringStripWS($Inp_res1, 8)
            
            $Mid1 = StringLen($Edit1)
            $Mid2 = StringLen($Inp_res2) 
            
            $l = $Mid2 / 6
            $n = 6
            $o = 1
            $q = 1
            Do
                $p = StringMid($Inp_res2, $o, $n)
                _ArrayInsert($avArray, $q, $p)
                
                $o = $o + $n
                $q = $q + 1
                $l = $l - 1
                
            Until $l = 0
            GUICtrlSetData($Edit1, $Inp_res1)
            
            If GUICtrlRead($Checkbox1) == $GUI_UNCHECKED Then
;~                 _ArrayDisplay($avArray)
                SetIt1();Set the input box / label with the total number of entries.
                DoIt1()
                GetPos()
            Else
                SetIt1();Set the input box / label with the total number of entries.
                DoIt2()                
                GetPos()
            EndIf
            
        Case $Button1
            
            $w = UBound($avArray, 1)-1
            For $t = $w To -1 Step -1
                _ArrayDelete($avArray, $t)
                
            Next
            
            GUICtrlSetData($Edit1, "") 
;~             _ArrayDisplay($avArray)
        Case Else
    EndSwitch
WEnd
Exit

;-----------------------Functions-----------------------;
Func GetPos()
    $w = WinGetPos("The Thing")
    WinMove("The Thing", "", $w[0], $w[1])
EndFunc
;-------------------------------------------------------;
Func SetIt1()
    $i = $Mid2 / 6
    GUICtrlSetData($Input1, $i)
EndFunc   ;==>SetIt1
;-------------------------------------------------------;
Func DoIt1()
    WinWait("Fieldpro - Citrix Presentation Server Client", "")
    If Not WinActive("Fieldpro - Citrix Presentation Server Client", "") Then
        WinActivate("Fieldpro - Citrix Presentation Server Client", "")
    EndIf
    WinWaitActive("Fieldpro - Citrix Presentation Server Client", "")
    Send("!sw")
    Sleep(500)
    Send("{F5}")
    Send("{TAB}")
    Send($avArray[$j])
    Send("{Enter}")
    Send("{Enter}")
    $j = $j + 1
    WinActivate("The Thing")
EndFunc   ;==>DoIt1
;-------------------------------------------------------;
Func DoIt2()
    WinWait("FieldPro Enterprise  V4.17   Metafore  (Fieldpro) - \\Remote", "")
    If Not WinActive("FieldPro Enterprise  V4.17   Metafore  (Fieldpro) - \\Remote", "") Then
        WinActivate("FieldPro Enterprise  V4.17   Metafore  (Fieldpro) - \\Remote", "")
    EndIf
    WinWaitActive("FieldPro Enterprise  V4.17   Metafore  (Fieldpro) - \\Remote", "")
    Send("!sw")
    Sleep(400)
    Send("{F5}")
    Send("d")
    Send("{TAB}")
    Send($avArray[$j])
    Send("{Enter}")
    Send("{Enter}")
    $j = $j + 1
    WinActivate("The Thing")
EndFunc   ;==>DoIt2

Thanks for any help in advance.


~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hello guys,

I have a script I have created that does what I want except for two things:

1. The reset button doesn't work properly when I click it, it deletes and then gives me an error if I post in new numbers and click go.

2. It will keep looping infinitely. I would like it to get to the end of the list and then give a message if go button is clicked again i.e. "You have reached the end of the list!" etc.

Here is the code:

Here is the GUI and basic logic, stripped of all the fluff:

#include <GUIConstants.au3>
#include <Array.au3>

$Form1_1 = GUICreate("The Thing", 222, 116, 500, 400)
$Button2 = GUICtrlCreateButton("Go!", 149, 42, 70, 31, 0)
$Button1 = GUICtrlCreateButton("Reset", 149, 4, 70, 31, 0)
$Edit1 = GUICtrlCreateEdit("", 10, 4, 128, 92, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))
$Input1 = GUICtrlCreateInput("", 179, 80, 36, 21)
GUICtrlSetState(-1, $GUI_DISABLE)
$Label1 = GUICtrlCreateLabel("Total:", 147, 83, 31, 17)
$Checkbox1 = GUICtrlCreateCheckbox("Cases", 11, 99, 51, 12)
GUISetState(@SW_SHOW)

Global $avArray[1], $Inp_res2, $Inp_res1

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2 ; Go
            $Inp_res1 = GUICtrlRead($Edit1, 0);read the contents of the control
            $Inp_res2 = StringStripWS($Inp_res1, 8)
            _ArrayInsert($avArray, 1, $Inp_res2)
            GUICtrlSetData($Edit1, $Inp_res2)
            GUICtrlSetData($Input1, UBound($avArray) - 1)
            If BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) Then
                 _ArrayDisplay($avArray)
            Else
                MsgBox(64, "Checkbox", "Check the box if you want to show the array...") 
            EndIf

        Case $Button1 ; Reset
            Dim $avArray[1]
            GUICtrlSetData($Edit1, "")
            GUICtrlSetData($Input1, UBound($avArray) - 1)
    EndSwitch
WEnd

I know it's missing a lot of your functionality, but the GUI works, including both buttons, with no errors. Now you can see what's different, and put back just the functional parts you need.

Hope that helps.

:whistle:

Edited by PsaltyDS

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

I note that in the do loop if the length is not divisible by 6 you'll be in an infinite loop. Might be better to use $l <= 0. Also both Doit1 and Doit2 start with a WinWait that has no timeout. Since I don't see them activate in this code, did something else activate these windows? If not it will wait for something else to start them.

Cheers.

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