Sign in to follow this  
Followers 0
jbsoccerbrit

vairable loop .ini file

3 posts in this topic

#1 ·  Posted (edited)

I was looking at the file at DO, ContinueLoop, While, ExitLoop commands but not sure at how do something like the below.

Inside a .ini files I have two sections

[section1]

numbers1=12345689

[section2]

numbers2=123456789

What I would like to do is have a gui that displays both the start and end numbers and then another text box where you can set the amount of times the script it calls runs, whilst incrementing the ending digit of both start and end in the .ini file.

Once the count is met it would exit the loop and not run the other script any longer.

Main Script

; read the numbers
$sNumbers1 = IniRead("C:\temp.ini", "section1", "numbers1", "NotFound")
$sNumbers2 = IniRead("C:\temp.ini", "section2", "numbers2", "NotFound")
Send($sNumbers1 & "{TAB}")
Sleep ( 5000 )
Send($sNumbers2 & "{TAB 5}")
; do lots of other stuff here

Loop Gui:

Sections one [DISPLAY NUMBER HERE]

Section two [DISPLAY NUMBER HERE]

Loop for [HOW MANY TIMES HERE]

Button [Tells main script to run for whatever the value of loop for is set to]

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include <IE.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

;Title and GUI display for tool
$CopyPaste = GUICreate("Loop Script", 260, 155, 180, 124)
GUISetState(@SW_SHOW)

; read the numbers
$sNumbers1 = IniRead("C:\temp.ini", "section1", "tin", "NotFound")
$sNumbers2 = IniRead("C:\temp.ini", "section2", "tinsecond", "NotFound")

;Primary Files Label
$Label1 = GUICtrlCreateLabel("Input Values:", 10, 4, 151, 20)
$Label2 = GUICtrlCreateLabel("Start Number", 105, 20, 151, 20)
$Label3 = GUICtrlCreateLabel("End Number", 105, 45, 151, 20)
$Label4 = GUICtrlCreateLabel("How Many Loops", 105, 70, 151, 20)



$someControl =   GUICtrlCreateInput("", 10, 20, 90, 20, 1)

$someControl1 =   GUICtrlCreateInput("", 10, 45, 90, 20, 1)

$someControl2 =   GUICtrlCreateInput("", 10, 70, 90, 20, 1)

;Action Button
$action = GUICtrlCreateButton( "Start Loop", 10, 120, 60, 20, 1)


While 1
    $msg = GUIGetMsg()

        Switch $msg
    Case $GUI_EVENT_CLOSE ;closes when red x is pressed
    Exit


EndSwitch
WEnd

Better example of GUI look.

Edited by jbsoccerbrit

Share this post


Link to post
Share on other sites



That only takes one For/Next loop. Just add a Case to your GuiGetMsg() Switch for when the $action button is clicked. In that case, you read the appropriate Input and then simply do a For/Next for the number of loops you want:

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE ;closes when red x is pressed
            Exit
        Case $action
            $iCnt = Int(GUICtrlRead($someControl2))
            For $n = 1 To $iCnt
                GUICtrlSetData($someControl, Int(GUICtrlRead($someControl)) + 1)
                GUICtrlSetData($someControl1, Int(GUICtrlRead($someControl1)) + 1)
            Next
    EndSwitch
WEnd

:graduated:


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

Maybe this will be better help.

Script 1 (GUI Script) is a GUI window that reads from an INI file, it has a Create Returns text box that I need to insert a numeric into that increases the number in the Starting TIN and Ending TIN boxes. The numbers in the Starting TIN and Ending Tin are used in another script that also reads from the INI file and I want that script to run however many times the value was set in the Create Returns window of the GUI Script.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
Opt("WinWaitDelay",100)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
#include <GUIConstants.au3>
#include <IE.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>



;Title and GUI display for tool
$CopyPaste = GUICreate("Loop Script", 200, 220, 180, 124)
GUISetState(@SW_SHOW)

;text box labels
;Primary Files Label
$Label1 = GUICtrlCreateLabel("Username INI:", 1, 10, 100, 20)
$Label2 = GUICtrlCreateLabel("Starting TIN:", 1, 50, 100, 20)
$Label3 = GUICtrlCreateLabel("Ending TIN:", 1, 90, 100, 20)
$Label4 = GUICtrlCreateLabel("Create Returns:", 1, 130, 100, 20)

;read username from the .ini
$username = IniRead("C:\temp.ini", "section1", "username", "NotFound")
$someControl0 =   GUICtrlCreateInput("", 1, 25, 100, 20, 1)
$readcontrol0 = GUICtrlRead($someControl0)
Send("{tab}" & $username)

;read first tin from the .ini
$sNumbers1 = IniRead("C:\temp.ini", "section2", "tin", "NotFound")
$someControl1 =   GUICtrlCreateInput("", 1, 65, 100, 20, 1)
$readcontrol1 = GUICtrlRead($someControl1)
Send("{tab}" & $sNumbers1)

;read second tin from the .ini
$sNumbers2 = IniRead("C:\temp.ini", "section3", "tinsecond", "NotFound")
$someControl2 =   GUICtrlCreateInput("", 1, 105, 100, 20, 1)
$readcontrol2 = GUICtrlRead($someControl2)
Send("{tab}" & $sNumbers2)

;text box for return count
$someControl3 = GUICtrlCreateInput("", 1, 145, 100, 20, 1)

;Buttons -- 

;refresh button
$refreshbutton = GUICtrlCreateButton("Refresh", 1, 170, 100, 20, 1)

;start return creation
$createreturns = GUICtrlCreateButton("Create", 1, 195, 100, 20, 1)


While 1
    $msg = GUIGetMsg()

        Switch $msg
    Case $GUI_EVENT_CLOSE ;closes when red x is pressed
    Exit

case $refreshbutton
;read username from the .ini
$username = IniRead("C:\temp.ini", "section1", "username", "NotFound")
$someControl0 =   GUICtrlCreateInput("", 1, 25, 100, 20, 1)
Send("{tab 2}" & $username)

;read first tin from the .ini
$sNumbers1 = IniRead("C:\temp.ini", "section2", "tin", "NotFound")
$someControl1 =   GUICtrlCreateInput("", 1, 65, 100, 20, 1)
Send("{tab}" & $sNumbers1)

;read second tin from the .ini
$sNumbers2 = IniRead("C:\temp.ini", "section3", "tinsecond", "NotFound")
$someControl2 =   GUICtrlCreateInput("", 1, 105, 100, 20, 1)
Send("{tab}" & $sNumbers2)


EndSwitch
WEnd

#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

Other Script to be ran based on Create Returns value from GUI script

#region ---Au3Recorder generated code Start ---
Opt("WinWaitDelay",100)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
; read the user name
$sUserName = IniRead("C:\temp.ini", "section1", "username", "NotFound")
; make sure we found one!
If $sUsername <> "NotFound" Then
    ; read the numbers
    $sNumbers1 = IniRead("C:\temp.ini", "section2", "tin", "NotFound")
    $sNumbers2 = IniRead("C:\temp.ini", "section3", "tinsecond", "NotFound")
    ; now put these into the web page
_WinWaitActivate("IPO Online : Individual : " & $sUserName & " - Microsoft Internet Explorer","")
MouseClick("left",31,158,1)
_WinWaitActivate(" -- Web Page Dialog","")
Sleep ( 5000 )
Send($sNumbers1 & "{TAB}")
Sleep ( 5000 )
Send($sNumbers2 & "{TAB 5}")
Sleep ( 5000 )
Send("{enter}")
Sleep ( 5000 )
Send ("{TAB 24}")
Sleep ( 5000 )
Send ("{space}")
Sleep ( 2000 ) 
Send ("{TAB 3}")
Sleep ( 2000 )
Send ("w")
Sleep ( 1000 )
Send ("{TAB}")
Sleep ( 1000 )
Send ("{enter}")
Sleep ( 5000 )
Send ("{SHIFTDOWN}{tab}{SHIFTUP}")
Sleep ( 500 )
Send ("m")
Sleep ( 500 )
Send ("{tab}")
Sleep ( 100 )
Send ("test")
Sleep ( 100 )
Send ("{tab}")
Sleep ( 100 )
Send ("test")
Sleep ( 100 )
Send ("{tab}{tab}")
Sleep ( 100 )
Send ("111111111")
Sleep ( 100 )
Send ("{tab}")
Send ("Job")
Sleep ( 100 )
Send ("{tab}")
Sleep ( 100 )
Send ("street")
Sleep ( 100 )
Send ("{tab}")
Sleep ( 100 )
Send ("30165{tab}")
Sleep ( 2000 )
Send ("{tab}{tab}")
Sleep ( 100 )
Send ("111111111{tab}")
Sleep ( 100 )
Send ("111111111{tab}")
Sleep ( 100 )
Send ("{tab 5}{enter}")
Sleep ( 5000 )
Send ("{tab 31}")
Sleep ( 5000 )
Send ("{enter}")
Sleep ( 2000 )
Send  ("{space}")
Sleep ( 500 )
Send ("{tab}")
Sleep ( 500 )
Send  ("{space}")
Sleep ( 500 )
Send ("{tab}")
Sleep ( 500 )
Send  ("{space}")
Sleep ( 500 )
Send ("{tab}")
Sleep ( 500 )
Send  ("{space}")
Sleep ( 500 )
Send ("{tab}{RIGHT}")
Sleep ( 500 )
Send ("{tab 5}")
Sleep ( 2000 )
Send ("{enter}")
Sleep ( 5000 )
Send ("{RIGHT}")
Sleep ( 500 )
Send ("{tab 3}")
Sleep ( 2000 )
Send ("{enter}")
Sleep ( 2000 )
Send ("{TAB 24}")
Sleep ( 2000 )
Send ("{enter}")
Sleep ( 5000 )
Send ("{TAB 24}")
Sleep ( 5000 )
Send ("{enter}")
Sleep ( 5000 )
Send ("{TAB 31}")
Sleep ( 2000 )
Send ("{enter}")
Sleep ( 2000 )
Send ("{TAB 23}")
Sleep ( 1000 )
Send ("{DOWN}{DOWN}")
Sleep ( 1000 )
Send ("{tab 4}")
Sleep ( 3000 )
Send ("{enter}")
Sleep ( 5000 )
Send ("{tab 27}")
Sleep ( 3000 )
Send ("{enter}")
Sleep ( 3000 )
Send ("{enter}")
Sleep ( 3000 )
Send ("{tab 73}")
Sleep ( 6000 )
Send ("{enter}")
Sleep ( 3000 )
Send ("{tab}")
Sleep ( 500 )
Send ("{enter}")
Sleep ( 3000 )
Else
    ; Some thing else if the username was not found
EndIf

#region --- Internal functions Au3Recorder Start ---
Func _WinWaitActivate($title,$text,$timeout=0)
    WinWait($title,$text,$timeout)
    If Not WinActive($title,$text) Then WinActivate($title,$text)
    WinWaitActive($title,$text,$timeout)
EndFunc
#endregion --- Internal functions Au3Recorder End ---

#endregion --- Au3Recorder generated code End ---

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