Jump to content
Sign in to follow this  
hayesb0404

Using an Array List for radio button options?

Recommended Posts

hayesb0404

Hi,

I am fairly new to AutoIT, but am having to use it for work. I am working on automating a New Hire active directory account, exchange account, and setting the profile up for use on the PC.

I have a webserver that uses ASP.NET to create a form that HR will use to submit - which creates a flat file (.txt). Since the script is not part of the form submission, I dont want to adjust any verbage in order for the script to run; example - john doe is hired, I don't want to change the script for "John Doe" in order for it to work. I figured I would get a list of files from the Array functions and try adding a GUI for the array list. The GUI will have buttons for each file in the directory (which have been named for each new user). The selection would fill a variable used for the remaining script. Once I have that variable the rest should be fairly easy, but like I mentioned, I am pretty new and not yet at an advanced level. Anyone willing to help me out for that portion of my script?

 

This is all I have so far, which is pretty much the example for _FileListToArray.

  

#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>

NewUser()

Func NewUser()
    Local $aFileList = _FileListToArray($path, "*") ; List all the files and folders in the desktop directory using the default parameters
    If @error = 1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.")
        Exit
    EndIf
    If @error = 4 Then
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.")
        Exit
    EndIf
    _ArrayDisplay($aFileList, "$aFileList") ; Display the results returned by _FileListToArray
EndFunc

Share this post


Link to post
Share on other sites
JLogan3o13

Are you saying that when "John Doe" is hired, you then want to open an Array of all files/folders named John Doe in that directory. Or that when the form is filled out (with John Doe's name somewhere on the form), you want to be able to create all the files/folders and append John Doe's name in some way? Can you please provide an example, step by step, of what you would like to have happen, as your explanation is a bit ambigous?

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
hayesb0404

Absolutely, and sorry for being ambiguous. If more information is needed, please let me know. I bolded the section I am having trouble understanding or knowing where to start.

I have a basic form that HR will complete when a new hire comes in. When the form is submitted, this is what happens on the server side (ASP.NET)

string FirstName = firstname.Text;

string LastName = lastname.Text;

string PCNumber = pcnumber.Text;

string Phone = phone.Text;

string Studio = studio.SelectedItem.ToString();

string Location = location.SelectedItem.ToString();

string filepath = @"C:New Users";

string filename = LastName + FirstName + ".txt";

filepath =

Path.Combine(filepath, filename);

//write to file

System.Text.

StringBuilder sb = new StringBuilder();

sb.AppendLine(

"First Name: " + FirstName);

sb.AppendLine(

"Last Name: " + LastName);

sb.AppendLine(

"PCNumber: " + PCNumber);

sb.AppendLine(

"Phone: " + Phone);

sb.AppendLine(

"Studio: " + Studio);

sb.AppendLine(

"Office Location: " + Location);

File.WriteAllText(filepath, sb.ToString());

 

This creates the text file in a "New Users" directory. A lot of times, we have multiple people hired at the same time, so multiple text files will be created. The users directory will have multiple files. Those files are what will be used to reference things such as Office Location, Studio/Department, Name, PC number. Those fields are listed in the form and the values are saved to the text file. I plan on using FileReadLine to assign the appropiate values throughout the script. Here is a high level view, excuse the syntax for now and look at the idea.

I want those results to create radio buttons in a GUI of some sort. When the item is selected, the txt file is used.

 

The array file list: (I know how to do this part so far)

DoeJohn.txt

SmithBob.txt

FunctionCreateButtonsFromArray() ;this is where I am having a tough time

 

GUI pops up: "Please select user to be created"

 

John Doe was selected

 

$Selection = "C:New UsersDoeJohn.txt"

 FileOpen ($Selection)

$pcname = FileReadLine ($selection, 3)

Func _ADCreateComputer($pcname, $computerOU, $strComputerUser)

(rest of function) ;I should be able to handle the rest...I think...

Share this post


Link to post
Share on other sites
JLogan3o13

Are you thinking something like this?

 

<Started off with a dir with the following "user" files: Doe,John, Jim-Bob,BillyJo, Louis,Jimmy, Nelson,Anna, Smith,James, Smith,Jane, Williams,Barry>

#include <File.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $aArray = _FileListToArray(@DesktopDir & "\Users", "*.txt")

GUICreate("Test", 300, 300)
$top = 10

    For $i = 1 To $aArray[0]
        GUICtrlCreateRadio(StringTrimRight($aArray[$i], 4), 10, $top, 120, 20)
        $top += 30
    Next

GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

GUIDelete()

If you're leaning this way, the problem I see is that you won't have a variable associated with the radiobutton, so figuring out which is clicked will add a layer of complexity (certainly not impossible). Let me know if I'm on the right track or way off.


√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
hayesb0404

I will definitely need to associate a variable with the radio button. This is absolutely on the right track. I appreciate the help! 

Variable used without being declared.:
For $i = 1 To $aArray[0]
For $i = 1 To ^ ERROR
>Exit code: 1    Time: 0.207

#include <Array.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$path = "C:\New Users" ;File location for the submitted form

;;;;;;;;;;;;;;
; Array setup
;;;;;;;;;;;;;;


NewUser()

Func NewUser()
    Local $aArray = _FileListToArray($path, "*") ; List all the files and folders in the desktop directory using the default parameters
    If @error = 1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.")
        Exit
    EndIf
    If @error = 4 Then
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.")
        Exit
    EndIf
 EndFunc

;;;;;;;;;;;;;;
;GUI setup
;;;;;;;;;;;;;;

GUICreate("Test", 300, 300)
$top = 10
 
   For $i = 1 To $aArray[0]
        GUICtrlCreateRadio(StringTrimRight($aArray[$i], 4), 10, $top, 120, 20)
        $top += 30
    Next
 
GUISetState(@SW_SHOW)
 
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
               ExitLoop
        EndSwitch
    WEnd
 
GUIDelete()

Share this post


Link to post
Share on other sites
hayesb0404

Makes sense when you define the $aArray variable as Local in a Func. ;)

Jos.

Thanks, the GUI is working now.... :P

@JLogan : That is exactly what I need, I just need it to place that selection in a variable, as you had already mentioned. Could I incorporate GUISetOnEvent to select an array option?

Edited by hayesb0404

Share this post


Link to post
Share on other sites
JLogan3o13

With the way you're doing it, I don't think you'd be able to use OnEventMode (there is always every possibility that someone will come along and prove me wrong). If you were launching from a button, I would think it would look something like this, but you'll have to play around with it to get exactly where you want to be:

#include <File.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $aArray = _FileListToArray(@DesktopDir & "\Users", "*.txt")

GUICreate("Test", 300, 300)
$top = 10

    For $i = 1 To $aArray[0]
        GUICtrlCreateRadio(StringTrimRight($aArray[$i], 4), 10, $top, 120, 20)
        $top += 30
    Next

$go = GUICtrlCreateButton("Go", 200, 250, 40, 40)

GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $go
                myEvent()
        EndSwitch
    WEnd

GUIDelete()

Func myEvent()
    For $x = 1 To $aArray[0]
        If GUICtrlRead($x, 1) <> "" Then MsgBox(0, GUICtrlRead($x, 1), GUICtrlRead($x))
    Next
EndFunc

√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
hayesb0404

JLogan - Ok, thanks! You've been helpful. i should be able to play with that to make it work as desired.

Share this post


Link to post
Share on other sites
hayesb0404

Thought I would start a new thread, but got directed back here. Trying to do the same thing. need to populate variables from a gui. I'm not understanding the func myEvent. I tried reading through the help file, but I find it hard to put everything together in an adequate amount of time without help. I read about GUICtrlRead but I don't understand how to integrate that with the array. I think if I can get that concept figured out, any other GUI concept should be a lot easier to figure out.

NewUser()

Func NewUser()
    Global $aArray = _FileListToArray($path, "*") ; List all the files and folders in the desktop directory using the default parameters
    If @error = 1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.")
        Exit
    EndIf
    If @error = 4 Then
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.")
        Exit
    EndIf
 EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;============GUI setup============;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

GUICreate("Please select user profile", 300, 300)
$top = 10
 
    For $i = 1 To $aArray[0]
       GUICtrlCreateRadio(StringTrimRight($aArray[$i], 4), 10, $top, 120, 20)
        $top += 30
    Next
 
$next = GUICtrlCreateButton("Next", 200, 250, 40, 40)
 
GUISetState(@SW_SHOW)
 
    While 1
        Switch GUIGetMsg()
           Case $GUI_EVENT_CLOSE
               ExitLoop
         Case $next
                myEvent()
        EndSwitch
    WEnd
 
GUIDelete()
 
Func myEvent()
    For $x = 1 To $aArray[0]
        If GUICtrlRead($x, 1) <> "" Then MsgBox(0, GUICtrlRead($x, 1), GUICtrlRead($x))
    Next
EndFunc

;After clicking the "Next" button, I need an interface to input PC Number value, Username, and Phone Extension value. Those values will be variables stored in the "Creating Variable for Account Creation" section below




$selected = This variable should represent the selected value from "myEvent()"  with the associated text file.(i.e. GUI selection = SmithBob which translates to SmithBob.txt)************************************ Help!






;;;;;;;;;;;;;;;;;;;
;AD Account Setup
;;;;;;;;;;;;;;;;;;;


FileOpen ($selected)


;;============Creating Variables for Account Creation==============;;


;Define UserOU
   If FileReadLine ($selected, 6) = "HoustonHQ" Then
$userou = "OU=Houston,DC=domaintest,DC=local"
   ElseIf FileReadLine ($selected, 5) = "Dallas" Then
$userou = "OU=Dallas,DC=domaintest,DC=local"
   EndIf    
   
;Define Logon Script
   If FileReadLine ($selected, 6) = "HoustonHQ" Then
$loscript = "win95login.bat"
   ElseIf FileReadLine ($selected, 5) = "Dallas" Then
$loscript = "dallaslogin.bat"
   EndIf     
  ;Add all groups

;Define description of profile"
   If FileReadLine ($selected, 5) = "Accounting" Then
$description = "win95 - win95login.bat"
   ElseIf FileReadLine ($selected, 5) = "Dallas" Then
$description = "dallaslogin.bat"
   EndIf
   ;Add all groups
   
;**************************************
$user = $iResultuser ; from GUI input screen ;**************************string needs to be defined from either GUI or form submission*******************************
;**************************************

$fname = FileReadLine ($selected, 1)
$lname = FileReadLine ($selected, 2)
$pcnumber = $iResultpc ; from GUI input screen
$phone = $iResultphone; from GUI input screen

Share this post


Link to post
Share on other sites
hayesb0404

So i tried but it's not where I want it. Can anyone help me?

#include <Array.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <AD.au3>
#include-once


;File location for the submitted forms
$path = "C:\New Users"
$workingdir = "C:\New Users\Working"


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;=========Array setup ===========;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


NewUser()

Func NewUser()
    Global $aArray = _FileListToArray($path, "*") ; List all the files and folders in the desktop directory using the default parameters
    If @error = 1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.")
        Exit
    EndIf
    If @error = 4 Then
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.")
        Exit
    EndIf
 EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;============GUI setup============;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

GUICreate("Please select user profile", 300, 300)
$top = 10
 
    For $i = 1 To $aArray[0]
       $radio = GUICtrlCreateRadio(StringTrimRight($aArray[$i], 4), 10, $top, 120, 20)
        $top += 30
    Next
 
$next = GUICtrlCreateButton("Next", 200, 250, 40, 40)
 
GUISetState(@SW_SHOW)
 
 
For $x = 1 To $aArray[0]
        GUICtrlSetData ($radio, $aArray[$x])
     Next
   While 1
      
    $message = GUIGetMsg()
    
    If $message = $GUI_EVENT_CLOSE Then Set_Exit()
    
    If $message = $next Then
        ; read the selected user in the radio
        $selected = GUICtrlRead( $radio )
        
        $selected = $path & "\" & $selected & ".txt"
        ; call the function with the info
        Userdata()
      EndIf
WEnd


 
Func Userdata()
   GUICreate("User Data", 300, 300)
      $top = 10
      
       $pcInput = GUICtrlCreateInput("", 10, $top, 120, 20)
        $top += 30
       $phoneInput = GUICtrlCreateInput("", 10, $top, 120, 20)
        $top += 30
       $usernameInput = GUICtrlCreateInput("", 10, $top, 120, 20)
        $top += 30
 GUISetState(@SW_SHOW)
$start = GUICtrlCreateButton("Start", 200, 250, 40, 40)
      
      If $message = $GUI_EVENT_CLOSE Then Set_Exit()
        
      If $message = $start Then
         $pcnumber = GUICtrlRead ($pcInput)
         $phone = GUICtrlRead ($phoneInput)
                      $user = GUICtrlRead (usernameInput)
         EndIf
      StartProcess()
EndFunc

Func StartProcess()
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;============AD Account Setup=============;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

FileOpen ($selected)


;;============Creating Variables for Account Creation==============;;


;Define UserOU
   If FileReadLine ($selected, 6) = "HoustonHQ" Then
$userou = "OU=Houston,DC=domaintest,DC=local"
   ElseIf FileReadLine ($selected, 5) = "Dallas" Then
$userou = "OU=Dallas,DC=domaintest,DC=local"
   EndIf    
   
;Define Logon Script
   If FileReadLine ($selected, 6) = "HoustonHQ" Then
$loscript = "win95login.bat"
   ElseIf FileReadLine ($selected, 5) = "Dallas" Then
$loscript = "dallaslogin.bat"
   EndIf     
  ;Add all groups

;Define description of profile"
   If FileReadLine ($selected, 5) = "Accounting" Then
$description = "win95 - win95login.bat"
   ElseIf FileReadLine ($selected, 5) = "Dallas" Then
$description = "dallaslogin.bat"
   EndIf
   ;Add all groups
   
;**************************************
$user = $iResultuser ; from GUI input screen ;**************************string needs to be defined from either GUI or form submission*******************************
;**************************************

$fname = FileReadLine ($selected, 1)
$lname = FileReadLine ($selected, 2)
;$pcnumber = $pcnumber = GUICtrlRead ($pcInput)
;$phone = GUICtrlRead ($phoneInput)



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;============Join Domain===============;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


$sDNSDomainParam     = "DC=domaintest,DC=local" ;;e.g. "DC=domaintest,DC=local"
$sHostServerParam    = "test-dc.domaintest.local"    ;;e.g. "servername.domaintest.local" or "domain.local" (access the domain root)
$sConfigurationParam = "CN=Configuration,DC=domaintest,DC=local" ;;e.g. "CN=Configuration,DC=domaintest,DC=local"


_AD_Open("bhayes", "Password#1", "DC=domaintest,DC=local", "test-dc.domaintest.local", "CN=Configuration,DC=domaintest,DC=local")

Global $iValue = _AD_JoinDomain($pcnumber,"bhayes","Password#1")
If $iValue = 1 Then
    MsgBox(64, "Active Directory Functions - Example 1", "Computer '" & $pcnumber & "' successfully joined. Please reboot the computer")
ElseIf @error = 1 Then
    MsgBox(64, "Active Directory Functions - Example 1", "Computer account for '" & $pcnumber & "' does not exist in the domain")
ElseIf @error = 3 Then
    MsgBox(64, "Active Directory Functions - Example 1", "WMI object could not be created. @extended=" & @extended)
ElseIf @error = 4 Then
    MsgBox(64, "Active Directory Functions - Example 1", "Computer '" & $pcnumber & "' is already a member of the domain")
ElseIf @error = 5 Then
    MsgBox(64, "Active Directory Functions - Example 1", "Joining computer '" & $pcnumber & "' to the domain was not successful. @extended=" & @extended)
Else
    MsgBox(64, "Active Directory Functions - Example 1", "Return code '" & @error & "' from Active Directory")
EndIf
_AD_Close()
  
  
  


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;===========Create AD User================;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


_AD_Open("bhayes", "Password#1", "DC=domaintest,DC=local", "test-dc.domaintest.local", "CN=Configuration,DC=domaintest,DC=local")
_AD_CreateUser($userou,$user, $fname & " " & $lname)
$auser = _AD_SamAccountNameToFQDN($user)
;Adding attributes to new account
_AD_ModifyAttribute($auser, "givenName", $fname)
_AD_ModifyAttribute($auser, "sn", $lname)
_AD_ModifyAttribute($auser, "scriptPath", $loscript)
_AD_ModifyAttribute($auser, "displayName", $fname & " " & $lname)
_AD_ModifyAttribute($auser, "description", $description)

;Add User to groups based on studio
If FileReadLine ($selected, 5) = "Accounting" Then
   _AD_AddUserToGroup("Everyone Houston", $auser)
   _AD_AddUserToGroup("FTP Users", $auser)
   _AD_AddUserToGroup("Accounting", $auser)
EndIf
 _AD_Close()


  
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;====End of Part 2 - Prepping for Part 3======;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

FileMove ($selected, $workingdir)

RegWrite ("HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnce","AutoUserSetup","C:\Users\bhayes\Desktop\Scripting\New Hire Automation\AutomationP3.exe")

Shutdown(6)
   EndFunc

Share this post


Link to post
Share on other sites
Melba23

hayesb0404,

I am not at all clear what you want to do. Why do you want to have a radio button for each file in the folder? Why not just pick one file at a time from the existing file list using some form of dialog (like my ChooseFileFolder UDF)? Then deal with that file and when complete return to the list and choose another. Much simpler than trying to create an unknown number of radio buttons. ;)

If that sounds interesting then we can start trying to design something. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
hayesb0404

Sorry for any confusion. I will go over the process of what I want to do. First, I dont have any preference with a radio vs checkbox vs dropdown. I just need a value selected. HR sometimes submits multiple requests, which can create multiple files. I wanted to use a flat file system instead of a database.

Step 1 - HR submits a web form with new employee information. web server takes that form and creates a text file in a new directory ($path) and send new hire request to IT. The text file will get saved with "LastnameFirstname.txt" format

Step 2 - IT will start this program which gives them a GUI. The GUI will display the text files that HR submits through an array. The array will trim the last 4 characters(.txt) for display purposes. IT will select a text file to process to create the new user account.

The code for joining a pc to a domain and creating a new user in ad both work perfectly.

In order for me to have tested the joining of a domain and new user in AD, I had to simulate the variable created from the GUI selections.

The GUI is where I am having my issues. I setup the array, my GUI finds those files and presents a radio for each, but I am having trouble on how I get that selection and continue through the rest of the script. 

Thanks for the help and interest

SmithBob.txt

Share this post


Link to post
Share on other sites
hayesb0404

Actually Melba, if your method is an easier task, we can do that. I just need an GUI to input the data that HR won't know when the account is being created (PC Number, Phone Extension, username).

Share this post


Link to post
Share on other sites
Melba23

hayesb0404,

Fine - I understand the process much better now. I think selecting one file at time is the way to go - I will work up an example using my UDF for you tomorrow. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
hayesb0404

Awesome. I'm always open to finding better processes. Thanks!

Share this post


Link to post
Share on other sites
Melba23

hayesb0404,

here is my take on how you might do things:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

#include <ChooseFileFolder.au3>

; Path of files
$sFilepath = @ScriptDir & "\"

; create array to hold data store controls - set as many as you need
Global $aDataStore[6]

$hGUI = GUICreate("Test", 500, 500)
GUISetBkColor(0xC4C4C4)

; Create labels
GUICtrlCreateLabel("First Name:", 10, 10, 150, 20)
GUICtrlCreateLabel("Last Name:", 10, 40, 150, 20)
GUICtrlCreateLabel("Studio:", 10, 70, 150, 20)
GUICtrlCreateLabel("Office Location:", 10, 100, 150, 20)

; Create labels to hold file data
For $i = 0 To 3
    $aDataStore[$i] = GUICtrlCreateLabel("", 170, 10 + (30 * $i), 150, 20)
    GUICtrlSetBkColor($aDataStore[$i], 0xFFFFFF)
Next

; Create labels for new data
GUICtrlCreateLabel("New Data 1:", 10, 130, 150, 20)
GUICtrlCreateLabel("New Data 2:", 10, 160, 150, 20)

; create inputs to hold new data
For $i = 4 To UBound($aDataStore) - 1
    $aDataStore[$i] = GUICtrlCreateInput("", 170, 10 + (30 * $i), 150, 20)
    GUICtrlSetState($aDataStore[$i], $GUI_DISABLE)
Next

; Create action buttons
$cRead = GUICtrlCreateButton("Read file", 10, 200, 80, 30)
$cSave = GUICtrlCreateButton("Save data", 100, 200, 80, 30)
GUICtrlSetState($cSave, $GUI_DISABLE)

GUISetState()

; Register select on doubleclick
_CFF_RegMsg()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cRead
            ; Get position of GUI
            $aPos = WinGetPos($hGUI)
            ; Create file selection dialog inside GUI - diplay only files and remove extension
            $sFile = _CFF_Choose("Select file", $aPos[2] - 200, $apos[3] - 200, $aPos[0] + 100, $aPos[1] + 100, $sFilepath, "*.txt", 1 + 64, False, $hGUI)
            ; if a file was selected
            If $sFile Then
                ; read file into an array - splitting into elements
                Local $aFileData
                _FileReadToArray($sFile, $aFileData, $FRTA_NOCOUNT + $FRTA_ENTIRESPLIT, ": ")
                ; Add the data
                For $i = 0 To 3
                    GUICtrlSetData($aDataStore[$i], $aFileData[$i][1])
                Next
                ; Enable all data items and Save button
                For $i = 0 To UBound($aDataStore) - 1
                    GUICtrlSetState($aDataStore[$i], $GUI_ENABLE)
                Next
                GUICtrlSetState($cSave, $GUI_ENABLE)
                ; Put focus on first additional input
                GUICtrlSetState($aDataStore[4], $GUI_FOCUS)
            EndIf
        Case $cSave
            ; Check all additional inputs filled
            $bError = False
            For $i = 4 To UBound($aDataStore) - 1
                If GUICtrlRead($aDataStore[$i]) = "" Then
                    $bError = True
                    ExitLoop
                EndIf
            Next
            ; Check for error
            If $bError Then
                MsgBox($MB_SYSTEMMODAL, "Error", "Please fill all fields")
            Else
                ; Collect data from inputs
                $sData = ""
                For $i = 0 To UBound($aDataStore) - 1
                    $sData &= GUICtrlRead($aDataStore[$i]) & @CRLF
                Next
                MsgBox($MB_SYSTEMMODAL, "Data", $sData)
                ; Clear all data and disable inputs and Save button
                For $i = 0 To UBound($aDataStore) - 1
                    GUICtrlSetData($aDataStore[$i], "")
                    GUICtrlSetState($aDataStore[$i], $GUI_DISABLE)
                Next
                GUICtrlSetState($cSave, $GUI_DISABLE)
                ; Focus on Read button
                GUICtrlSetState($cRead, $GUI_FOCUS)
            EndIf
    EndSwitch

WEnd
You can get my UDF from the link in my sig. ;)

Let me know what you think and if it needs any major changes. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
hayesb0404

I really like this, thanks. I think thats a great idea to pull the data from the file. I'm trying to figure out whats happening when I select Save though.

Share this post


Link to post
Share on other sites
Melba23

hayesb0404,

All "Save" does at present is to collect and present the data from all of the lines. You said that you needed to add some further data - here I used inputs, but you could use combos instead. Then when all is ready you press the button and collect all the data to send to the AD creation code you said you had working. :)

Makes sense now? ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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  

×