Jump to content

DanielTyrkiel

Active Members
  • Posts

    52
  • Joined

  • Last visited

DanielTyrkiel's Achievements

Wayfarer

Wayfarer (2/7)

5

Reputation

  1. wow, I must be NOOB LvL 002 if Water is asking me for suggestions
  2. I've added a few lines to the code in first post. I think I have found a quick way to paste a largish table back into excel What do you think?
  3. Hi, I have found that the above synthax returns an array of all cells used in the active sheet in excel. The benefit I'm trying to exploit is that the array is loaded in an instant! My question is: Do you know if there is a parameter that transposes the array? As it is, when checking with _ArrayDisplay(), the result is that columns from excel are as rows in the array. It's not a big issue because I can code around it, but it would make it easier here's my code: #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.8.1 Author: Daniel Tyrkiel Script Function: testing fast array loading #ce ---------------------------------------------------------------------------- ; Script Start #include <Excel.au3> #include <Array.au3> ;setting hotkey to terminate the script in case it runs away in a loop HotKeySet("{ESC}", "Terminate") ;navigate to the chase up log: $sFilePath002 = FileOpenDialog("Choose a spreadsheet", @MyDocumentsDir, "All (*.*)") If $sFilePath002 = "" Then Exit ;exit if "cancel" gets pressed $oExcel = _ExcelBookOpen($sFilePath002) If $oExcel = 0 Then MsgBox(0, "", "failed to attach", 2) ;speak up if you can't attach Exit EndIf ;core of the test: Local $aTest = $oExcel.ActiveSheet.UsedRange.Value Local $fIsArray = IsArray($aTest) If $fIsArray = 1 Then _ArrayDisplay($aTest, "") Else MsgBox(0, "", "$aTest is not an array") EndIf Local $oExcelNew = _ExcelBookNew() ;_ExcelWriteSheetFromArray($oExcelNew, $aTest) ;ClipPut("") ;_ArrayToClip($aTest) $oExcelNew.ActiveSheet.Range("A1:I100").Value = $aTest ;Functions_______________________________________________________________________________________________________________________________________ Func Terminate() Exit 0 EndFunc ;==>Terminate
  4. I think I've sorted it myself again... Here's what I've added: $oInput_1 = _IETagNameGetCollection($oIE1, "input", 6) $oInput_2 = _IETagNameGetCollection($oIE1, "input", 7) MsgBox(0, "", $oInput_1.name & @CRLF & $oInput_2.name & @CRLF & " Prompt 2 Value is: " & $oInput_2.value & @CRLF & " Prompt 1 Value is: " & $oInput_1.value) I've used the console output to see the index numbers for the values nevermind...
  5. Hi, this is probably another one of my newbie easy questions. Here's the image of the table/form I'm trying to control. https://docs.google.com/file/d/0ByUpE9M4BFXIMjc5aU1ubklYZG8/edit The goal is to set values of the two date input boxes and click submit. Here's the code I've got so far to identify the DOM elements: #include <IE.au3> Local $oIE1 = _IECreate("http://lomacorvu/corvucgi/cvhtmsrv.exe?file=/Loma/Purchasing/UK_PO_Receipts_by_Period.qry&showprompts=1") Local $tagINPUT = _IETagNameGetCollection($oIE1, "input") For $oInput In $tagINPUT ConsoleWrite($oInput.name & @CRLF) If $oInput.name = "prompt_1" Then $oInput_1 = $oInput ElseIf $oInput.name = "prompt_2" Then $oInput_2 = $oInput Else ContinueLoop EndIf #cs Switch $oInput.name Case "prompt_1" $oInput_1 = $oInput Case "prompt_2" $oInput_2 = $oInput EndSwitch #ce Next MsgBox(0, "", $oInput_1.name & @CRLF & $oInput_2.name & @CRLF & " Prompt 2 Value is: " & $oInput_2.value & @CRLF & " Prompt 1 Value is: " & $oInput_1.value) My problem is that instead of the first input box named: "prompt_1", I get the submit element named "0" I'm not sure what I'm doing wrong. I'm only starting to learn this. regards Daniel Here's the result after running it: https://docs.google.com/open?id=0ByUpE9M4BFXITGRhVHo1M0pzT1U
  6. Cool, I ran it. Got it now. I didn't realise that this function assigned its own variable on the fly. I've been learning to read the descriptions of functions a bit closer and noticing the fine differences. Many thanks!
  7. I've just read this: The Variable will be created automatically with a Local scope, even when MustDeclareVars is on. So it's declared by the loop statement itself... The statement operates on colections or arrays so it must recognise them somehow. I think I'm getting it. _IETagNameAllGetCollection retrieves a collection of sorts and the variable defined between "for" and "in" is used to pass elements of the colection one by one. Have I got it?
  8. Hi, I'm trying to understand how does this work: ; ******************************************************* ; Example 1 - Open a browser with the basic example, get the collection ; of all elements and display the tagname and innerText of each ; ******************************************************* #include <IE.au3> Local $oIE = _IE_Example("basic") Local $oElements = _IETagNameAllGetCollection($oIE) For $oElement In $oElements MsgBox(0, "Element Info", "Tagname: " & $oElement.tagname & @CR & "innerText: " & $oElement.innerText) Next in the "For" loop there is a variable "$oElement" but I can't see it defined anywhere. I don't understand how it works. I have searched the web, this forum, autoit help file and even the IE UDF, but can't find a clear answer. Sorry if it's an easy one, but I can't use it if I don't understand it. regards Daniel
  9. Sorry, being lazy here. Was looking through threads to find a way to resize columns in my script. I used: $ColA = $oExcel.Columns("A");get the column 1 $ColA.ColumnWidth = 40; set width to 40 for the column 1 but modified it for my excel and multiplied it for columns A thro P and it crashed my script So I'll give it up for now, got more important things to do. When I get a moment, I'll get back to making the sheets look nice thanks Sorry for the trouble Govner Dan
  10. This function didn't work for me. Columns got expanded 7 times more than I set it to and then the script crashed
  11. OK, NOW I have done my homework... After re-reading the Excel.au3 file... There is an option in _ExcelReadCell() that you put in after the column number. If you set it to "3" then it reads the text seen by ze humanz... Sorry to be a dafty...
  12. I've just noticed that when I changed the formatting of the entire column to "general" then the ones that show as a date in the array also show as a date in excel. The others - that show as a long string are presented as a 5 digit string of numbers in excel...
  13. Solved: sorry, didn't read the excel UDF properly regards Hi, have you come across the date format being kept after the cell value had been added to the array? I DON'T have a problem with the formatting not being kept, because I simply can cut the long string and re-organize it, but when it saves "properly" then my formula for splitting the long string produces a mangled string of characters (obviously) Here's what I found after running a test script on my big spreadsheet: https://docs.google.com/open?id=0ByUpE9M4BFXIVTJpclFWWGtPNlU sorry for the trouble. I have looked through the forum but haven't come across this problem (but I have been called blind before ) Here's the test code I whipped up to produce the array: #include <Excel.au3> #include <Array.au3> Global $YearandWeek = "all weeks 2012" Global $oExcel $sFilePath002 = @MyDocumentsDir & "\Delivery Planning" & "\" & $YearandWeek & ".xlsx" ;path to open the chase up spreadsheet $oExcel = _ExcelBookOpen($sFilePath002) Local $j ;check which row number is the last one For $j = 1 To 2000 $sAnotherCellValue = _ExcelReadCell($oExcel, $j, 1) $sAnotherCellValue = StringLen($sAnotherCellValue) If $sAnotherCellValue = 0 Then ExitLoop Next ;by the time it's finished $j is row number one below the last filled one Local $i Local $avArray[1] ;create the array to work with Local $date $avArray[0] = "the list" ;populate the first line For $i = 2 To $j - 1 $date = _ExcelReadCell($oExcel, $i, 12) ;read the date cell _ArrayAdd($avArray, $date) ;add date to the array Next _ArrayDisplay($avArray, "dates")
  14. I'm working with a JAVA software that resides in an IE frame. It assigns class instances dynamically. Here's a piece of script that I wrote today to read all visible class instances and storing it into an array. It works if the second instance is different than the first one, but obviously exits the loop when the second one is the same as the first one. What would be a good logic to exit the class reading loop when all visible classes have been read and the first one has been reached? Here's my code: #include <Array.au3> Local $window = WinActivate("http://loma25.loma.co.uk - Live, UK - Loma UK, AUL Environment - Microsoft Internet Explorer", "") ; activate the window we want to check Local $sControl = ControlGetFocus($window, "") ;read the first class instance visible Local $avArray[1] ;create the array to work with $avArray[0] = $sControl ;populate the first line with the first control in view Local $i ;this is just a counter For $i = 1 To 10 ControlSend($window, "", $sControl, "{TAB}") ;tab to the next control in view $sControl = ControlGetFocus($window, "") ;read the control in focus Local $SearchResult = _ArraySearch($avArray, $sControl) ;check if the control we read is the same as the first one If $SearchResult = 0 Then ExitLoop ;exit the loop if it is the same _ArrayAdd($avArray, $sControl) ;add it to the array Next _ArrayDisplay($avArray, "all instances") ;show the result
×
×
  • Create New...