Faran Posted February 6, 2015 Share Posted February 6, 2015 Hello, i m totaly newbie to Autoit i need some help with this i have a array in text file users.txt something like this profile[1]=user1|password1 profile[2]=user2|password2 profile[3]=user3|password3 profile[4]=user4|password4 profile[5]=user5|password5 i want to import this array to multi select listbox and laterz seprate them and login to a site by them thanks Link to comment Share on other sites More sharing options...
water Posted February 6, 2015 Share Posted February 6, 2015 Welcome to AutoIt and the forum! Function FileReadToArray would be a good start. To split strings try function StringSplit. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 6, 2015 Moderators Share Posted February 6, 2015 Faran,Why do you want to log into "a site" using many different username/password combinations and why are you storing these combinations in a simple text file? 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...
Faran Posted February 6, 2015 Author Share Posted February 6, 2015 something like this #include <file.au3> Dim $aArray If _FileReadToArray("users.txt",$aArray) then MsgBox(0,"Array Output records",$aArray[0]) Else MsgBox(0,"Error","Error from Function") EndIf Exit but isnt only for counting this telling me "7" a nummber of array only Link to comment Share on other sites More sharing options...
Faran Posted February 6, 2015 Author Share Posted February 6, 2015 good question i have many email account thats why i want to save them all to a text file and wiv autoit i want to login to selected Email account which will be display in Listbox i guess but i m not so familar to autoit Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 6, 2015 Moderators Share Posted February 6, 2015 Faran,Fine. 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...
Faran Posted February 7, 2015 Author Share Posted February 7, 2015 so far i have i have got my text file 2d array in Listbox but 2nd issue how will i get text from colum1 and colum2 of selected items #include <File.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 438, 192, 124) $button = GUICtrlCreateButton("Selected item", 10, 325) $List1 = GUICtrlCreateListView("List|List1", 2, 40, 394, 268, BitOR($LBS_MULTIPLESEL,$LBS_MULTICOLUMN,$LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $file = "users.txt" FileOpen($file, 0) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) GUICtrlCreateListViewItem($line,$List1) Next FileClose($file) _GUICtrlListView_SetItemSelected($List1, 1) _GUICtrlListView_SetItemSelected($List1, 2) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $button MsgBox (0,"Selected","Item are" & _GUICtrlListView_GetSelectedIndices($List1,1)) EndSwitch WEnd thanks in advance Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 7, 2015 Moderators Share Posted February 7, 2015 Faran,This should give you an idea of how you might proceed: expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <GuiListView.au3> $file = "users.txt" $Form1 = GUICreate("Form1", 615, 438, 192, 124) $button = GUICtrlCreateButton("Selected item", 10, 325) $List1 = GUICtrlCreateListView("List|List1", 2, 40, 394, 268) GUISetState(@SW_SHOW) ; Read the file into an array $aLines = FileReadToArray($file) ; Loop through the array For $i = 0 To @extended - 1 ; Extract the data $sUser = StringRegExpReplace($aLines[$i], "^.*=(.*)\|.*$", "$1") $sPass = StringRegExpReplace($aLines[$i], "^.*\|(.*)$" , "$1") ; And fill the ListView GUICtrlCreateListViewItem($sUser & "|" & $sPass, $List1) Next While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $button ; Get the selected item $sSelection = Number(_GUICtrlListView_GetSelectedIndices($List1, False)) ; Extract the data from the original array $sUser = StringRegExpReplace($aLines[$sSelection], "^.*=(.*)\|.*$", "$1") $sPass = StringRegExpReplace($aLines[$sSelection], "^.*\|(.*)$" , "$1") ; And here it is MsgBox($MB_SYSTEMMODAL, "Selection", "UserName:" & @TAB & $sUser & @CRLF & "Password: " & @TAB & $sPass) EndSwitch 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...
Faran Posted February 7, 2015 Author Share Posted February 7, 2015 thanks m23 but its not filling the listbox at all Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 7, 2015 Moderators Share Posted February 7, 2015 Faran,I used the same file format as you showed in the OP:profile[1]=user1|password1 profile[2]=user2|password2 profile[3]=user3|password3 profile[4]=user4|password4 profile[5]=user5|password5Is that not how the file reads? If not then what does it look like? 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...
Faran Posted February 7, 2015 Author Share Posted February 7, 2015 M23 its same file but see i have screen shoot there is nothing inside listbox Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 7, 2015 Moderators Share Posted February 7, 2015 Faran,A thought - re-reading the OP makes me think the actual file content looks like this:user1|password1 user2|password2 user3|password3 user4|password4 user5|password5If this is the case then this code should work: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <GuiListView.au3> $file = "users.txt" $Form1 = GUICreate("Form1", 615, 438, 192, 124) $button = GUICtrlCreateButton("Selected item", 10, 325) $List1 = GUICtrlCreateListView("Username|Password", 2, 40, 394, 268) GUISetState(@SW_SHOW) $aLines = FileReadToArray($file) For $i = 0 To @extended - 1 ; Add the already formatted data GUICtrlCreateListViewItem($aLines[$i], $List1) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $button $iSelection = Number(_GUICtrlListView_GetSelectedIndices($List1, False)) ; Split the array line on the "|" $aSplit = StringSplit($aLines[$iSelection], "|") MsgBox($MB_SYSTEMMODAL, "Selection", "UserName:" & @TAB & $aSplit[1] & @CRLF & "Password: " & @TAB & $asplit[2]) EndSwitch WEndIf that still does not work, please post a copy of the file with which you want to work. 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...
Faran Posted February 7, 2015 Author Share Posted February 7, 2015 M23 still same issue used this user1|password1 user2|password2 user3|password3 user4|password4 user5|password5 in file and putted ur new given codes but nothing comes in listbox and when press button its show Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 7, 2015 Moderators Share Posted February 7, 2015 Faran,Is the file in the same folder as the script? If not, use the full path when you declare the $file variable. 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...
Faran Posted February 7, 2015 Author Share Posted February 7, 2015 yes its in same Folder where the script is Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 7, 2015 Moderators Share Posted February 7, 2015 Faran,Then I am at a complete loss - the code works for me or I would not have posted it. >Let us see if we can pin down which part of the script is failing. Try running this:#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <GuiListView.au3> ; Prefill the array Global $aLines[5] = ["user1|password1", "user2|password2", "user3|password3", "user4|password4", "user5|password5"] $Form1 = GUICreate("Form1", 615, 438, 192, 124) $button = GUICtrlCreateButton("Selected item", 10, 325) $List1 = GUICtrlCreateListView("Username|Password", 2, 40, 394, 268) GUISetState(@SW_SHOW) For $i = 0 To 4 ; Add the already formatted data GUICtrlCreateListViewItem($aLines[$i], $List1) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $button $iSelection = Number(_GUICtrlListView_GetSelectedIndices($List1, False)) ; Split the array line on the "|" $aSplit = StringSplit($aLines[$iSelection], "|") MsgBox($MB_SYSTEMMODAL, "Selection", "UserName:" & @TAB & $aSplit[1] & @CRLF & "Password: " & @TAB & $asplit[2]) EndSwitch WEndDoes it work now? 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...
Faran Posted February 8, 2015 Author Share Posted February 8, 2015 hello m23 I used "For $i = 0 To Ubound($aLines) -1" instead of "For $i = 0 To @extended - 1" and its worked now thanks you so much for ur time faran Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 8, 2015 Moderators Share Posted February 8, 2015 Faran,My fault for using the latest beta where @extended holds the number of lines read. Glad you got it working. 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
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