danusko Posted October 19, 2020 Share Posted October 19, 2020 Hi, i try to figured out how to do something like this. I have list of values e.g. in excel. After i copy it to the clipboard (e.g. list of 4 values) my script will take this 4 values and put each of this value to dynamic variable . After this it will be possible to call each of the variable and take out one of you want to use. E.g. i wil have this values 123 321 111 444 i wll copy all this to clipboard and then i will be able to call the first value with variable(1) and the second with variable(2) or with loop i will call step by step each of those variables. I tried something like this, but i am not so good in arrays thx for any help Opt("WinTitleMatchMode", -2) ; -2 = subStr, nocase AutoItSetOption("SendKeyDelay", 10) Global $ICO[1000] WinActivate("Excel") WinWaitActive("Excel") send("^c") ; upper i copy list of values to clip #include <Array.au3> Local $arr = [] ; NOTE this creates an array of size 1 with an empty string $Pamat = ClipGet() _ArrayAdd($arr, $Pamat) _ArrayAdd($arr, $Pamat) Local $ArrayICO = _FileListToArray($Pamat, "*") For $i = 1 To UBound($ArrayICO) - 1 ConsoleWrite('arr[' & $i & '] == ' & $ArrayICO[$i] & @CRLF) Next MsgBox(0, "vysledok ", $arr[2] ) exit Link to comment Share on other sites More sharing options...
Zedna Posted October 19, 2020 Share Posted October 19, 2020 (edited) Opt("WinTitleMatchMode", -2) ; -2 = subStr, nocase AutoItSetOption("SendKeyDelay", 10) Global $ICO[1000] WinActivate("Excel") WinWaitActive("Excel") send("^c") ; upper i copy list of values to clip #include <Array.au3> Local $arr = [] ; NOTE this creates an array of size 1 with an empty string $values = ClipGet() $values = StringSplit($values,@CRLF,1) For $i = 1 To $values[0] ConsoleWrite('arr[' & $i-1 & '] = ' & $values[$i] & @CRLF) Next MsgBox(0, "vysledok ", $arr[2] ) exit Edited October 19, 2020 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zedna Posted October 19, 2020 Share Posted October 19, 2020 If you have installed Excel then you can use Excel UDF to directly read values from Excel. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
danusko Posted October 19, 2020 Author Share Posted October 19, 2020 This code retur error on line 20. Array variable has incorrect number of subscripts or subscripts dimension range exceeded. I copied only abou 20 values from excel. Link to comment Share on other sites More sharing options...
Zedna Posted October 19, 2020 Share Posted October 19, 2020 Here is fixed your example where is copied array $values to array $arr Local $arr = [] ; NOTE this creates an array of size 1 with an empty string $values = '1' & @CRLF & '2' & @CRLF & '3' ;~ $values = ClipGet() $values = StringSplit($values,@CRLF,1) ReDim $arr[$values[0]] For $i = 1 To $values[0] $arr[$i-1] = $values[$i] ConsoleWrite('arr[' & $i-1 & '] = ' & $arr[$i-1] & @CRLF) Next MsgBox(0, "Result 2", $arr[1] ) output: Quote arr[0] = 1 arr[1] = 2 arr[2] = 3 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zedna Posted October 19, 2020 Share Posted October 19, 2020 Here is simple variant using only/directly array $values: $values = '1' & @CRLF & '2' & @CRLF & '3' ;~ $values = ClipGet() $values = StringSplit($values,@CRLF,1) For $i = 1 To $values[0] ConsoleWrite('values[' & $i & '] = ' & $values[$i] & @CRLF) Next MsgBox(0, "Result 2", $values[2] ) output: Quote values[1] = 1 values[2] = 2 values[3] = 3 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Subz Posted October 19, 2020 Share Posted October 19, 2020 As Zedna mentioned if you use the Excel udf, you could just use _Excel_RangeRead to read cells, columns etc.. into an array, see help file for more info. Link to comment Share on other sites More sharing options...
danusko Posted October 20, 2020 Author Share Posted October 20, 2020 Thank you very much, This is exactly what i needed. This part of code is for me very helpfull. 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