Sign in to follow this  
Followers 0
javip

is there a better way than CASE select for Combo selection?

14 posts in this topic

so my script was made to load drivers based on a selection from a combo box. i've created a VERY robust system to load drivers when imaging with wds or ghost using a winPE wim. WDS does not work correctly with injected drivers. so comes into play my script/program that loads from a winPE wim after wds loads. anyone knows WDS is pretty powerful but it does not always have proper drivers once the winPE loads. so my program loads drivers into winPE based on the model / device. so if we get a new model of laptop or desktop and we want to save up that image to wds we find 32bit drivers and we load them into my program.

wds then in turn loads my winPE with my program set to autolaunch and presenting all these options. if winPE contained a generic driver then all is good. if not then we go through my list and usually one of the drivers does work but in case it doesn't we add to my list.

that's just the pre-amble incase anyone asks what i'm doing.

reminder that this has worked flawlessly for the better part of a year. but now with more devices it's getting cumbersome to manually edit my code, then compile, then mount edit and recompile the winPE wim and inject my autoit program into it.

takes a maximum of 5 minutes but when you're constantly testing it gets VERY bad.

 

here's a snippet of the array for the combobox.

Local $aList[300][2] = [["___________", "___________"], _
        ["ASUS", "ASUS"], _
        ["HP Probook 4430s", "HP Probook 4430s"], _
        ["Lenovo S10-3", "Lenovo S10-3"], _
        ["Lenovo x200/x230", "Lenovo x200/x230"], _

so this populates a combo box that lists these entries.

i use a case select to determine which box was selected. very manual editing when i need to add another device.

Func selection()

    $sSel = GUICtrlRead($cb_platform)
    $iIndex = _ArraySearch($aList, $sSel)
    Select
        Case $iIndex = 1 ;~ ASUS
            $driver = (@scriptdir & "\drivers\hp32\Netrtl32.inf")
            $nothing = $option

        Case $iIndex = 2 ;~ HP Probook 4430s
            $driver = (@scriptdir & "\drivers\hp4430\hp86win7.inf")
            $nothing = $option

        Case $iIndex = 3 ;~ Lenovo S10-3
            $driver = (@scriptdir & "\drivers\lenovos103\Netrtl32.inf")
            $nothing = $option

EndFunc

this is the part of the script which i'm trying to revamp. right now my script works very awesome for what we're doing. however i want it more streamlined.

as you can see once a combobox selection is selected, then it goes to that CASE and populates those variables then it kicks down to a function that i have that continues either ghost or wds depending on a selected radio box.

this is what i have now for the array for the combobox.

$drivers_folder=_FileListToArray(@scriptdir & "\drivers\","*",2)
$cb_platform = GUICtrlCreateCombo("",10,40,600,120,-1,-1)

For $i=1 To Ubound($drivers_folder)-1
    GUICtrlSetData($cb_platform,$drivers_folder[$i])
Next

this populates the combox based on the folder i have with each individual device. instead of creating a long winded array.

the problem i have now is i don't know how to make it load the driver within that folder without a case select.

i was thinking maybe something that got the name of the folder selected, then appended a "*.inf" at the end to load. but i'm totally in the dark of how to do this.

if you'd like me to post all my code to help, please let me know.

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

What about this kind of array?

Local $aList[300][3] = _
        ["ASUS", "ASUS", "hp32\Netrtl32.inf"], _
        ["HP Probook 4430s", "HP Probook 4430s", "hp4430\hp86win7.inf"], _
        ["Lenovo S10-3", "Lenovo S10-3", "lenovos103\Netrtl32.inf"]]

...
$driver = @ScriptDir & "\drivers\" & $aList[$iIndex][2]
Edit: Added indents.

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

well the thing is i don't want to use that kind of array. manual editing. the way i want to do it is the new way where it pulls the directory listing. so to add a new driver to my program all i need to do is drop the new device folder into the drivers folder. then when the program is launched the new folder is there in the combobox.

each driver folder is independent and containts only one .inf for that device. so using a *.inf wildcard to load it wouldn't hurt anything.

Edited by pixeldotz

Share this post


Link to post
Share on other sites

If you don't want to have an array, these informations have to be stored somewhere. Maybe in an ini in each driver's folder or in the inf files.

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

How about:

#include <GUIConstantsEx.au3>
#include <array.au3>
$sDir = @scriptdir & "\driver"

$aFolders = _FileListToArray($sDir,"*",2)
_ArrayDelete($aFolders,0)
$string = _ArrayToString($aFolders)
Local $msg
GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered

$combo = GUICtrlCreateCombo("", 10, 10) ; create first item
GUICtrlSetData(-1,  $string) ; add other item snd set a new default

GUISetState()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()

    If $msg = $combo Then
        $Folder = GUICtrlRead($combo)
        $sINFFolder = $sDir & "\" & $Folder
        $aTemp = _FileListToArray( $sINFFolder, "*.inf",1)
        If UBound($aTemp)=2 Then
            ; Get the driver
            ConsoleWrite("your driver=[" & $sINFFolder & "\" & $aTemp[1] & "]" & @CRLF)
        Else
            ConsoleWrite("no driver, or multiple drivers, in=[" & $sINFFolder & "\" & "]" & @CRLF)
        EndIf
        $aTemp = ""
    EndIf

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

that would be fine too since it would require editing only one external file instead of adding everything and recompiling. this would also keep everything nice and in alphabetical order.

how would i go about doing that? i've never done a split or loaded from an inf file.

Share this post


Link to post
Share on other sites

Take a look at the Ini* functions, it's really simple :)


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

i got it to read using this little code.

$cbox = IniReadSection("device.ini","Config")

For $i = 1 To $cbox[0][0]
        GUICtrlSetData($cb_platform,$cbox[$i][1])
    Next
EndIf

this populates the combobox beautifully. now i'm stuck on the case part. i can do another IniReadSection into another array but how would that work to call my functions? or rather how would that work at all. i'm stumped.

Share this post


Link to post
Share on other sites

You can populate an array according to your ini file :

[drivers]
name1=ASUS
displayname1=ASUS
path1=hp32\Netrtl32.inf

name2=HP Probook 4430s
displayname2=HP Probook 4430s
path2=hp4430\hp86win7.inf
There is for sure a better structure way for the ini, but the idea is here.

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

If you had a section ([section]) for each driver folder, then you could key off the combobox selection to drive the INI reading as well.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

that displays the name and the path in the 'path' thing.

what i was thinking of was something like this.

[device]

name1=ASUS
name2=HP Probook 4430s

[drivers]

path1=(@scriptdir & "AsusNetrtl32.inf")

path2=(@scriptdir & "hp4430hp86win7.inf)

so when i select ASUS i want it to also select path1 and if i select HP i want it to select path2 etc.

then put that as a variable in

            $driver = WHATEVER WAS SELECTED
            $nothing = $option

im totally stumped on this second part.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

less logic if it looked like this...loop through IniReadSectionNames:

[Case1]

name=ASUS
path=(@scriptdir & "AsusNetrtl32.inf")

 

[Case2]

name=HP Probook 4430s

path=(@scriptdir & "hp4430hp86win7.inf)

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

try this...not doing any action, just populating data, for now:

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <array.au3>
$sDir = @scriptdir & "\driver"

$aFolders = _FileListToArray($sDir,"*",2)
_ArrayDelete($aFolders,0)
$string = _ArrayToString($aFolders)
Local $msg
$gui = GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered

$combo = GUICtrlCreateCombo("", 10, 10) ; create first item
GUICtrlSetData(-1,  $string) ; add other item snd set a new default

$aPos = WinGetPos($gui)

Global $button = GUICtrlCreateButton("Start",10,$aPos[3]-80, 50, 40,$BS_DEFPUSHBUTTON)
GUICtrlSetState($button,$GUI_DISABLE)
GUISetState()
$aDrivers=""
$driver = ""
; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()

    Select
        Case $msg = $combo
            $Folder = GUICtrlRead($combo)
            $sINFFolder = $sDir & "\" & $Folder
            $aTemp = _FileListToArray( $sINFFolder, "*.inf",1)
            If UBound($aTemp)=2 Then
                ; Get the driver
                ConsoleWrite("your driver=[" & $sINFFolder & "\" & $aTemp[1] & "]" & @CRLF)
                $aDrivers = CreateDriverControls($aDrivers, $sINFFolder & "\" & $aTemp[1])
            Else
                ConsoleWrite("no driver, or multiple drivers, in=[" & $sINFFolder & "\" & "]" & @CRLF)
            EndIf
        Case $msg = $button
            ConsoleWrite("Do something with driver=[" & $driver & "]." & @CRLF)

        Case _ArraySearch($aDrivers,$msg,0,0,0,0,1,0)>0
            $driver=$aDrivers[_ArraySearch($aDrivers,$msg,0,0,0,0,1,0)][1]
            ConsoleWrite("changed radio selection to=[" & $driver & "]." & @CRLF)
            If Not BitAND(GUICtrlGetState($button),$GUI_ENABLE) Then GUICtrlSetState($button,$GUI_ENABLE)
    EndSelect

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func CreateDriverControls ($aDrivers, $sINIFile)
    If BitAND(GUICtrlGetState($button),$GUI_ENABLE) Then GUICtrlSetState($button,$GUI_DISABLE)
    For $i = 0 To UBound($aDrivers) - 1
        For $j = 0 To UBound($aDrivers,2) - 1
            GUICtrlDelete($aDrivers[$i][$j])
        Next
    Next
    $aTemp              = IniReadSection($sINIFile, "device")
    $aTemp2             = IniReadSection($sINIFile, "drivers")
    $iStart             = 40
    $iControlHeight     = 20
    $iControlSpacing    = 10
    For $i = 1 To UBound($aTemp)-1
        $aTemp[$i][0] = GUICtrlCreateRadio($aTemp[$i][1], $iControlSpacing,$iStart+($iControlSpacing*$i)+($iControlHeight*$i), 100 )
        $aTemp2[$i][1] = GUICtrlCreateEdit($aTemp2[$i][1], 100+$iControlSpacing,$iStart+($iControlSpacing*$i)+($iControlHeight*$i), 250 )
    Next
    Return $aTemp
EndFunc
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

 

try this...not doing any action, just populating data, for now:

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <array.au3>
$sDir = @scriptdir & "\driver"

$aFolders = _FileListToArray($sDir,"*",2)
_ArrayDelete($aFolders,0)
$string = _ArrayToString($aFolders)
Local $msg
$gui = GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered

$combo = GUICtrlCreateCombo("", 10, 10) ; create first item
GUICtrlSetData(-1,  $string) ; add other item snd set a new default

$aPos = WinGetPos($gui)

Global $button = GUICtrlCreateButton("Start",10,$aPos[3]-80, 50, 40,$BS_DEFPUSHBUTTON)
GUICtrlSetState($button,$GUI_DISABLE)
GUISetState()
$aDrivers=""
$driver = ""
; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()

    Select
        Case $msg = $combo
            $Folder = GUICtrlRead($combo)
            $sINFFolder = $sDir & "\" & $Folder
            $aTemp = _FileListToArray( $sINFFolder, "*.inf",1)
            If UBound($aTemp)=2 Then
                ; Get the driver
                ConsoleWrite("your driver=[" & $sINFFolder & "\" & $aTemp[1] & "]" & @CRLF)
                $aDrivers = CreateDriverControls($aDrivers, $sINFFolder & "\" & $aTemp[1])
            Else
                ConsoleWrite("no driver, or multiple drivers, in=[" & $sINFFolder & "\" & "]" & @CRLF)
            EndIf
        Case $msg = $button
            ConsoleWrite("Do something with driver=[" & $driver & "]." & @CRLF)

        Case _ArraySearch($aDrivers,$msg,0,0,0,0,1,0)>0
            $driver=$aDrivers[_ArraySearch($aDrivers,$msg,0,0,0,0,1,0)][1]
            ConsoleWrite("changed radio selection to=[" & $driver & "]." & @CRLF)
            If Not BitAND(GUICtrlGetState($button),$GUI_ENABLE) Then GUICtrlSetState($button,$GUI_ENABLE)
    EndSelect

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func CreateDriverControls ($aDrivers, $sINIFile)
    If BitAND(GUICtrlGetState($button),$GUI_ENABLE) Then GUICtrlSetState($button,$GUI_DISABLE)
    For $i = 0 To UBound($aDrivers) - 1
        For $j = 0 To UBound($aDrivers,2) - 1
            GUICtrlDelete($aDrivers[$i][$j])
        Next
    Next
    $aTemp              = IniReadSection($sINIFile, "device")
    $aTemp2             = IniReadSection($sINIFile, "drivers")
    $iStart             = 40
    $iControlHeight     = 20
    $iControlSpacing    = 10
    For $i = 1 To UBound($aTemp)-1
        $aTemp[$i][0] = GUICtrlCreateRadio($aTemp[$i][1], $iControlSpacing,$iStart+($iControlSpacing*$i)+($iControlHeight*$i), 100 )
        $aTemp2[$i][1] = GUICtrlCreateEdit($aTemp2[$i][1], 100+$iControlSpacing,$iStart+($iControlSpacing*$i)+($iControlHeight*$i), 250 )
    Next
    Return $aTemp
EndFunc

that's way above my head : . i am making progress though. i'm using an ini formatted as

[devices]
ASUS=\\asus.inf
HP=\\hp.inf

0 is the name and 1 is the path, after a selection is made i want "1" to be set into a variable. that is the last problem i'm having. i think i've been looking at the code too long.

 

here's the code that population of combo box.

$cbox = IniReadSection("device.ini","devices")

If @error Then
    MsgBox(4096, "", "Error occurred, probably no INI file.")
Else
For $i = 1 To $cbox[0][0]
        GUICtrlSetData($cb_platform,$cbox[$i][0])
    Next
End

and here's the function.

Func selection()

    $sSel = GUICtrlRead($cb_platform)
    $iIndex = _ArraySearch($cbox, $ssel)
    

            $driver = (@scriptdir & $iIndex)
            MsgBox(1, "",$driver)
        ;    $nothing = $option

EndFunc

using  this function all i get it does is display the "case" of the select item so for install it shows c:asuscase when the first option is selected and c:hpcase1 when the second is selected.

i know i'm close i'm just looking at it to hard i think.

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

  • Similar Content

    • XinYoung
      By XinYoung
      Hello all,
      I've been working on 4 standalone scripts. They each have their own GUI and are now independent .exe's. But instead of having 4 separate icons on my computer, is it possible to put them all together into one .exe?
      What I want is one interface with tabs. Each script's GUI would be on their own respective tab. Is this possible?
      The different scripts don't need to communicate with one another. I just want them all in one .exe.
      I can't find this anywhere... Any help would be greatly appreciated. Thank you!
    • kawliga751
      By kawliga751
      I have a workplace GUI that has a search field function that pulls up customer records to allow changes. I am attempting to 1)LOGIN 2)Enter Search field, enter a number and then {ENTER} 3)change specific field once customer record loads. I have very limited experience in GUI manipulation but I am able to login using the below:
      #include <IE.au3> Const $navOpenInNewTab = 0x0800 Dim $oIE = _IECreate('http://asag.xxxxxxx.com/ASAG/index.htm') Call ("RacksheetSignIn") Func RacksheetSignIn () Local $username = _IEGetObjByName ($oIE,"uname") Local $password = _IEGetObjByName ($oIE,"pword") $oIE.Navigate2('http://asag.xxxxxxx.com/apps/RackSheets/LogInSAG/login.asp',2048) _IEFormElementSetValue ($username, "xxxxxxx") _IEFormElementSetValue ($password, "xxxxxxx") Send('{Enter}') EndFunc However I can't seem to use the _IEGetObjByName or Mouseclick to focus on the search field to allow me to enter my search criteria. When I "inspect element" in the Search field I get the attached:
       
      Any help would be MUCH appreciated
       
       
       

    • Jibberish
      By Jibberish
      I am having difficulties getting updated results from GUICtrlCreateInput. I wrote a small script to demonstrate what I am trying to do.
      This script reads a text file into an array and displays the Name and Number from the text file.
      The user can check a name and change the number, and the results are displayed in _ArrayDisplay.
      Only the Checked names are displayed in their original position. This is necessary for future
      plumbing.
      The problem with this script is the original number is returned, not the changed number. I cannot
      figure out how to get the updated number to be displayed.
      ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; This script reads a text file into an array and displays the Name and Number from the text file. ; The user can check a name and change the number, and the results are displayed in _ArrayDisplay. ; Only the Checked names are displayed in their original position. This is necessary for future ; plumbing. ; ; The problem with this script is the original number is returned, not the changed number. I cannot ; figure out how to get the updated number to be displayed. ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #include-once #include <MsgBoxConstants.au3> #include <array.au3> #include <Date.au3> #include <WinAPIFiles.au3> #include <AutoItConstants.au3> #include <Misc.au3> #include <File.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Local $iMax = 6 ;Default number of Videos - 1 for the array counter Dim $aTextFile[$iMax][2] ; [start with 5 entries][Name, Number] Don't get confused! [Row][Column] Local $i = 0 Local $iLeft = 30 Local $iTop = 30 Local $sName Local $sNumber Local $aArray Local $iMaxCol = 5 Local $iRow = 0 Local $iCol = 0 Local $aNumberCount[$iMaxCol][2] $aArray1 = ReadFile() $aNamesNumbers = DisplayNames($aArray1) _ArrayDisplay($aNamesNumbers) ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; ReadFile() places the contents of the NameNumber.txt file in an array ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Func ReadFile() Local $sFileData = @ScriptDir & "\NameNumber.txt" Local $iStrReturn = 0 Local $aArrayFile Local $aTextFile[$iMaxCol][2] Local $aName Local $sCheckBox1 Const $iL = 10 ; Count from Left for GUI so all buttons line up Local $sFill Local $iA = 0, $iN = 0 ; Put the Names into an Array _FileReadToArray($sFileData, $aArrayFile) For $iA = 0 To $aArrayFile[0] ; Step through the array looking for Names If StringInStr($aArrayFile[$iA], "Name:") Then $aName = StringSplit($aArrayFile[$iA],":") $sFill = $aName[2] If UBound($aTextFile) <= $iRow Then ; Resize the array when $iRow is equal to the element count in the array to prevent subscript error ReDim $aTextFile[UBound($aTextFile) + 1][$iMaxCol] EndIf $aTextFile[$iRow][$iCol] = $sFill $iRow += 1 EndIf Next $iCol = 1 $iRow = 0 $sFill = "" For $iA = 1 To $aArrayFile[0] ; Step through the array looking for Numbers If StringInStr($aArrayFile[$iA], "Number:") Then $aName = StringSplit($aArrayFile[$iA],":") $sFill = $aName[2] If UBound($aTextFile) <= $iRow Then ; Resize the array when $iRow is equal to the element count in the array to prevent subscript error ReDim $aTextFile[UBound($aTextFile) + 1][$iMaxCol] EndIf $aTextFile[$iRow][$iCol] = $sFill $iRow += 1 EndIf Next Return $aTextFile EndFunc ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Display the Name and Number ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Func DisplayNames($aArray1) Local $aName[$iMax] Local $aNumbers[$iMax] $iMMCount = UBound($aArray1) $iMMCount -=1 Local $iWidth = 300 Local $iLength = 300;$iMMCount * 30 GUISetFont(12) $hGUI = GUICreate("Edit / Update Number Test", $iWidth, $iLength, -1, -1) GUICtrlCreateLabel(" Name Number",1,5) ;$iTop += 30 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Display Name with a Checkbox. Only Checked Names should be saved. ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For $i = 0 to $iMMCount Step 1 $sNameText = $aArray1[$i][0] $iNameLength = StringLen($sNameText) $aName[$i] = GUICtrlCreateCheckbox($sNameText,$iLeft, $iTop) $iTop += 30 Next ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Display the number from the text file below each name. Allow the user to change the number and display the ; new number. ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $iLeft = 60 GUIStartGroup() $iTop = 28 For $i = 0 to $iMMCount Step 1 $sNumberText = $aArray1[$i][1] $aNumberCount[$i][1] = $sNumberText $aNumberCount[$i][0] = GUICtrlCreateInput($sNumberText,$iLeft, $iTop, 50,18, $GUI_DOCKAUTO) GUICtrlSetPos($aNumberCount[$i][0],200) $iTop += 30 Next ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Read the checked names and (possibly updated) number ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $iMMCount = UBound($aNumberCount) $iMMNewCount = $iMMCount - 1 Local $aGUICheckbox[$iMMCount] Local $aCheckedNameNumber[$iMMCount][2] $iLeft = 30 Local $idCloseGUI = GUICtrlCreateButton("Close",$iLeft, $iTop) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idCloseGUI For $i = 0 To $iMMNewCount Step 1 Switch GUICtrlRead($aName[$i]) Case $GUI_CHECKED $aCheckedNameNumber[$i][0] = $aArray1[$i][0] Case $GUI_UNCHECKED EndSwitch Switch GUICtrlRead($aNumberCount[$i][0]) Case $aCheckedNameNumber[$i][1] = GUICtrlRead($aNumberCount[$i][1]) EndSwitch Next ExitLoop EndSwitch WEnd For $i = 0 to $iMMNewCount step 1 GUICtrlRead($aNumberCount[$i][0]) If $aCheckedNameNumber[$i][0] <> "" Then $aCheckedNameNumber[$i][1] = $aNumberCount[$i][1] EndIf Next GUIDelete($hGUI) Return $aCheckedNameNumber EndFunc This is the text file I am reading. If you want to try this out put the NameNumber.txt file in your script directory. It's attached to the post.
      * This is a dummy file with a Name and Number * The only purpose of this file is to read the updated Number. Name:Taggart Number:916 Name:Mongo Number:90 Name:Hedley Lamarr Number:22 Name:Bart Number:9999 Name:The Waco Kid Number:2244 If I change the number, the original number is displayed at the end, not the updated/modified number. I need the modified number to be displayed.
      Thanks in advance for any assistance!
      Jibberish
      NameNumber.txt
    • FMS
      By FMS
      Hello,
      As I was searching this forum I came along something intresting what was new to me.
      CUI/GUI hybrid.
      Whish sounds very usefull to me to compile it all into 1 script.
      So i was fideling around whit it but couldn't get it to work.
      In the real script (not this simplified version) i got a lot of functions whish i can use whan talking to it by commandline and switches.
      I could not get this to work and hope somebody could give me some pointers on how to make it work.
      Also I was hoping iff somebody could help me whit the /? function?
      (I don't know how to output the help text back to the commandline or the function that can help me do it)
      please advice and thanks in advanced.
      #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Change2CUI=y #include <Process.au3> #include <Array.au3> If $CmdLine[0] = 0 Then If _ProcessGetName(ProcessGetParent(@AutoItPID)) = "cmd.exe" Then ;ConsoleWrite("Program was started in CMD" & @CRLF) If Mod($CmdLine[0], 2) <> 0 Then Exit MsgBox(16, $sTitle, "Invalid number of parameters! has to be a multiple of 2!") If $CmdLine[0] = 0 Then Exit MsgBox(16, $sTitle, "No parameters passed!") For $i = 1 To $CmdLine[0] Step 2 If $CmdLine[$i] = "/switch" Then MsgBox(64, "Passed Parameters", "/switch is " & $CmdLine[$i+1]) If $CmdLine[$i] = "/?" Then MsgBox(64, "Passed Parameters", "/? " ) Next _ArrayDisplay($CmdLine) Else #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 239, 65, 192, 124) $Button1 = GUICtrlCreateButton("Button1", 32, 24, 75, 25) $Button2 = GUICtrlCreateButton("Button2", 120, 24, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 button1() Case $button2 button2() EndSwitch WEnd EndIf EndIf Exit Func button1() MsgBox(16, "title", "button1()!") EndFunc Func button2() MsgBox(16, "title", "button1()!") EndFunc Func ProcessGetParent($i_PID) ;get PID from parent process done by SmOke_N Local $TH32CS_SNAPPROCESS = 0x00000002 Local $a_tool_help = DllCall("Kernel32.dll", "long", "CreateToolhelp32Snapshot", "int", $TH32CS_SNAPPROCESS, "int", 0) If IsArray($a_tool_help) = 0 Or $a_tool_help[0] = -1 Then Return SetError(1, 0, $i_PID) Local $tagPROCESSENTRY32 = _ DllStructCreate( _ "dword dwsize;" & _ "dword cntUsage;" & _ "dword th32ProcessID;" & _ "uint th32DefaultHeapID;" & _ "dword th32ModuleID;" & _ "dword cntThreads;" & _ "dword th32ParentProcessID;" & _ "long pcPriClassBase;" & _ "dword dwFlags;" & _ "char szExeFile[260]" _ ) DllStructSetData($tagPROCESSENTRY32, 1, DllStructGetSize($tagPROCESSENTRY32)) Local $p_PROCESSENTRY32 = DllStructGetPtr($tagPROCESSENTRY32) Local $a_pfirst = DllCall("Kernel32.dll", "int", "Process32First", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32) If IsArray($a_pfirst) = 0 Then Return SetError(2, 0, $i_PID) Local $a_pnext, $i_return = 0 If DllStructGetData($tagPROCESSENTRY32, "th32ProcessID") = $i_PID Then $i_return = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID") DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0]) If $i_return Then Return $i_return Return $i_PID EndIf While @error = 0 $a_pnext = DllCall("Kernel32.dll", "int", "Process32Next", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32) If DllStructGetData($tagPROCESSENTRY32, "th32ProcessID") = $i_PID Then $i_return = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID") If $i_return Then ExitLoop $i_return = $i_PID ExitLoop EndIf WEnd DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0]) Return $i_return EndFunc ;==>ProcessGetParent  
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning
      I'm working on a little project, and I was wondering if there's a way ( sure there is ) to insert data to a ComboBox control everytime the user insert some text in the ComboBox which is not in the ComboBox data. I'll try to explain with an example:
      - Form with some data ( ComboBox is empty );
      - User prompt something in the ComboBox: if what the user prompts is not in the ComboBox values ( at the moment empty ), then insert the value in the ComboBox values, in order to have, next time the user prompts the form, the value that he entered.
      More pratical example:
      - First call of the form, ComboBox empty;
      - I prompt "A" in the ComboBox;
      - Second call, in the ComboBox I should see "A";
      - I prompt "B" in the ComboBox;
      - Third call, I should see "A"
                                                 "B";
      - And so on...
      Everytime the form is called, I re-create it, so I think I can't use _GUICtrlComboBox_AddStrings().
      I tried with
      Global $strCboStrings = "" ; When the user prompt the form, the code below is executed. ; I.E. : User prompt "A", after the if I should have "A"; ; In the second call, If I write "B", I should see "A" ; "B"; ; If I write "A" again, in the combobox values should not be any changes. If Not StringInStr($strCboStrings, GUICtrlRead($cboVoiceCategory)) <> 0 Then $strCboStrings &= $strCboStrings & "|" & GUICtrlRead($cboVoiceCategory) EndIf Any suggestion?
      Thanks