edumanilha Posted February 18, 2020 Share Posted February 18, 2020 (edited) I have this code, and I'm trying to fill the array , with files in a folder to create a list...I know I need to use "_FileListToArray" but I can't put the array into the menu...I know about the fish/net thing, but I'm really going crazy with so many codes...Give me a break please guys! My Project is almost done...Thank you very much! I'm learning a lot here! func mobile() If _Metro_ToggleIsChecked($Togglechoose) Then Local $MenuButtonsArray[4] = ["Comando 1", "Comando 2", "Comando 3","Comando 4"] ; Open the rightclick Menu. See decleration of $MenuButtonsArray above. Local $MenuSelect = _Metro_RightClickMenu($Form1, 100, $MenuButtonsArray) Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array. Case "0" ConsoleWrite("Returned 0 = Button 1 clicked." & @CRLF) Case "1" ConsoleWrite("Returned 1 = Button 2 clicked." & @CRLF) Case "2" ConsoleWrite("Returned 2 = Button 3 clicked." & @CRLF) Case "3" ConsoleWrite("Returned 3 = Button 4 clicked." & @CRLF) EndSwitch Else Local $MenuButtonsArray[1] = ["Root"] ; Open the rightclick Menu. See decleration of $MenuButtonsArray above. Local $MenuSelect = _Metro_RightClickMenu($Form1, 100, $MenuButtonsArray) Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array. Case "0" ConsoleWrite("Returned 0 = Button 1 clicked." & @CRLF) EndSwitch EndIf EndFunc I just need to fill the array with the files names, and store the selected one to call him later...Thanks! Edited February 21, 2020 by edumanilha Link to comment Share on other sites More sharing options...
Subz Posted February 18, 2020 Share Posted February 18, 2020 You can use _FileListToArray or _FileListToArrayRec to create an array then use _ArrayToString (if it's something like a combo box) or use a loop to add the array item to the menu. Local $aFileList = _FileListToArray(@DesktopDir, "*") If @error Then Exit For $i = 1 To $aFileList[0] ConsoleWrite($aFileList[$i] & @CRLF) Next Link to comment Share on other sites More sharing options...
edumanilha Posted February 18, 2020 Author Share Posted February 18, 2020 How can use this, the way the script are right now? Sorry Like I said I'm having headaches trying to do this thing... And now I found a new problem trying to execute the .exes...Probably I'll need to open another topic, my desktop is full with tries...LOL... Link to comment Share on other sites More sharing options...
Subz Posted February 18, 2020 Share Posted February 18, 2020 What do you mean? The following would be a 1d array of all files on your desktop, you just delete the first item which includes the file count and that's it. Local $MenuButtonsArray = _FileListToArray(@DesktopDir, "*") _ArrayDelete($MenuButtonsArray, 0) ;~ Delete the first item (file count). edumanilha 1 Link to comment Share on other sites More sharing options...
edumanilha Posted February 18, 2020 Author Share Posted February 18, 2020 20 minutes ago, Subz said: What do you mean? The following would be a 1d array of all files on your desktop, you just delete the first item which includes the file count and that's it. Local $MenuButtonsArray = _FileListToArray(@DesktopDir, "*") _ArrayDelete($MenuButtonsArray, 0) ;~ Delete the first item (file count). Sorry...That's enought for today....I'm dizzy...KKKK Thanks for your help! I'll try tomorrow! Link to comment Share on other sites More sharing options...
edumanilha Posted February 19, 2020 Author Share Posted February 19, 2020 14 hours ago, Subz said: What do you mean? The following would be a 1d array of all files on your desktop, you just delete the first item which includes the file count and that's it. Local $MenuButtonsArray = _FileListToArray(@DesktopDir, "*") _ArrayDelete($MenuButtonsArray, 0) ;~ Delete the first item (file count). Man.....Thank you very much! It works! Link to comment Share on other sites More sharing options...
edumanilha Posted February 19, 2020 Author Share Posted February 19, 2020 (edited) On 2/18/2020 at 7:20 PM, Subz said: What do you mean? The following would be a 1d array of all files on your desktop, you just delete the first item which includes the file count and that's it. Local $MenuButtonsArray = _FileListToArray(@DesktopDir, "*") _ArrayDelete($MenuButtonsArray, 0) ;~ Delete the first item (file count). This way, file list will fill the array, sort and erase the .txt part! expandcollapse popupfunc mobile() If _Metro_ToggleIsChecked($Togglechoose) Then ;Local $MenuButtonsArray[4] = ["Comando 1", "Comando 2", "Comando 3","Comando 4"] Local $MenuButtonsArray = _FileListToArray(@ScriptDir & "\Dados\Comandos\", "*") _ArrayDelete($MenuButtonsArray, 0) ;~ Delete the first item (file count). _ArraySort($MenuButtonsArray) For $i = 0 To UBound($MenuButtonsArray) - 1 $MenuButtonsArray[$i] = StringRegExpReplace($MenuButtonsArray[$i], '^.*\\|\.[^.]*$', "") Next ; Open the rightclick Menu. See decleration of $MenuButtonsArray above. Local $MenuSelect = _Metro_RightClickMenu($Form1, 200, $MenuButtonsArray) Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array. Case "0" ConsoleWrite("Returned 0 = Button 1 clicked." & @CRLF) Case "1" ConsoleWrite("Returned 1 = Button 2 clicked." & @CRLF) Case "2" ConsoleWrite("Returned 2 = Button 3 clicked." & @CRLF) Case "3" ConsoleWrite("Returned 3 = Button 4 clicked." & @CRLF) EndSwitch Else Local $MenuButtonsArray[1] = ["Root"] ; Open the rightclick Menu. See decleration of $MenuButtonsArray above. Local $MenuSelect = _Metro_RightClickMenu($Form1, 100, $MenuButtonsArray) Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array. Case "0" $CMD = @ScriptDir & "\Dados\putty.exe -ssh -pw password user@" & $Final ;$iPID = Run(@ComSpec & " /c " & $CMD, @WindowsDir, @SW_ENABLE) ;RunWait(@ComSpec & ' /c ' & @ScriptDir & "\Dados\putty.exe -ssh -pw riachuelo root@" & $Final) ;ProcessClose("$iPID") ShellExecute(@ScriptDir & "\Dados\putty.exe","-ssh -pw password user@" & $Final) WinActivate("root@") EndSwitch EndIf EndFunc I realized that I'll have trouble with this part looking like this... Edited February 20, 2020 by edumanilha other topic 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