Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/29/2020 in all areas

  1. As the WebDriver UDF - Help & Support thread has grown too big, I started a new one. The prior thread can be found here.
    1 point
  2. I made an initial update to the script in my previous post. Although it now pulls all of the "irregular" table data without throwing any errors, the exact placement of the spanned rows and columns are not maintained as they are when using the _HtmlTableGetWriteToArray() function. I doubt I will continue to work on it since it really serves no purpose for me until I come across such a table in the course of my scripting. And if I need a quick fix, _HtmlTableGetWriteToArray() is always there to save the day.
    1 point
  3. And I'm glad I came across it. After some further testing I plan to incorporate it into my DIY password manager. It'll give it a new lease on life once the deprecated encryption functions are taken out of service. I'll definitely be following this UDF for further developments!
    1 point
  4. A stupid, inattentive error on my part. Sorry for wasting your time. In the meantime, I have been getting along fine with func _CryptoNG_AES_CBC_EncryptData and its Decrypt counterpart -- using the correct syntax. Thanks very much for your quick reply.
    1 point
  5. Hi @TheXman, from a quick test on the above table it seems that I get the same array using both_WD_GetTable () and _WD_GetTable_2 (), but _WD_GetTable_2 () is much slower. I also did a test on the second table at this link (https://www.w3.org/WAI/tutorials/tables/irregular/), but _WD_GetTable_2 () seems to go wrong. _WD_GetTable_2($sSession, "/html/body/div/main/article/div/figure[4]/div/table") Can you take a test on that table too?
    1 point
  6. I updated the Readme on Github so that it shows the _HtmlTableGetWriteToArray UDF as optional. Probably need to do the same to the 1st post of the this thread. Glad you are enjoying the UDF. Always willing to accept submissions for inclusion. 😉 Edit: 1st post updated
    1 point
  7. Yes, I noticed the updated _WD_Getable() function yesterday. That's why I mentioned the part about "If a user has found and included the function". Because if they hadn't, it would fall back to using the existing logic. I hadn't started playing with the WebDriver UDFs until 2 days ago. It is quite an impressive piece of work. Kudos to you and all of the contributors!
    1 point
  8. @TheXman FWIW, I recently modified _WD_GetTable so that it will use _HtmlTableGetWriteToArray instead of the original coding if this UDF is available. Appreciate your input, and I'll continue to do some testing to with your code.
    1 point
  9. https://fftoday.com/nfl/schedule.php It is a 1200 cell table, so it takes a bit to build. It is 300 rows with 4 columns per row.
    1 point
  10. Below is my version of the _WD_GetTable() helper function (named _WD_GetTable_2) that I use for grabbing tables from web sites. The difference between it and the existing _WD_GetTable() is that it spins thru the rows to find the maximum number of columns in the table. As you know, the current _WD_GetTable() only checks the first <tr> to determine the number of columns. I found that to be problematic for some of the tables that I have come across. This is certainly not the fastest way to get table data, but it is a more reliable way to get table data and uses native WebDriver functions. Maybe others may find it useful in those cases where the first row of the table doesn't reflect all of the columns in the body of the table. ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WD_GetTable_2 ; Description ...: Return all elements of a table ; Syntax ........: _WD_GetTable_2($sSession, $sBaseElement) ; Parameters ....: $sSession - Session ID from _WDCreateSession ; $sTableXpath - XPath of the table to return ; Return values .: Success - 2D array ; Failure - "" ; @ERROR - $_WD_ERROR_Success ; - $_WD_ERROR_Exception ; - $_WD_ERROR_NoMatch ; @EXTENDED - WinHTTP status code ; Author ........: TheXman ; Modified ......: ; Remarks .......: Number of rows and max cols are determined based on actual table data. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _WD_GetTable_2($sSession, $sTableXpath) Const $sFuncName = "_WD_GetTable_2" Local $aTable[0], $aRowElements[0], $aColElements[0] Local $sRowColumns = "" Local $iRows = 0, $iCols = 0, $iChildCount = 0 ;Get table row elements $aRowElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sTableXpath & "/tbody/tr", "", True) If @error <> $_WD_ERROR_Success Then Return SetError(__WD_Error($sFuncName, @error, "HTTP status = " & $_WD_HTTPRESULT), $_WD_HTTPRESULT, "") $iRows = UBound($aRowElements) ;Find max number of columns by checking each row's child count property For $iRow = 0 To UBound($aRowElements) - 1 $iChildCount = _WD_ElementAction($sSession, $aRowElements[$iRow], "property", "childElementCount") If @error <> $_WD_ERROR_Success Then Return SetError(__WD_Error($sFuncName, @error, "HTTP status = " & $_WD_HTTPRESULT), $_WD_HTTPRESULT, "") ;If number of row columns is greater the previous value, then save new value If $iChildCount > $iCols Then $iCols = $iChildCount Next ;Dimension and load table data ReDim $aTable[0][$iCols] For $iRow = 0 To $iRows - 1 ;Get column elements (td or th) $aColElements = _WD_FindElement($sSession, _ $_WD_LOCATOR_ByXPath, _ "./td|./th", _ $aRowElements[$iRow], _ True) If @error <> $_WD_ERROR_Success Then Return SetError(__WD_Error($sFuncName, @error, "HTTP status = " & $_WD_HTTPRESULT), $_WD_HTTPRESULT, "") ;Build pipe-separated row of column data $sRowColumns = "" For $iCol = 0 To UBound($aColElements) - 1 If $iCol = 0 Then $sRowColumns &= _WD_ElementAction($sSession, $aColElements[$iCol], "text") Else $sRowColumns &= "|" & _WD_ElementAction($sSession, $aColElements[$iCol], "text") EndIf Next ;Add row to array _ArrayAdd($aTable, $sRowColumns) Next ;Return result table Return $aTable EndFunc Here's an example of a table and its definition that the current _WD_GetTable() has a problem with because the first <tr> does not accurately define the max number of columns.
    1 point
  11. Here how you can do it (used Bluetooth as an example): #NoTrayIcon #include <Constants.au3> #Include <GuiToolBar.au3> _Systray_Hidden () ConsoleWrite ("Error = " & @error & @CRLF) Func _Systray_Hidden () Local $hWnd = WinGetHandle ('[Class:Shell_TrayWnd]') If Not $hWnd Then Return SetError (1) Local $hCtrl = ControlGetHandle($hWnd, "", "Button2") If Not $hCtrl Then Return SetError (2) ControlClick ($hWnd, "", $hCtrl) Sleep (600) $hWnd = WinGetHandle ('[Class:NotifyIconOverflowWindow]') Local $hSysTray = ControlGetHandle($hWnd, '', "ToolbarWindow321") If Not $hSysTray Then Return SetError (3) Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray) If Not $iSystray_ButCount Then Return SetError (4) For $i = 0 To $iSystray_ButCount-1 ConsoleWrite (_GUICtrlToolbar_GetButtonText($hSysTray, $i) & @CRLF) If StringInStr (_GUICtrlToolbar_GetButtonText($hSysTray, $i), "BlueTooth") Then _GUICtrlToolbar_ClickButton($hSysTray, $i, "left") Sleep (850) ControlSend("[CLASS:#32768]","","","{UP 2}{ENTER}") Return 1 EndIf Next Return SetError (5) EndFunc There shouldn't be more than 1 button without text. If you need more control, use UIAutomation.
    1 point
  12. Danp2

    DL'ing From API

    _INetGetSource to retrieve the raw HTML StringRegExp to parse out the desired links InetGet to download the file
    1 point
  13. Thank you, Nine! (I know, not my topic, but I haven't been able to find the Acrobat Reader object before.) The documentation for AcroPDF.PDF.1 appears to be here (page 106) under AxAcroPDFLib.AxAcroPDF This might be helpful because there are a few more methods for printing without using a dialog box: PrintAllFit, PrintPages, and PrintPagesFit
    1 point
  14. You can try this. it is unfinished but works well. It has some elements i will insert in the next weeks if i need them. #include <Constants.au3> #include <GuiConstants.au3> #include <FileConstants.au3> #include <EditConstants.au3> #include <file.au3> Opt("MustDeclareVars", 1) Opt("TrayIconHide", 1) Local $dropFile_1, $dropFile_2, $label, $msg, $dropFile_txt, $szDrive, $szDir, $szFName, $szExt, $print_pid, $default, $Printer,$Printer_setback ;Abfrage Standard Drucker $default = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device") ;default Printer auslesen $Printer_setback = $default If Not StringInStr($default, "FinePrint") Then If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(52, "Fineprint", "Ich benötige Fineprint als Standard Drucker." & @CRLF & "Jetzt setzen?", 15) Select Case $iMsgBoxAnswer = 6 ;Yes RunWait('RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "FinePrint"') ;default printer setzen $default = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device") ;default Printer auslesen Case $iMsgBoxAnswer = 7 ;No Case $iMsgBoxAnswer = -1 ;Timeout EndSelect EndIf ;Ende - Abfrage Standard Drucker ; Gui erstellen GUICreate('Drag and Drop', 150, 170, @DesktopWidth / 2 - 192, _ @DesktopHeight / 2 - 235, -1, $DS_MODALFRAME + $WS_EX_ACCEPTFILES + $WS_EX_TOPMOST) GUICtrlCreateGroup("", 5, 5, 140, 90) $dropFile_1 = GUICtrlCreateLabel($dropFile_1, 10, 20, 130, 70, -1) GUICtrlSetData($dropFile_1, @LF & @LF & "Datei hier ablegen") GUICtrlSetState($dropFile_1, $GUI_DROPACCEPTED) GUICtrlSetTip($dropFile_1, 'Zu druckende Datei in dieses Feld ziehen') $Printer = GUICtrlCreateLabel($default, 10, 150, 140, 60, -1) Local $idStart = GUICtrlCreateButton("Start", 15, 110, 100, 25) GUICtrlSetState($idStart, 128) Local $idset = GUICtrlCreateButton("", 130, 120, 15, 15) GUICtrlSetTip($idset, 'Drucker auf FinePrint umstellen') Local $sFile1 GUISetState() ;Ende - Gui erstellen While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE GUIDelete() ExitLoop Case $GUI_EVENT_DROPPED If @GUI_DropId = $dropFile_1 Then Dim $Path = @GUI_DragFile _PathSplit(@GUI_DragFile, $szDrive, $szDir, $szFName, $szExt) GUICtrlSetData($dropFile_1, $szFName & $szExt) GUICtrlSetState($idStart, 64) EndIf Case $idStart $sFile1 = GUICtrlRead($dropFile_1) If $sFile1 Then GUICtrlSetState($idStart, 128) GUICtrlSetData($dropFile_1, "In Arbeit...") ShellExecute(@GUI_DragFile, "", "", "Print") If @error Then Exit Sleep(5000) GUICtrlSetState($idStart, 64) GUICtrlSetData($dropFile_1, "Datei hier ablegen") Else MsgBox($MB_SYSTEMMODAL, "Error", "Keine Datei zum Drucken eingefügt") EndIf Case $idset RunWait('RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "FinePrint"');default printer setzen $default = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device") ;default Printer auslesen GUICtrlSetData($Printer, $default) MsgBox(262192, "", "Der Drucker wurde auf FinePrint umgestellt.") ;MsgBox features: Title=No, Text=Yes, Buttons=OK, Icon=Warning, Miscellaneous=Top-most attribute EndSwitch WEnd
    1 point
  15. That worked. Here it is the imagesearch.au3 modified code that worked. #include-once ; ------------------------------------------------------------------------------ ; ; AutoIt Version: 3.0 ; Language: English ; Description: Functions that assist with Image Search ; Require that the ImageSearchDLL.dll be loadable ; ; ------------------------------------------------------------------------------ ;=============================================================================== ; ; Description: Find the position of an image on the desktop ; Syntax: _ImageSearchArea, _ImageSearch ; Parameter(s): ; $findImage - the image to locate on the desktop ; $tolerance - 0 for no tolerance (0-255). Needed when colors of ; image differ from desktop. e.g GIF ; $resultPosition - Set where the returned x,y location of the image is. ; 1 for centre of image, 0 for top left of image ; $x $y - Return the x and y location of the image ; ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 ; ; Note: Use _ImageSearch to search the entire desktop, _ImageSearchArea to specify ; a desktop region to search ; ;=============================================================================== Func _ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $HBMP=0) return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance,$HBMP) EndFunc Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance, $HBMP=0) ;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom) if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage If IsString($findImage) Then $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage,"ptr",$HBMP) Else $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"ptr",$findImage,"ptr",$HBMP) EndIf ; If error exit if $result[0]="0" then return 0 ; Otherwise get the x,y location of the match and the size of the image to ; compute the centre of search $array = StringSplit($result[0],"|") $x=Int(Number($array[2])) $y=Int(Number($array[3])) if $resultPosition=1 then $x=$x + Int(Number($array[4])/2) $y=$y + Int(Number($array[5])/2) endif return 1 EndFunc ;=============================================================================== ; ; Description: Wait for a specified number of seconds for an image to appear ; ; Syntax: _WaitForImageSearch, _WaitForImagesSearch ; Parameter(s): ; $waitSecs - seconds to try and find the image ; $findImage - the image to locate on the desktop ; $tolerance - 0 for no tolerance (0-255). Needed when colors of ; image differ from desktop. e.g GIF ; $resultPosition - Set where the returned x,y location of the image is. ; 1 for centre of image, 0 for top left of image ; $x $y - Return the x and y location of the image ; ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 ; ; ;=============================================================================== Func _WaitForImageSearch($findImage, $waitSecs, $resultPosition, ByRef $x, ByRef $y, $tolerance, $HBMP=0) $waitSecs = $waitSecs * 1000 $startTime=TimerInit() While TimerDiff($startTime) < $waitSecs sleep(100) $result=_ImageSearch($findImage,$resultPosition,$x, $y,$tolerance,$HBMP) if $result > 0 Then return 1 EndIf WEnd return 0 EndFunc ;=============================================================================== ; ; Description: Wait for a specified number of seconds for any of a set of ; images to appear ; ; Syntax: _WaitForImagesSearch ; Parameter(s): ; $waitSecs - seconds to try and find the image ; $findImage - the ARRAY of images to locate on the desktop ; - ARRAY[0] is set to the number of images to loop through ; ARRAY[1] is the first image ; $tolerance - 0 for no tolerance (0-255). Needed when colors of ; image differ from desktop. e.g GIF ; $resultPosition - Set where the returned x,y location of the image is. ; 1 for centre of image, 0 for top left of image ; $x $y - Return the x and y location of the image ; ; Return Value(s): On Success - Returns the index of the successful find ; On Failure - Returns 0 ; ; ;=============================================================================== Func _WaitForImagesSearch($findImage, $waitSecs, $resultPosition, ByRef $x, ByRef $y, $tolerance, $HBMP=0) $waitSecs = $waitSecs * 1000 $startTime=TimerInit() While TimerDiff($startTime) < $waitSecs for $i = 1 to $findImage[0] sleep(100) $result=_ImageSearch($findImage[$i],$resultPosition,$x, $y,$tolerance,$HBMP) if $result > 0 Then return $i EndIf Next WEnd return 0 EndFunc
    1 point
  16. Hello. Check in function's byref parameter. make sure you set a space after every comma. Func _TestError(ByRef $a,ByRef $b) EndFunc Func _TestNoError(ByRef $a, ByRef $b) EndFunc Saludos
    1 point
  17. You can use the following Au3Wrapper directive to run your exe as an console application: #AutoIt3Wrapper_Change2CUI=Y ConsoleWrite("Hello World" & @CRLF)
    1 point
×
×
  • Create New...