Jump to content

AutoIT Macros - Running Multiple Macros in a loop


ttleser
 Share

Recommended Posts

All,

I'm writing a script for my company that our helpdesk will have end-users run when they call with problems. The script will obtain some basic information from the system but will have checkboxes to allow it to check other things. For example, one checkbox may be for more network information, driver version, IP, subnet, etc.. Another checkbox will obtain the version of SAP on the system. This way if the issue the user called on was about SAP, the helpdesk would tell the user to put a checkmark in the SAP box. The program would gather the "basic" information, plus stuff about SAP.

I'm looking for a way to be able to run multiple AutoIT macros in a for/next loop. The thought is to have a script read a INI file and run all the AutoIT macros specified and store the outputs in an array to be outputted later. This will allow me to store the INI on a network share and I can customize what data I want to obtain rather than hard coding it into the program and updating the program all the time.

A sample INI would look like this:

[Basic]
ComputerName = @ComputerName
Operating System = @OSVersion
Service Pack = @OSServicePack
IP Address 1 = @IPAddress1
IP Address 2 = @IPAddress2

[Network]
Driver=

The function is this:

Func GatherBasic()
$BasicArray = IniReadSection(@ScriptDir&"\GWPInfo.ini","Basic")
;_ArrayDisplay($BasicArray)
;msgbox(0,"test",$BasicArray[0][0])
ReDim $OutputArray[$BasicArray[0][0]+1][2]
For $d = 1 to $BasicArray[0][0]
;msgbox(0,"test",$d)
$OutputArray[$d][0] = $BasicArray[$d][0]
$OutputArray[$d][1] = $BasicArray[$d][1]
_ArrayDisplay($OutputArray)
Next
EndFunc

This would simply store in the array: ComputerName | @Computername

I know I could simply do this, but that defeats me being able to add more stuff on the fly:

$OutputArray[1][0] = "ComputerName"

$OutputArray[1][1] = @ComputerName (which would be "TEST COMPUTER"

Link to comment
Share on other sites

Try this and see if it does what you need.

#include <Array.au3>
$String = ""
$aArray = GatherBasic()
_ArrayDisplay($aArray)
For $I = 1 To $aArray[0][0]
    $String &= $aArray[$I][0] & " = " & Execute($aArray[$I][1]) & @CRLF
Next
MsgBox("", "Results", $String)

Func GatherBasic()
    $BasicArray = IniReadSection(@ScriptDir & "GWPInfo.ini", "Basic")
    Local $OutputArray[$BasicArray[0][0] + 1][2]
    $OutputArray[0][0] = $BasicArray[0][0]
    For $d = 1 To $BasicArray[0][0]
        ;msgbox(0,"test",$d)
        $OutputArray[$d][0] = $BasicArray[$d][0]
        $OutputArray[$d][1] = $BasicArray[$d][1]
    Next
    Return $OutputArray
EndFunc   ;==>GatherBasic

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I'm interested in seeing what you come up with, might be useful where I work as well.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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...