Jump to content

Need help with populating .wim files from a folder into a combo box


Go to solution Solved by orbs,

Recommended Posts

I can't seem to figure out the logic behind injecting data to a combo box. So far I have tried almost any suggestion in this forum, but with no results.

I know its because Im not doing it right, so any help is very much appreciated.

 

Here is my code:

$selectOperatingSystems = GUICtrlCreateCombo ( "", 106, 180, 412, 20, $CBS_DROPDONWLIST )
_GUICtrlComboBox_AddDir ( $selectOperatingSystems, "Z:\images\*.wim" )

Thanks in advance!

Link to comment
Share on other sites

  • Solution

you limit the height of the ComboBox to 20 px. change to something un-limiting, like 1000 or so. it will downsize to fit.

P.S. welcome to AutoIt and to the forum!

Edited by orbs

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

I may have another question. Now that the combo box has been populated with the files from folder, I would like to add a string to each item in the list

Example:

"1. "

"2. "

"3. "

Is that possible?

Thanks again!

Edited by doestergaard
Link to comment
Share on other sites

Is that possible?

 

yes.

does it worth it? i don't believe so. remember that when the user selects a wim file from your list, you will have to undo all strings manipulation you want to do. also your wim files may no longer be sorted alphabetically in the list once you prefix them with numbers.

anyway...

the function you have chosen to use, _GUICtrlComboBox_AddDir , is a UDF - that's User Defined Function. this means that a user wrote it for his/her needs, and later someone saw fit to include it in the AutoIt package. if you want it according to your needs, you will need to modify the function.

in your case, it does not seem too complicated: the function is included in the, well... #include file. find it, copy it to your script, rename it slightly to avoid conflict in function name, then modify the line:

_GUICtrlComboBox_InsertString($hWnd, $sText)

into something like this:

_GUICtrlComboBox_InsertString($hWnd, $i & ". " & $sText)

disclaimer: i did not test this, but that's what i'd do (if forced by torture).

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

@orbs

This code does it in my vbscript file:

FolderPath = "Z:\images"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(FolderPath)
Set colWimFile = objFolder.Files

For Each objWimFile In colWimFile

   Set objOption = Document.CreateElement("OPTION")
   objOption.Value = objFSO.GetBaseName(objWimFile)
   X = X + 1
   objOption.Text = X & "." & " " & objFSO.GetBaseName(objWimFile)
   selectWimFile.Add(objOption)

Next

Any chance that i could use the vbscript to populate it into my combo box?

Thanks

Link to comment
Share on other sites

AutoIt is shipped with a mighty arsenal of functions. using external scripts is needless and prone to issues.

check this out:

_FileListToArray()

this will create an array of files in memory. with this array you can do many thing in the same script: for example, 1) fill a ComboBox with your desired format, and 2) process the response.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

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