BUNNY3005 Posted August 21, 2018 Share Posted August 21, 2018 Hello, I have to replace random letters with files . can you help me ? Func Keywords() Local $sData For $i = 0 To 99 $asKeyWords[$i] = Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) $sData &= $asKeyWords[$i] & "|" Next GUICtrlSetData($cList, $sData) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($cList, $iCurrIndex) EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 21, 2018 Moderators Share Posted August 21, 2018 BUNNY3005, Do not hijack unrelated threads - particularly when they date back some 13 years! And as this is obviously to do with the auto-complete list question you asked yesterday, why not ask in that thread anyway - then the OP might make more sense to other people. You must have a list of these files - presumably from _FileListToArray - so just use that array in place of the randomly generated one. If not, then from where do you get the list of files? M23 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...
BUNNY3005 Posted August 29, 2018 Author Share Posted August 29, 2018 (edited) I Try to modify your code but i did not get my required output. What I need from it is.........for example, i have to upload files from desktop and search for one file and download it expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <Array.au3> #Include <GuiListBox.au3> #include <WinAPIDlg.au3> Global $hGUI, $cInput, $cList, $sPartialData, $asFile[100] ; Create list full of files" sFile() $hGUI = GUICreate("Example", 200, 400) $cInput = GUICtrlCreateInput("", 5, 5, 190, 20) $cList = GUICtrlCreateList("", 5, 30, 190, 325, BitOR(0x00100000, 0x00200000)) $cButton = GUICtrlCreateButton("Read", 60, 360, 80, 30) $cUP = GUICtrlCreateDummy() $cDOWN = GUICtrlCreateDummy() $cENTER = GUICtrlCreateDummy() GUISetState(@SW_SHOW, $hGUI) ; Set accelerators for Cursor up/down and Enter Dim $AccelKeys[3][2]=[["{UP}", $cUP], ["{DOWN}", $cDOWN], ["{ENTER}", $cENTER]] GUISetAccelerators($AccelKeys) $iCurrIndex = -1 GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cList $sChosen = GUICtrlRead($cList) If $sChosen <> "" Then GUICtrlSetData($cInput, $sChosen) Case $cButton If $sPartialData <> "" Then $sFinal = GUICtrlRead($cInput) If _ArraySearch($asFile, $sFinal) > 0 Then MsgBox(0, "Chosen", $sFinal) EndIf EndIf Case $cUP If $sPartialData <> "" Then $iCurrIndex -= 1 If $iCurrIndex < 0 Then $iCurrIndex = 0 _GUICtrlListBox_SetCurSel($cList, $iCurrIndex) EndIf Case $cDOWN If $sPartialData <> "" Then $iTotal = _GUICtrlListBox_GetCount($cList) $iCurrIndex += 1 If $iCurrIndex > $iTotal - 1 Then $iCurrIndex = $iTotal - 1 _GUICtrlListBox_SetCurSel($cList, $iCurrIndex) EndIf Case $cENTER If $iCurrIndex <> -1 Then $sText = _GUICtrlListBox_GetText($cList, $iCurrIndex) GUICtrlSetData($cInput, $sText) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($cList, $iCurrIndex) EndIf EndSwitch WEnd Func CheckInputText() $sPartialData = "|" ; Start with delimiter so new data always replaces old Local $sInput = GUICtrlRead($cInput) If $sInput <> "" Then For $i = 0 To 99 If StringInStr($asFile[$i], $sInput) <> 0 Then $sPartialData &= $asFile[$i] & "|" Next GUICtrlSetData($cList, $sPartialData) EndIf EndFunc ;==>CheckInputText Func sFile() Local $sData For $i = 0 To 99 $asFile[$i] = _WinAPI_OpenFileDlg('', @WorkingDir, 'AutoIt v3 Scripts (*.au3)|All Files (*.*)', 1, '', '', BitOR($OFN_PATHMUSTEXIST, $OFN_FILEMUSTEXIST, $OFN_HIDEREADONLY, $OFN_ALLOWMULTISELECT, $OFN_EXPLORER)) $sData &= $asFile[$i] & "|" Next GUICtrlSetData($cList, $sData) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($cList, $iCurrIndex) EndFunc ;==>Keywords Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) ; If it was an update message from our input If _WinAPI_HiWord($wParam) = $EN_CHANGE And _WinAPI_LoWord($wParam) = $cInput Then CheckInputText() EndIf EndFunc Edited August 29, 2018 by Melba23 Added code tags Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 29, 2018 Moderators Share Posted August 29, 2018 BUNNY3005, You need to get the desktop files into an array - the code then adds the matching names to the list. This should work: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <Array.au3> #include <GuiListBox.au3> #include <WinAPIDlg.au3> #include <File.au3> Global $hGUI, $cInput, $cList, $sPartialData, $asFile ; Create an array full of files sFile() $hGUI = GUICreate("Example", 200, 400) $cInput = GUICtrlCreateInput("", 5, 5, 190, 20) $cList = GUICtrlCreateList("", 5, 30, 190, 325, BitOR(0x00100000, 0x00200000)) $cButton = GUICtrlCreateButton("Read", 60, 360, 80, 30) $cUP = GUICtrlCreateDummy() $cDOWN = GUICtrlCreateDummy() $cENTER = GUICtrlCreateDummy() GUISetState(@SW_SHOW, $hGUI) ; Set accelerators for Cursor up/down and Enter Dim $AccelKeys[3][2] = [["{UP}", $cUP], ["{DOWN}", $cDOWN], ["{ENTER}", $cENTER]] GUISetAccelerators($AccelKeys) $iCurrIndex = -1 GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cList $sChosen = GUICtrlRead($cList) If $sChosen <> "" Then GUICtrlSetData($cInput, $sChosen) Case $cButton If $sPartialData <> "" Then $sFinal = GUICtrlRead($cInput) If _ArraySearch($asFile, $sFinal) > 0 Then MsgBox(0, "Chosen", $sFinal) EndIf EndIf Case $cUP If $sPartialData <> "" Then $iCurrIndex -= 1 If $iCurrIndex < 0 Then $iCurrIndex = 0 _GUICtrlListBox_SetCurSel($cList, $iCurrIndex) EndIf Case $cDOWN If $sPartialData <> "" Then $iTotal = _GUICtrlListBox_GetCount($cList) $iCurrIndex += 1 If $iCurrIndex > $iTotal - 1 Then $iCurrIndex = $iTotal - 1 _GUICtrlListBox_SetCurSel($cList, $iCurrIndex) EndIf Case $cENTER If $iCurrIndex <> -1 Then $sText = _GUICtrlListBox_GetText($cList, $iCurrIndex) GUICtrlSetData($cInput, $sText) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($cList, $iCurrIndex) EndIf EndSwitch WEnd Func CheckInputText() $sPartialData = "|" ; Start with delimiter so new data always replaces old Local $sInput = GUICtrlRead($cInput) If $sInput <> "" Then For $i = 1 To $asFile[0] If StringInStr($asFile[$i], $sInput) <> 0 Then $sPartialData &= $asFile[$i] & "|" Next GUICtrlSetData($cList, $sPartialData) EndIf EndFunc ;==>CheckInputText Func sFile() ; Get an array of files from the desktop $asFile = _FileListToArray(@DesktopDir, "*", $FLTA_FILES) EndFunc ;==>sFile Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) ; If it was an update message from our input If _WinAPI_HiWord($wParam) = $EN_CHANGE And _WinAPI_LoWord($wParam) = $cInput Then CheckInputText() EndIf EndFunc ;==>_WM_COMMAND M23 BUNNY3005 1 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...
BUNNY3005 Posted August 29, 2018 Author Share Posted August 29, 2018 thank you. Instead of reading the file. I have to download the file. can i do like this? or Is there anyway? $Downloads $DatafromFile = GUICtrlRead($File) $OpenLocation = FileOpenDialog("Open File", @ScriptDir, "Text Files ('*')") FileWrite($OpenLocation, $DatafromFile) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 29, 2018 Moderators Share Posted August 29, 2018 BUNNY3005, The file is already on your desktop (or it would not appear in the list) so why do you need to download it? M23 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...
BUNNY3005 Posted August 29, 2018 Author Share Posted August 29, 2018 I have to give ratings based on number of downloads. If we download more times,that file has more rating. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 29, 2018 Moderators Share Posted August 29, 2018 BUNNY3005, Falsifying download stats is not something we are willing to support - thread locked. M23 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