dabus Posted December 7, 2005 Share Posted December 7, 2005 (edited) Hi @ all. I would like to create a gui that does a filesearch and put the result into a gui. After that, I want to be able to press a button and get the result for that one to do FileDelete / FileOpen / whatever comes to my mind. Example: The dir contains 4 files. A B C D. The Script generates a gui with 4 controls/buttons. If I press A, I want to get A as output. I thought of Assign to do the magic, but it seems that obviously it does not work. I also thought af Eval, but that does not seem to be right, is it? ; sample code stolen from ... someone - gui is stupid- I know;) AutoItSetOption("TrayIconDebug", 1) AutoItSetOption("TrayIconHide", 0) AutoItSetOption("WinTitleMatchMode", 2) AutoItSetOption("SendKeyDelay", 25) #include <GUIConstants.au3> GUICreate("Test-Gui",300,300) $ExitBtn = GUICtrlCreateButton("",260,260 ,40,40, $BS_ICON) GUICtrlSetImage(-1,"Shell32.dll",27) $X = 20 $Y = 25 $Count = 0 For $i = 0 To 50 $button = GUICtrlCreateButton ($i, $X, $Y) Assign ( "Test"&$i, Eval ( $button )) $label = GUICtrlCreateLabel($button, $X+10, $Y+35,30,14) $X = $X + 40 $Count = $Count + 1 If $Count = 22 Then $Count = 0 $X = 25 $Y = $Y + 67 EndIf Next GUISetState () While 1 $msg = GUIGetMsg() ; If Button4 ist pressed, open a message box If $msg = $Test4 Then MsgBox ( 0, "Dummy", "Test" ) If $msg = $GUI_EVENT_CLOSE Or $Msg = $ExitBtn Then ExitLoop Wend I thought of something like this with fancy grafics expandcollapse popup#include <GUIConstants.au3> #include <GuiListView.au3> ;Generated with Form Designer preview $Form1 = GUICreate("Test", 373, 368, 226, 125) $ListView1 = GUICtrlCreateListView("Name|Type|Date|Time", 16, 80, 345, 225) $Label1 = GUICtrlCreateLabel("Test", 64, 16, 235, 49) $Icon1 = GUICtrlCreateIcon("shell32.dll", 21, 15, 25) $Button1 = GUICtrlCreateButton("Delete", 16, 320, 49, 25) $Button2 = GUICtrlCreateButton("AButton2", 80, 320, 49, 25) $Button3 = GUICtrlCreateButton("AButton3", 144, 320, 49, 25) $Button4 = GUICtrlCreateButton("AButton4", 200, 320, 57, 25) $Button5 = GUICtrlCreateButton("AButton5", 272, 320, 81, 25) $CurrentDir = @TempDir $Search = FileFindFirstFile($CurrentDir &"\*.*") If $Search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf $Counter=0 While 1 $Counter=$Counter+1 $SearchFile = FileFindNextFile($Search) If @error Then ExitLoop If $SearchFile="." Then ContinueLoop If $SearchFile=".." Then ContinueLoop $Time = FileGetTime ( $CurrentDir & "\" &$SearchFile ) $Attrib=FileGetAttrib ( $CurrentDir & "\" & $SearchFile ) If StringInStr($Attrib, "D") Then $Output = $SearchFile &"|"& "" & "|" & $Time[2]&"."&$Time[1]&"."&$Time[0] &"|"&$Time[3]&":"&$Time[4]&":"&$Time[5] Else $a = 0 While 1 $a = $a + 1 $Error = StringInStr($SearchFile, ".", 0, $a) If $Error = 0 Then $Pos = StringInStr($SearchFile, ".", 0, $a - 1) $FileName = StringLeft($SearchFile, $Pos - 1) $Suffix = StringTrimLeft($SearchFile, $Pos) ExitLoop EndIf WEnd $Output = $FileName&"|"&$Suffix& "|" & $Time[2]&"."&$Time[1]&"."&$Time[0] &"|"&$Time[3]&":"&$Time[4]&":"&$Time[5] EndIf GUICtrlCreateListViewItem ( $Output, $ListView1 ) WEnd GUISetState(@SW_SHOW) Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount ($ListView1) ] While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GUI_EVENT_PRIMARYDOWN $pos = GUIGetCursorInfo() If ($pos[4] == $ListView1) Then GUICtrlSetData($Label1, "Current Index Selected: " & _GUICtrlListViewGetCurSel ($ListView1)) EndIf Case $msg = $ListView1 ; sort the list by the column header clicked on _GUICtrlListViewSort($ListView1, $B_DESCENDING, GUICtrlGetState($ListView1)) Case $msg = $Button1 $Item = _GUICtrlListViewGetCurSel ($ListView1) $Output = _GUICtrlListViewGetItemText ($ListView1) $Output=StringSplit ( $Output, "|" ) If $Output[2]="" Then $Delete=DirRemove ( $CurrentDir&"\"&$Output[1], 1 ) Else $Delete=FileDelete ( $CurrentDir&"\"&$Output[1]&"."&$Output[2]) EndIf _GUICtrlListViewDeleteItem ( $ListView1, $Item ) ;~ ConsoleWrite('@@ Debug(61) : $Delete = ' & $Delete & @lf & '>Error code: ' & @error & @lf);### Debug Console ;~ EndIf EndSelect WEnd Exit Where's my fault? Or any other suggestions? Thx. Edited December 7, 2005 by dabus 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