Rawox Posted June 8, 2009 Share Posted June 8, 2009 Hey,, I have two listviews ($Listau3 and $Listexe) and an inputbox ($SelectedScript). My script lets the user select a folder and the au3 files are loaded in the first listview and the exes are loaded in the other listview. If a user selects a script in one of the listviews the name must be in the inputbox ($SelectedScrupt). The problem is when I click an au3 file and after that I select an executable and then an au3 again it still displays the executable I selected earlier... Is there any way how I can fix this? If GUICtrlRead ( $Listau3 ) > 0 Then $Readau3 = GUICtrlRead ( GUICtrlRead ( $Listau3 ) ) $Readau3r = StringSplit ( $Readau3, "|" ) GUICtrlSetData ( $SelectedScript, $Readau3r[1] ) EndIf If GUICtrlRead ( $Listexe ) > 0 Then $Readexe = GUICtrlRead ( GUICtrlRead ( $Listexe ) ) $Readexer = StringSplit ( $Readexe, "|" ) GUICtrlSetData ( $SelectedScript, $Readexer[1] ) EndIf Link to comment Share on other sites More sharing options...
Rawox Posted June 9, 2009 Author Share Posted June 9, 2009 Does no-one has the answer? I already tried everything Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 9, 2009 Moderators Share Posted June 9, 2009 Rawox,Your problem is that the 2 If sections are both run each time - so once you have selected something in the .exe list, GUICtrlRead ( $Listexe ) > 0 is always true and your script will always set the value of the Input to the value of the .exe list, even if it had just been set to the value of the .au3 list.You need to find out which list was last actioned - ControlGetFocus is one way of doing that. Here is some code to play with - it works perfectly for me:expandcollapse popup#include <GUIConstantsEx.au3> #Include <File.au3> $hGUI = GUICreate("Test", 500, 500) $hLB1 = GUICtrlCreateList("", 10, 10, 200, 200) $hLB2 = GUICtrlCreateList("", 250, 10, 200, 200) $hIB = GUICtrlCreateInput("", 10, 300, 200, 20) GUISetState() $aList = _FileListToArray(@ScriptDir, "*.au3", 1) For $i = 1 To $aList[0] GUICtrlSetData($hLB1, $aList[$i]) Next $aList = _FileListToArray(@ScriptDir, "*.exe", 1) For $i = 1 To $aList[0] GUICtrlSetData($hLB2, $aList[$i]) Next While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch If ControlGetFocus($hGUI) = "ListBox1" Then $sRead_LB = GUICtrlRead($hLB1) GUICtrlSetData($hIB, $sRead_LB) ElseIf ControlGetFocus($hGUI) = "ListBox2" Then $sRead_LB = GUICtrlRead($hLB2) GUICtrlSetData($hIB, $sRead_LB) EndIf WEndM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now