Jump to content

Davidowicza

Active Members
  • Posts

    65
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Davidowicza

  1. @mLipok @Danp2 Thank you both so much! Updating the UDF did the trick. I updated it about 2 months ago and I don't know why it didn't occur to me to do that this time 🤦‍♂️
  2. Hello Everyone! Been a bit since I've posted on here but I have come across an issue that I could just be overlooking and cannot get past. I work for a local government agency so I cannot share too much information, which I know isn't ideal and can probably make it so I can't be helped, but I will try to share as much as I can. I keep getting an error when trying to enter an iFrame that was working for months. This morning the website I am automating updated it's URL, so I am going step by step making sure all the xPath's and elements haven't changed as well. Turns out 99% of it is still the same. When I get to my step of entering an iFrame using FrameEnter, it throws an error every time, even though the iFrame xpath didn't change at all in the html. This is the iFrame element: <iframe allow="geolocation *; microphone *; camera *" frameborder="0" height="500px" id="j_id9" name="j_id9" src="https://dmahs-nj.my.site.com/admintool/AVS_REPORT?RequestID=1098578" title="Content" width="1200px"></iframe> This is the iFrame's Xpath: //*[@id="j_id9"] This is the snippet of the code: ;Locate iFRAME and enter it _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='j_id9']",0,10000) If @error Then MsgBox(0, "iFrame Error", "WaitElement for iFrame Error") Exit EndIf Sleep(2000) ;2 second sleep is only here for testing $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='j_id9']") If @error Then MsgBox(0, "iFrame Error", "FindElement iFrame Error"&@CRLF&@error) Exit EndIf Sleep(2000) ;2 second sleep is only here for testing _WD_FrameEnter($sSession,$sElement) If @error Then MsgBox(0, "iFrame Error", "FrameEnter iFrame Error"&@CRLF&@error&@CRLF&$sElement) Exit EndIf This is console output: _WD_WaitElement ==> Success [0] : Parameters: Strategy=xpath Selector=//*[@id='j_id9'] Delay=0 Timeout=10000 Options=Default __WD_Post ==> Success [0] : HTTP status = 200 _WD_FindElement ==> Success [0] : Parameters: Strategy=xpath Selector=//*[@id='j_id9'] StartNodeID=Default Multiple=Default ShadowRoot=Default _WD_FrameEnter ==> Invalid argument [5] : Parameters: Identifier=C2121657FAA2FC7757E94F6A9B188BB8_element_113 +>09:05:39 AutoIt3.exe ended.rc:0 +>09:05:39 AutoIt3Wrapper Finished. >Exit code: 0 Time: 55.9 What I've never had happen before is WaitElement see's it, FindElement get's it but for some reason FrameEnter is the only one having issues with it. Has anyone else run into this? Thanks in advance and I know it may not get far with limited information.
  3. Wouldn't it just be easier to just roll back your version of AutoIT if you don't want fix your script errors?
  4. @serkan, Simple explaination of Danp2's script: #include <InetConstants.au3> #include <StringConstants.au3> #include <Array.au3> Local $sHTML = BinaryToString(InetRead("https://covid19asi.saglik.gov.tr/", $INET_FORCERELOAD)) ;Grab the websites HTML and put it all inside of a string variable Local $aMatch = StringRegExp($sHTML, "(?:var asiyapilankisisayisi = )(.*);", $STR_REGEXPARRAYMATCH) ;Using RegEx patterns, search through the string and grab the number you need _ArrayDisplay($aMatch) Now if you don't want to learn RegEx (I can't even comprehend how insane some of them are), Danp2 suggest you use his Webdriver UDF (User Defined Function) in his signature. It is a super useful and simple tool to navigate and/or grab information from Chrome or Edge browser. If you want to learn and not just get, click the links in @Danp2's signature and read up. 😃 👍
  5. Throwing the unset before the screen capture as @pixelsearch said could help as sending the the key immediately after could be a timing issue which could explain why your other computer is sending 2 deletes. If that is still an issue, throw a short sleep(100) after the unset of the hotkey.
  6. This worked for me: #include <Date.au3> #include <ScreenCapture.au3> HotKeySet("1", "one") HotKeySet("{ESC}","leave") While 1 Sleep(50) WEnd Func one() _ScreenCapture_Capture(@DesktopDir & "\" & StringRegExpReplace(_Now(), '[/ :]', '-') & ".jpg") HotKeySet("1") Send("1") Sleep(200) HotKeySet("1", "one") EndFunc Func leave() Exit EndFunc
  7. Looks like when we got our new PCs a couple months ago I focused on updating the SciTE rather than Autoit itself.... don't mind me I'll be in the corner Thanks, haha.
  8. Hey @water, First time testing this UDF and I am having issues getting started. I keep getting many "'With' cannot be nested." Errors. Simple Code: #include <TaskScheduler.au3> Global $oService = _TS_Open() Errors: With so many people being able to run this without issues, I am thinking it's some setting in my AutoIT I need to change? Let me know what you think! UDF Version: 1.5.1.0 Thanks.
  9. I find it the easiest to click by Xpath. In Chrome you should be able to right click that div (in developer tools) and copy Xpath. Then it is as easy as: $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "XPATH HERE") _WD_ElementAction($sSession, $sElement, 'click')
  10. Total assumption that you are trying to click here, but try changing your Xpath to the iFrame to: $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='left-content']/div/iframe[2]") And the element you want to "possibly" click to: $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/div/div[1]/a[1]/img") This was the only element in that iFrame that I could find that "did something". Tested and works for me at least.
  11. @Nine I agree that your way is much more efficient and reliable but from his response I figured he needed a simpler method to start with.
  12. Start off by looking at MouseGetPos(), TimerInit(), and ProcessClose() functions.
  13. @Danp2 Thank you again! I figured I had to be missing something obvious... Spent about 4 hours trying to figure it out but never guessed it was because of how I was entering the iFrame...it works like a charm!
  14. Hey all, I am having an issue getting the _WD functions to locate this link that I need to click on. Link element that I need to click: <a href="/admintool/servlet/servlet.FileDownload?file=00Pt000000ICYQHEA5" target="_BLANK" class="actionLink">Review.pdf</a> Xpath: //*[@id="j_id0:theForm:j_id31:j_id33:0:j_id36"]/a iFrame that it is in: <iframe allow="geolocation *; microphone *; camera *" frameborder="0" height="80%" id="j_id71" name="j_id71" src="website" title="Content" width="100%"></iframe> What I have tried so far: _WD_FrameEnter($sSession,"j_id71") ;I have tried all this code without entering the frame too if @error Then MsgBox(0, "Frame", @error) ;Does not throw error so I know I am in the frame _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='j_id0:theForm:j_id31:j_id33:0:j_id36']/a"), 0, 10000) if @error Then MsgBox(0, "ByXpath", @error) _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/form/div[2]/div/div/div[1]/table/tbody/tr/td[1]/a"), 0, 10000) ;Not sure if this even works but I tried it anyway if @error Then MsgBox(0, "ByFullXpath", @error) _WD_WaitElement($sSession, $_WD_LOCATOR_ByLinkText, "Review.pdf", 0, 10000) if @error Then MsgBox(0, "ByLinkText", @error) _WD_WaitElement($sSession, $_WD_LOCATOR_ByPartialLinkText, "Review.pdf", 0, 10000) if @error Then MsgBox(0, "ByPartialText", @error) _WD_WaitElement($sSession, $_WD_LOCATOR_ByPartialLinkText, "Review", 0, 10000) if @error Then MsgBox(0, "ByPartialText2", @error) _WD_WaitElement($sSession, $_WD_LOCATOR_ByCSSSelector, ".actionLink") if @error Then MsgBox(0, "ByCSS", @error) All of these return @error = 7 (timeout) even though the element is loaded (takes half a second to appear on the screen) and I am completely stumped on another way to interact with it. And obviously since I cannot get my script to locate this element, all of the 'click' interactions return "No Match". Anymore suggestions would be super helpful! Thanks! PS: Unfortunately I cannot share this website since it has private information on it, but I will give as much info as I can.
  15. When seeing if strings are equal you need to use the StringCompare() function.
  16. Are you planning on doing this in a GUI you create yourself? Because what I would do is use a hotkey (or button) to start your "clock" using TimerInit then type what you need to, and use another hotkey to stop you clock, do a word count of the string that was just written, and then get calculate your words per minute by using the timer and how many words you wrote. The problem with using a Hotkey on the spacebar to count "words" is that it would be inaccurate if you make a typo and need to delete some words.
  17. Just to clarify, are you having an issue getting the file to one of your pcs? or running the file once its there? If you are wondering how to get the file there, AFAIK TeamViewer is just an RDP. So you will still need a way to transfer transfer the file to that PC. You can do that using a shared directory through your network, Active Directory, or even just emailing the file to that PC. Once it is there, using RDP, you can just run it yourself.
  18. You clearly didn't read what he said: You kept the comma in your script. Change it to: $oNNV = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[(text()='Noch nicht veröffentlicht')]")
  19. I actually never knew Exitloop had parameters to work with! It makes life so much easier haha. Thanks for that. Changed to: While 1 $oFrames = _IEFrameGetCollection($o_IE) $iNumFrames = @extended For $i = 0 to ($iNumFrames - 1) $oFrame = _IEFrameGetCollection($o_IE, $i) if $oFrame.name = "j_id53" Then $oSelects = _IETagNameGetCollection($oFrame, "select") ExitLoop(2) EndIf Next sleep(100) WEnd
  20. I want to thank you @Nine for pointing me in the right direction. Changed when looking for iFrames to this: $bFound = False While $bFound = False $oFrames = _IEFrameGetCollection($o_IE) $iNumFrames = @extended For $i = 0 to ($iNumFrames - 1) $oFrame = _IEFrameGetCollection($o_IE, $i) if $oFrame.name = "j_id53" Then sleep(500) $bFound = True $oSelects = _IETagNameGetCollection($oFrame, "select") ExitLoop EndIf Next sleep(100) WEnd and it works like a charm! (took me so long to respond because after I got this working, other areas were causing me grief so I had to take care of those first)
  21. @Nine Thanks, I will try these and let you know!
  22. Hey guys, I am getting a COM error that I am struggling to resolve. It happens at random times but in the same area. I am automating a printing job that goes through and prints all of the applications for the day for my agency. Unfortunately I cannot share access to the website since its government related so I will provide as much detail as I possibly can. Here is my script: #INCLUDE <IE.au3> Opt("wintitlematchmode",2) _IEErrorHandlerRegister(_User_ErrFunc) $URL = "https://njfc.force.com/admintool/login" $sUser = InputBox("Enter Username", "Username:","","",30,130) $sPass = InputBox("Enter Password", "Password:","","",30,130) ;Open IE ;Created a loop since after roughly 18 apps the _IE functions would start failing. for $x = 1 to 25 ;Will print up to 125 apps. $o_IE = _IECreate($URL) ;Set window to Maximum $hwnd = _IEPropertyGet($o_IE, "hwnd") WinSetState($hwnd,"",@SW_MAXIMIZE) ;Search through the website and insert the information $oInputs = _IETagNameGetCollection($o_IE, "Input") if @error Then MsgBox($MB_ICONERROR, '_IETAGNAME LOGIN', '@error = ' & @error & @CRLF & '@extended = ' & @extended) EndIf for $oInput In $oInputs If $oInput.name = 'username' Then $oInput.value = $sUser If $oInput.name = 'pw' Then $oInput.value = $sPass Next sleep(500) ;Search for Login button and click it for $oInput In $oInputs If $oInput.name = 'Login' Then _IEAction($oInput, "click") if @error Then MsgBox($MB_ICONERROR, '_IEAction click Login', '@error = ' & @error & @CRLF & '@extended = ' & @extended) EndIf EndIf Next sleep(5000) ;Wait for the Next button to appear then click it $bFound = False $iTimer = TimerInit() While TimerDiff($iTimer) < 5000 AND $bFound = False $oInputs = _IETagNameGetCollection($o_IE, "Input") if @error Then MsgBox($MB_ICONERROR, '_IETagNameGetCollection Next button', '@error = ' & @error & @CRLF & '@extended = ' & @extended) EndIf for $oInput In $oInputs If $oInput.name = 'thePage:j_id2:i:f:pb:pbb:nextAjax' Then Sleep(4000) _IEAction($oInput, "click") if @error Then MsgBox($MB_ICONERROR, '_IEAction Next click', '@error = ' & @error & @CRLF & '@extended = ' & @extended) EndIf $bFound = True EndIf Next sleep(100) WEnd ;Error checking. If $bFound = False Then MsgBox(0,"Error","Could not find NEXT button. Try again. If this is a constant error, please contact IT.") Exit EndIf ;Long wait for the dropdown list to show all the entries to appear. $bFound = False $iTimer2 = TimerInit() While TimerDiff($iTimer2) < 45000 AND $bFound = False $oSelects = _IETagNameGetCollection($o_IE, "Select") if @error Then MsgBox($MB_ICONERROR, '_IETAGNAMECollection droplist', '@error = ' & @error & @CRLF & '@extended = ' & @extended) EndIf for $oSelect In $oSelects If $oSelect.name = 'theTable_length' Then _IEAction($oSelect, "click") if @error Then MsgBox($MB_ICONERROR, '_IEAction click dropdown', '@error = ' & @error & @CRLF & '@extended = ' & @extended) EndIf Send("{DOWN}") Send("{DOWN}") Send("{DOWN}") $bFound = True EndIf Next sleep(100) WEnd If $bFound = False Then MsgBox(0, "Error", "Could not find dropdown. Please try again.") EndIf Sleep(1000) ;This is where we loop through up to 100 entries on the page. If there are more, they just need to rerun the script. $nNum = 0 $oTableCells = _IETagNameGetCollection($o_IE, "TD") if @error Then MsgBox($MB_ICONERROR, '_IETagNameCollection table', '@error = ' & @error & @CRLF & '@extended = ' & @extended) EndIf for $oTableCell In $oTableCells If $nNum > 5 Then ExitLoop ;If we have done 15 apps. restart the program. ;Each app is labeled 'N - New' so we loop through each TD element with that in it. If $oTableCell.innertext = 'N - New' Then _IEAction($oTableCell, "click") If @error Then MsgBox($MB_ICONERROR, '_IEAction table click', '@error = ' & @error & @CRLF & '@extended = ' & @extended) EndIf ;Set timer and wait for the popup for that app to load. $oAs = _IETagNameGetCollection($o_IE, "a") if @error Then MsgBox($MB_ICONERROR, '_IETagNameCollection Status tab', '@error = ' & @error & @CRLF & '@extended = ' & @extended) EndIf For $oA In $oAs ;Click the App Status tab If $oA.id = "ui-id-4" Then Sleep(3000) _IEAction($oA, "click") if @error Then MsgBox($MB_ICONERROR, '_IEAction click status tab', '@error = ' & @error & @CRLF & '@extended = ' & @extended) EndIf EndIf Next Sleep(100) sleep(5000) $oFrame = _IEFrameGetObjByName($o_IE,"j_id53") sleep(500) $oSelects = _IETagNameGetCollection($oFrame, "select") For $oSelect in $oSelects ;Focus on the 'New' and switch it to pending If $oSelect.id = "j_id0:theForm:j_id26:0:APP_status" Then Sleep(2000) _IEFormElementOptionSelect($oSelect, "P - Pending") if @error Then MsgBox($MB_ICONERROR, '_IEFormOptionSelect Pending', '@error = ' & @error & @CRLF & '@extended = ' & @extended) EndIf EndIf Next Sleep(1000) ;Search and find the 'Save' button and click it. $oForm = _IEFormGetObjByName($oFrame,"j_id0:theForm") if @error Then MsgBox($MB_ICONERROR, '_IEGetForm', '@error = ' & @error & @CRLF & '@extended = ' & @extended) EndIf $oInput = _IEGetObjById($oForm, "j_id0:theForm:j_id26:0:cmdSave") if @error Then MsgBox($MB_ICONERROR, '_IEGetObjId Save', '@error = ' & @error & @CRLF & '@extended = ' & @extended) EndIf _IEAction($oInput, "click") if @error Then MsgBox($MB_ICONERROR, '_IEAction click save', '@error = ' & @error & @CRLF & '@extended = ' & @extended) EndIf Sleep(2000) For $oA In $oAs ;Click on the tab that hold the pdf If $oA.id = "ui-id-13" Then _IEAction($oA, "click") if @error Then MsgBox($MB_ICONERROR, '_IEaction click pdf tab', '@error = ' & @error & @CRLF & '@extended = ' & @extended) EndIf EndIf Next Sleep(7000) $oFrame = _IEFrameGetObjByName($o_IE,"j_id71") if @error Then MsgBox($MB_ICONERROR, '_IE iFrame Get PDF', '@error = ' & @error & @CRLF & '@extended = ' & @extended, 3000) EndIf Sleep(500) $oAs = _IETagNameGetCollection($oFrame, "a") For $oA in $oAs ;Click on the link that opens the pdf can be names either review or PEapplicationReview If ($oA.innertext = "Review.pdf") Or ($oA.innertext = "PEapplicationReview.pdf") Then sleep(1000) _IEAction($oA, "click") if @error Then MsgBox($MB_ICONERROR, '_IEaction PDF click', '@error = ' & @error & @CRLF & '@extended = ' & @extended) EndIf EndIf Next Sleep(3000) ;Many issues on this computer interacting with the new tab created. So we are forced to do Send commants to print the app. ;_IELoadWait($o_IE) Cannot do this. Was occasionally getting No Longer Connected to Object error sleep(12000) ;Open printing options Send("^p") WinWait("Print") Sleep(4000) ;Print Send("{ENTER}") ;Wait for upload to printer WinWait("Progress") Sleep(7000) ;Close the app Tab. THIS IS THE ONLY COORDINATE ISSUE WILL SHOULD EVER RUN INTO MouseClick("left",1005, 40,5) ;move the mouse back since it sometimes extended the tabs so they would be off MouseMove(500,500) sleep(5000) ;Close the apps popup $oDivs = _IEGetObjById($o_IE, "escaper") if @error Then MsgBox($MB_ICONERROR, '_IEGetObjID Escaper', '@error = ' & @error & @CRLF & '@extended = ' & @extended,2) EndIf _IEAction($oDivs, "click") if @error Then MsgBox($MB_ICONERROR, '_IEAction Escaper click', '@error = ' & @error & @CRLF & '@extended = ' & @extended,2) EndIf $nNum = $nNum + 1 Sleep(2000) EndIf Next ;Close IE _IEQuit($o_IE) if @error Then MsgBox($MB_ICONERROR, '_IEClose', '@error = ' & @error & @CRLF & '@extended = ' & @extended,2) EndIf Sleep(3000) Next Func _User_ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptFullPath & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_User_ErrFunc (I stopped using _IELoadWait() since I kept losing connection to the ie object, which could be an issue too) It happens at line 178: $oFrame = _IEFrameGetObjByName($o_IE,"j_id71") This is what the consol returns: >"C:\Program Files\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Bergen\AdminTool.au3" /UserParams     +>09:37:36 Starting AutoIt3Wrapper v.19.102.1901.0 SciTE v.4.1.2.0   Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X86  Environment(Language:0409)  CodePage:0  utf8.auto.check:4 +>         SciTEDir => C:\Program Files\AutoIt3\SciTE   UserDir => C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper >Running AU3Check (3.3.14.5)  from:C:\Program Files\AutoIt3  input:C:\Bergen\AdminTool.au3 +>09:37:36 AU3Check ended.rc:0 >Running:(3.3.14.5):C:\Program Files\AutoIt3\autoit3.exe "C:\Bergen\AdminTool.au3"     +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop C:\Bergen\AdminTool.au3 (1812) : ==> COM Error intercepted !     err.number is:         0x80020008     err.windescription:    Bad variable type.     err.description is:          err.source is:              err.helpfile is:          err.helpcontext is:          err.lastdllerror is:     0     err.scriptline is:     1812     err.retcode is:     0x00000000 C:\Bergen\AdminTool.au3 (1812) : ==> COM Error intercepted !     err.number is:         0x80020008     err.windescription:    Bad variable type.     err.description is:          err.source is:              err.helpfile is:          err.helpcontext is:          err.lastdllerror is:     0     err.scriptline is:     1812     err.retcode is:     0x00000000 C:\Bergen\AdminTool.au3 (713) : ==> COM Error intercepted !     err.number is:         0x000000A9     err.windescription:    Variable must be of type 'Object'.     err.description is:          err.source is:              err.helpfile is:          err.helpcontext is:          err.lastdllerror is:     0     err.scriptline is:     713     err.retcode is:     0x00000000 --> IE.au3 T3.0-2 Warning from function _IEFrameGetObjByName, $_IESTATUS_NoMatch (No Frames found) And the iFrame I am trying to connect to: <iframe name="j_id71" width="100%" height="80%" title="Content" id="j_id71" src="https://njfc.force.com/admintool/apex/FC_Attachment_Tab?confnum=02000846815" frameborder="0" allow="geolocation *; microphone *; camera *"></iframe> The error thrown is @error=7 and @extended=2 which means it could not find the object. The main thing that I do not understand is it works for the first 8-14 applications, then it will randomly throw this error. The element has fully loaded on the page and I am 100% sure that the name of the iFrame did not change. I will provide as much info as possible if you need more. Any help would be appreciated. Thanks.
  23. Make sure the administraTor account is spelled correctly. Edit: Didn't know that was the spanish spelling, whoops. Thanks @BrewManNH
  24. @TheXman Yeah I was trying that off limits topic but ran into an issue and I know I am on my own with that issue if I try to continue that direction. Task Scheduler could be my safety blanket for this, it just ran so nicely on Win 7 was hoping for an easy conversion to 10 but I guess that's Microsoft for ya. Thanks. @genius257 Thanks for that information but _Date_Time_* functions would still need me to elevate the script and for the second link we do not want the users to be able to change the date/time of their machines.
  25. Long story short, I work for our local government, half of our computers are owned by the state. There are some dumb processes on the state's computers that we cannot change, like where those computer sync their time on boot. The server that it syncs time with happens to be 7 minutes faster than the actual time, which makes about 110 of our machines 7 minutes faster than the others. I would run that script after log-in so it sets those computers that are state owned to the correct time of our office. I know it seems dumb, because it is. But we need to have all machines at the same time since if a worker forgets their swipe in badge, they can email our payroll clerk which will have their timestamp on the email. That 7 minute discrepancy caused many issues... and is causing me even more haha
×
×
  • Create New...