Jump to content

All Activity

This stream auto-updates

  1. Today
  2. Alright...I've got this thing working. Final code is here in case anyone wants to use it. The functions variables still reference a CSV but they are just a relic from when they did work off a CSV. Now everything is based off a TXT. Func WriteDataToWorkbook($sSheetName, $aInput, $sFormat = "Excel") Local $iMatch Switch $oWorkbook.Sheets(1).Name Case "Sheet1" ;There is only one sheet...rename the existing sheet $oWorkbook.Sheets(1).Name = $sSheetName Case Else ;The first sheet has already been renamed...add a new sheet to the workbook (if it doesn't already exist). Local $aSheets = _Excel_SheetList($oWorkbook) ;_ArrayDisplay($aSheets) $iMatch = _ArraySearch($aSheets, $sSheetName, 0, 0, 0, 0, 1, 0) Switch $iMatch Case -1 ;The sheet doesn't exist...add it. _Excel_SheetAdd($oWorkbook, -1, False, 1, $sSheetName) Case Else ;The sheet already exists...overwrite it's contents EndSwitch EndSwitch ;Write data to the range. Switch $sFormat Case "CSV" Local $sTempCSV = WriteDataToWorkbookViaCSV($aInput) Local $oSOURCEBook = _Excel_BookOpenText($oExcel, $sTempCSV, Default, $xlDelimited, Default, Default, "|") Local $oSOURCESheet = $oSOURCEBook.ActiveSheet Local $oSOURERange = $oSOURCESheet.Usedrange ;There is only ever going to be one sheet in this workbook. Otherwise should probably not use the ActiveSheet method. Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "" Local $aPathSplit = _PathSplit($sTempCSV, $sDrive, $sDir, $sFileName, $sExtension) _Excel_RangeCopyPaste($oSOURCESheet, $oSOURERange, $oWorkbook.Sheets($sSheetName).Range("A1"), False, $xlPasteValues) _Excel_BookClose($oSOURCEBook, False) ;Close the source file FileDelete($sTempCSV) Case Else _Excel_RangeWrite($oWorkbook, $sSheetName, $aInput, Default, True) EndSwitch ;MsgBox(0,0,0) EndFunc ;==>WriteDataToWorkbook Func WriteDataToWorkbookViaCSV($aInput) Local $sLineToWrite Local $sTempFile = _TempFile(Default, "", ".txt") ConsoleWrite($sTempFile & @CRLF) Local $hFileOpen = FileOpen($sTempFile, $FO_OVERWRITE) Local $sTempCSV For $i = 0 To UBound($aInput) - 1 $sLineToWrite = _ArrayToString($aInput, '|', $i, $i) & @CRLF ;MsgBox(0,"Line To Write",$sLineToWrite) FileWrite($hFileOpen, $sLineToWrite) ;ConsoleWrite("------------" & @CRLF & $sTempCSV & @CRLF & "------------" & @CRLF) ;MsgBox(0,0,0) Next Return $sTempFile EndFunc ;==>WriteDataToWorkbookViaCSV Now that I have a workaround functioning, I'm curious why the _Excel_RangeWrite didn't actually work as I was just trying to put an AutoIt Array to an Excel range. I've used this function in the past and it has been a pretty reliable (even with the strong-arming the last argument). Overall, I've been very happy with your Excel UDF, Water. It's nice that I can use the Excel COM objects I'm familiar with while having the extra power of AutoIt to more efficiently manipulate large datasets. It has really helped me really expand the capabilities of the code that I write while still being efficient and to run tasks with the Windows Task Scheduler on a computer solely running your functions multiple times a day. For someone that is a structural engineer by trade and just a hobby coder, it's been nice that I didn't really need to learn anything significantly new. It's always been "why learn something new (like Python) when what I know is already efficient?" Once again, thanks for your effort with this UDF and all the support you have given me over these last 6 years that I've been coding.
  3. ;----------------------------------------------------------- ; *** SAVE FILE DATA *** ;----------------------------------------------------------- Func PC_Log_A2($SaveLocation, $DataFromUser_1, $Facility, $DataFromUser_3) If StringInStr($DataFromUser_1, ",") Then $DataFromUser_1 = '"' & $DataFromUser_1 & '"' If StringInStr($Facility, ",") Then $Facility = '"' & $Facility & '"' If StringInStr($DataFromUser_3, ",") Then $DataFromUser_3 = '"' & $DataFromUser_3 & '"' Local $sCSV_string = $DataFromUser_1 & ', ' & $Facility & ', ' & $DataFromUser_3 & @CRLF FileWrite($SaveLocation, $sCSV_string) ;~ FileWrite($SaveLocation, $DataFromUser_1) ;~ FileWrite($SaveLocation, ', ') ;~ FileWrite($SaveLocation, $Facility) ;~ FileWrite($SaveLocation, ', ') ;~ FileWrite($SaveLocation, $DataFromUser_3) ;~ FileWrite($SaveLocation, @CRLF) ;~ StartMT_A3() EndFunc ;==>PC_Log_A2 ..yes, there are things that could be written more efficiently. You should read up about for loops and function parameters.
  4. Patch/change the registry or add the "#AutoIt3Wrapper_UseX64 = N" to your template.au3. That way you don't have to remember.
  5. Greetings all. I've got an AutoIT script that "works", but it's not very efficient. This is what I'm trying to do: I've got an Excel spreadsheet with computer names (Column A) and a description of that computer (Column B). I need to add this data (from cells A2 and B2, for example) to another program, using a function. I would like this particular function to repeat, using the next two cells on the spreadsheet (A3 and B3), and so on, until there are no more computer names on the list to add. The way that I have it working at this time is by copying the same functions (under a different name each time), for every line in Excel. (In a nutshell, I have 25 copies of the same functions with minor changes, to add 25 PCs.) This makes the script way longer than it should be and it's a pain, if I have to change something in a particular function, since I have to make the change 25 times... Also, the script adds data from the added PCs to a comma separated text file, so I know which PC was added where. Note: The script starts with a GUI, because when I first started, my thought was to add one PC at a time, using the GUI. (That worked pretty well.) I later decided to get the data directly from Excel, but I left the (modified) GUI in place. Attached is a part of the script. I appreciate any help that you can provide. I've spent at least 10 hours trying to figure this out. Add PC Script.au3
  6. that file attached above has all that I scrapped from @NoNameCode's v0.02. Other than what is in that zip file, I have nothing more
  7. I added IDs to each <input> so it can be done with ID too.
  8. Yesterday
  9. Hi @Gianni You are right, that is indeed an oversight, thanks for telling me The issue has been fixed on the master branch now, but I'll wait a day or two before creating a new release, to verify no more small mistakes appear
  10. Hi @genius257 Just a small oversight: I tried to "build" example.au3 from example.au3p using build.au3 the output file produced contains this little "flaw": If $pObj=0 Then Return $__AOI_E_POINTER "C:\Temp\au3class-master\Example\Example.au3"(30,40) : warning: $__AOI_E_POINTER: possibly used before declaration. If $pObj=0 Then Return $__AOI_E_POINTER ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Temp\au3class-master\Example\Example.au3"(30,40) : error: $__AOI_E_POINTER: undeclared global variable. If $pObj=0 Then Return $__AOI_E_POINTER ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ apart from this the created "object" works correctly.
  11. These wrapper functions, of my boilerplate repository (regarding the au3WebDriver) could be helpful for further tasks you may have ๐Ÿ˜€ . Best regards Sven
  12. Hi @argumentum ๐Ÿ‘‹ , your page do not have any @ids in the DOM available (at least for the /LoginForm/ page. So you have to search for indicators which will give you the correct elements to interact with. In this example page you could use the placeholder attribute for username and password and the name "Login" for the submit button as your selectors. In other words, you can use XPath for the three elements to interact (2x input, 1x button) like this: _Login() Func _Login() Local Const $sUsername = 'argumentum' Local Const $sPassword = 'your-password' Local Const $sUsernameSelector = '//form//input[@placeholder="Enter Username"]' ; or by name: [@name="uname"] Local Const $sPasswordSelector = '//form//input[@placeholder="Enter Password"]' ; or by name: [@name="psw"] Local Const $sSubmitButtonSelector = '//form//button[text()="Login"]' _WD_ElementAction($sSession, _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sUsernameSelector), 'value', $sUsername) _WD_ElementAction($sSession, _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sPasswordSelector), 'value', $sPassword) _WD_ElementAction($sSession, _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sSubmitButtonSelector), 'click') EndFunc I didn't tested it right now, but I am relatively sure, this should work ๐Ÿ˜‡ . How did I came up with the XPath? Okay, I am experienced with locator strategies, but in case you're not: Use Chrome (or Firefox) > right click on your target element > choose "inspect" > you are now in the DevTools ("Elements" tab) > right click on the highlighted DOM element (input or button) > choose Copy from the context menu > Copy XPath > Ctrl+F > paste your generated XPath in the search (optional) > this verifies the match > use this selector in the _WD_FindElement() function. But: This is often not very robust. It's usually better to improve the selector by the usage of a relative XPath (different XPath Axes). I hope this will answer your questions ๐Ÿคž . Best regards Sven
  13. You could insert #AutoIt3Wrapper_UseX64 = N on top of your script.
  14. @argumentumI don't know how you can color the updown in black and also the left part of the Tab control a coloring of the date control can be a good improvement too. I implement a GUISetDarkTheme($hGui) which working the same , no need to use a callback I hope somebody can help.
  15. Olรก, Is there any way to ensure that the "Compile x86 version" option is always checked in the compilation window without having to reinstall AutoIt or SciTE?
  16. I'd like to login to a site. ( https://www.werwer.org/testing/LoginForm/ ). How do I list the IDs or XPaths from HTML source. How do I submit to execute the login. Thanks
  17. Thanks for finding that definition file argumentum. I was basing my trimming based off a colleague's work but I don't really know what all the data means. I do have the array trimming working off what he had deemed to be important. I can see I need to tweak things a little bit more. Thanks for the suggestion. Maybe I could try creating a new pipe delimited text file based on my cleaned up array and then copying that to my file. I think this might be a little cleaner than my current solution putting in all those extra quotes to work as a csv. As you can see, I currently have it set up to make a new tab and delete a tab (pretty clunky but it is what I band-aided together). If I wanted to copy the data instead of the whole tab into a sheet on a different workbook, what's the cleanest way to copy the whole sheet data to an existing sheet. I assume it would be something with _Excel_RangeCopyPaste but I am hung up on what to use for the $vSourceRange. Would it just be easiest to set the range like in VBA with creating a COM range object based off the $oWorkbook object? I'm open to trying a more efficient way. I think it would be something like this: Local $vSourceRange = $oWorkbook.ActiveSheet.Usedrange ;There is only ever going to be one sheet in this workbook. Otherwise should probably not use the ActiveSheet method.
  18. I Will erase EVERYTHING and I Will start again IT has to work, no matter the cost
  19. Clearly it either finding another instance of chromedriver or there's an issue with the version you downloaded.
  20. I've made a transpiler for converting AutoIt-like class syntax into AutoIt code. GIthub: https://github.com/genius257/au3class/ Example for the syntax: #include-once Class Example $property = Null Func __construct($ts = 'now') $this.property = 0 EndFunc Func __destruct() ; Destructor code here. EndFunc Func method() Return "something" EndFunc Get Func dynamic() Return $this.dynamic & $this.property EndFunc Set Func dynamic($value) $this.property += 1 $this.dynamic = $value EndFunc EndClass $oExample = Example() $oExample.dynamic = 12 MsgBox(0, "", $oExample.dynamic) MsgBox(0, "", $oExample.method()) $oExample = Null class properties are defined as variables within the Class structure class methods are defined as function declarations within the Class structure property getters and setters need to have Get or Set in front of their function declaration Getter and setter can access their own underlying property, without triggering the getter or setter for said variable. Version 2 produces more code than version 1, but does not need any other scripts included to work. Version 2 is also faster than version 1, since version 2 creates specific code for looking up class members, instead of relying on AutoItObject_Internal with it's dynamic properties lookup. See the example folder on Github for building and using this: https://github.com/genius257/au3class/tree/master/Example
  21. Helloooo, here I am... again... unfortunately I cannot validate the installation of Chromedriver... I took all the au3 files wd_Core.au3, wd_helper.au3 , wd_cdp.au3 , wd_capabilities.au3 from the WebDriver UDF Json.au3 and BinaryCall.au3 from the JSON UDF WinHttp.au3 and WinHttpConstants.au3 from the WinHttp UDF and put them into the au3 files directory, than I downloaded Chromedriver "chromedriver win64 https://storage.googleapis.com/chrome-for-testing-public/125.0.6422.60/win64/chromedriver-win64.zip" and put it inside the same directory of wd_demo, clicking on wd_demo appear the gui, I select "chrome" from browser and go for "run" it comes a error "check logs", It creates a files called Chrome, reading that file I thought got a wrong webdriver but I cannot see others suitable webdriver for my browser, "Chrome รจ aggiornato Versione 125.0.6422.61 (Build ufficiale) (a 64 bit)" <---- My browser chromedriver win64 https://storage.googleapis.com/chrome-for-testing-public/125.0.6422.60/win64/chromedriver-win64.zip" <---- my webdriver from here https://googlechromelabs.github.io/chrome-for-testing/ Here the logs I found after running wd_demo set on "Chrome" [1716207842.173][INFO]: Starting ChromeDriver 111.0.5563.64 (c710e93d5b63b7095afe8c2c17df34408078439d-refs/branch-heads/5563@{#995}) on port 9515 [1716207842.173][INFO]: Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. [1716207843.944][INFO]: [37d3147aafd38edcab6334fdeb294b9b] COMMAND InitSession { "capabilities": { "alwaysMatch": { "goog:chromeOptions": { "excludeSwitches": [ "enable-automation" ], "w3c": true } } } } [1716207843.955][INFO]: Populating Preferences file: { "alternate_error_pages": { "enabled": false }, "autofill": { "enabled": false }, "browser": { "check_default_browser": false }, "distribution": { "import_bookmarks": false, "import_history": false, "import_search_engine": false, "make_chrome_default_for_user": false, "skip_first_run_ui": true }, "dns_prefetching": { "enabled": false }, "profile": { "content_settings": { "pattern_pairs": { "https://*,*": { "media-stream": { "audio": "Default", "video": "Default" } } } }, "default_content_setting_values": { "geolocation": 1 }, "default_content_settings": { "geolocation": 1, "mouselock": 1, "notifications": 1, "popups": 1, "ppapi-broker": 1 }, "password_manager_enabled": false }, "safebrowsing": { "enabled": false }, "search": { "suggest_enabled": false }, "translate": { "enabled": false } } [1716207843.956][INFO]: Populating Local State file: { "background_mode": { "enabled": false }, "ssl": { "rev_checking": { "enabled": false } } } [1716207843.960][INFO]: Launching chrome: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --allow-pre-commit-input --disable-background-networking --disable-backgrounding-occluded-windows --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-blink-features=ShadowDOMV0 --enable-logging --log-level=0 --no-first-run --no-service-autorun --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\Marco\AppData\Local\Temp\scoped_dir9376_481513447" data:, [1716207844.236][DEBUG]: DevTools HTTP Request: http://localhost:63839/json/version [1716207844.580][DEBUG]: DevTools HTTP Response: { "Browser": "Chrome/125.0.6422.61", "Protocol-Version": "1.3", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36", "V8-Version": "12.5.227.8", "WebKit-Version": "537.36 (@0e32b459e15a72d5ffe73ffa8a7d92c2f278e1ff)", "webSocketDebuggerUrl": "ws://localhost:63839/devtools/browser/02599d6c-198e-45da-bece-b00c78b607f5" } [1716207844.580][INFO]: Failed to connect to Chrome. Attempting to kill it. [1716207844.682][INFO]: [37d3147aafd38edcab6334fdeb294b9b] RESPONSE InitSession ERROR session not created: This version of ChromeDriver only supports Chrome version 111 Current browser version is 125.0.6422.61 with binary path C:\Program Files (x86)\Google\Chrome\Application\chrome.exe [1716207844.683][DEBUG]: Log type 'driver' lost 0 entries on destruction [1716207844.683][DEBUG]: Log type 'browser' lost 0 entries on destruction The line: "RESPONSE InitSession ERROR session not created: This version of ChromeDriver only supports Chrome version 111 Current browser version is 125.0.6422.61 with binary path C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" makes me think I am using an old version of Chromedriver but I am sure to use the new one... advises?
  22. This is most likely not possible, but I will ask - is it possible to insert html content into a page in Chrome using UIAutomation (for example, by setting an h2 tag to a blank about:blank page)?
  23. Please tell me how to disable event focus in _UIA_action? For example command: _UIA_action($oUIElement,"setValue", "test text") activates the window, how to disable it?
  24. Read about the meaning of each entry ( https://transition.fcc.gov/Bureaus/Wireless/Public_Notices/2000/da000046.txt ). That should help you with the cleanup.
  25. Correct...they are pipe delimited. I'm doing a little data manipulation with an AutoIt array (trimming out some fat that isn't relevant to us)...and now I'm trying to get the data into our Caspio app (which requires Excel formatted values, so I'm trying to convert my array to that format. Here's my current workaround (I'm not sure if this will exactly work for you as I may be missing some data) that now works decently: Func WriteDataToWorkbook($sSheetName, $aInput, $sFormat = "Excel") Local $iMatch Switch $oWorkbook.Sheets(1).Name Case "Sheet1" ;There is only one sheet...rename the existing sheet $oWorkbook.Sheets(1).Name = $sSheetName Case Else ;The first sheet has already been renamed...add a new sheet to the workbook (if it doesn't already exist). Local $aSheets = _Excel_SheetList($oWorkbook) ;_ArrayDisplay($aSheets) $iMatch = _ArraySearch($aSheets,$sSheetName,0,0,0,0,1,0) Switch $iMatch Case -1 ;The sheet doesn't exist...add it. _Excel_SheetAdd($oWorkbook, -1, False, 1, $sSheetName) Case Else ;The sheet already exists...overwrite it's contents EndSwitch EndSwitch ;Write data to the range. Switch $sFormat Case "CSV" Local $sTempCSV = WriteDataToWorkbookViaCSV($aInput) Local $oSOURCE = _Excel_BookOpen($oExcel,$sTempCSV,True) Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "" Local $aPathSplit = _PathSplit($sTempCSV, $sDrive, $sDir, $sFileName, $sExtension) _Excel_SheetCopyMove($oSOURCE, Default, $oWorkbook, $sSheetName, False, True) _Excel_SheetDelete ($oWorkbook, $sSheetName) $oWorkbook.Sheets($sFileName).Name = $sSheetName _Excel_BookClose($oSOURCE, False) ;Close the source file FileDelete($sTempCSV) Case Else _Excel_RangeWrite($oWorkbook, $sSheetName, $aInput, Default, True) EndSwitch ;MsgBox(0,0,0) EndFunc ;==>WriteDataToWorkbook Func WriteDataToWorkbookViaCSV($aInput) Local $sLineToWrite Local $sTempFile = _TempFile(Default,"",".csv") ConsoleWrite($sTempFile & @CRLF) Local $hFileOpen = FileOpen($sTempFile, $FO_OVERWRITE) Local $sTempCSV For $i = 0 To UBound($aInput) - 1 $sLineToWrite = '"' & _ArrayToString($aInput, '","', $i, $i, "") & '"' & @CRLF ;ConsoleWrite($sLineToWrite) FileWrite($hFileOpen, $sLineToWrite) ;ConsoleWrite("------------" & @CRLF & $sTempCSV & @CRLF & "------------" & @CRLF) ;MsgBox(0,0,0) Next Return $sTempFile EndFunc I guess I'm curious if someone has a better solution than this that isn't so brute force. My big change from before and now is I was trying to create a super long variable to a file and I flipped it to the current format with the filewrite with a handle.
  1. Load more activity
×
×
  • Create New...