Leaderboard
Popular Content
Showing content with the highest reputation on 12/25/2018 in all areas
-
Hi Paul, Appreciate the feedback. I believe all of the items you listed are due to the webdriver implementation and can't be controlled by this UDF. I'm guessing you tested with Chrome, because that's where I also observed the "shooting effect". As far as getting the element's boundaries, you can use _WD_ElementAction to obtain them. Dan1 point
-
Remove figure from the open workbook Excel
Xandy reacted to JLogan3o13 for a topic
@LazyVasily you are simply going to have to provide more information if you want help, our crystal ball is in the shop. How about a screenshot of the figure you are trying to remove, or better yet, an example of the spreadsheet itself.1 point -
Here's my rendition of _WD_Screenshot, which will eventually be added to wd_helper.au3. I tried to make it versatile enough for any scenario. I decided to keep it simple by leaving the file writing process to the calling routine. Note: To test this, you will need to use the latest (unreleased) rendition of wd_core.au3, which can be downloaded here. #include "wd_core.au3" #include "wd_helper.au3" Local $sDesiredCapabilities Local Enum $eFireFox = 0, _ $eChrome Local Const $_TestType = $eFireFox Func SetupGecko() _WD_Option('Driver', 'geckodriver.exe') _WD_Option('DriverParams', '--log trace') _WD_Option('Port', 4444) $sDesiredCapabilities = '{"capabilities":{"alwaysMatch":{"acceptInsecureCerts":true, "pageLoadStrategy":"none"}}}' EndFunc Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true}}}}' EndFunc Switch $_TestType Case $eFireFox SetupGecko() Case $eChrome SetupChrome() EndSwitch _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) If @error <> $_WD_ERROR_Success Then Exit _WD_Navigate($sSession, "http://www.google.com") _WD_LoadWait($sSession, 500, 2000) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='q']") $sImage1 = _WD_Screenshot($sSession, $sElement) $sImage2 = _WD_Screenshot($sSession) _WD_Navigate($sSession, "http://www.yahoo.com") _WD_LoadWait($sSession, 500, 2000) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@id='uh-signin']") $sImage3 = _WD_Screenshot($sSession, $sElement) $sImage4 = _WD_Screenshot($sSession) _WD_DeleteSession($sSession) $hImage = FileOpen("image1.png", 18) FileWrite($hImage, $sImage1) FileClose($hImage) $hImage = FileOpen("image2.png", 18) FileWrite($hImage, $sImage2) FileClose($hImage) $hImage = FileOpen("image3.png", 18) FileWrite($hImage, $sImage3) FileClose($hImage) $hImage = FileOpen("image4.png", 18) FileWrite($hImage, $sImage4) FileClose($hImage) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WD_Screenshot ; Description ...: ; Syntax ........: _WD_Screenshot($sSession[, $sElement = ''[, $nOutputType = 1]]) ; Parameters ....: $sSession - Session ID from _WDCreateSession ; $sElement - [optional] Element ID from _WDFindElement ; $nOutputType - [optional] One of the following output types: ; | 1 - String (Default) ; | 2 - Binary ; | 3 - Base64 ; Return values .: None ; Author ........: Dan Pollak ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _WD_Screenshot($sSession, $sElement = '', $nOutputType = 1) Local Const $sFuncName = "_WD_Screenshot" Local $sResponse, $sJSON, $sResult, $bDecode If $sElement = '' Then $sResponse = _WD_Window($sSession, 'Screenshot') $iErr = @error Else $sResponse = _WD_ElementAction($sSession, $sElement, 'Screenshot') $iErr = @error EndIf If $iErr = $_WD_ERROR_Success Then Switch $nOutputType Case 1 ; String $sResult = BinaryToString(_Base64Decode($sResponse)) Case 2 ; Binary $sResult = _Base64Decode($sResponse) Case 3 ; Base64 EndSwitch Else $sResult = '' EndIf Return SetError(__WD_Error($sFuncName, $iErr), 0, $sResult) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Base64Decode ; Description ...: ; Syntax ........: _Base64Decode($input_string) ; Parameters ....: $input_string - string to be decoded ; Return values .: Decoded string ; Author ........: trancexx ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://www.autoitscript.com/forum/topic/81332-_base64encode-_base64decode/ ; Example .......: No ; =============================================================================================================================== Func _Base64Decode($input_string) Local $struct = DllStructCreate("int") $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _ "str", $input_string, _ "int", 0, _ "int", 1, _ "ptr", 0, _ "ptr", DllStructGetPtr($struct, 1), _ "ptr", 0, _ "ptr", 0) If @error Or Not $a_Call[0] Then Return SetError(1, 0, "") ; error calculating the length of the buffer needed EndIf Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]") $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _ "str", $input_string, _ "int", 0, _ "int", 1, _ "ptr", DllStructGetPtr($a), _ "ptr", DllStructGetPtr($struct, 1), _ "ptr", 0, _ "ptr", 0) If @error Or Not $a_Call[0] Then Return SetError(2, 0, ""); error decoding EndIf Return DllStructGetData($a, 1) EndFunc ;==>_Base64Decode Also, I haven't been able to get the chrome or firefox drivers to successfully return an element image. Please test and share your results here. Any feedback is appreciated.1 point
-
This can be done with the Webdriver UDF, but only if the browser was launched by the UDF.1 point
-
With information from UIASpy (Copy structure to clipboard) it's not that hard: 0000 Pane: AutoIt Scripting Language - AutoIt - Google Chrome 0001 Pane: Chrome Legacy Window 0002 TitleBar 0003 MenuBar: System 0004 MenuItem: System 0005 Button: Minimize 0006 Button: Maximize 0007 Button: Close 0008 Pane: Google Chrome 0009 Pane 0010 Button: Minimize 0011 Button: Maximize 0012 Button: Restore 0013 Button: Close 0014 Pane 0015 Pane 0016 Document 0017 Pane 0018 Tab 0019 TabItem: AutoIt Scripting Language - AutoIt 0020 Text: AutoIt Scripting Language - AutoIt 0021 Pane 0022 Button: Close 0023 TabItem: Forums - AutoIt Forums 0024 Text: Forums - AutoIt Forums 0025 Pane 0026 Button: Close 0027 TabItem: AutoIt Help and Support - AutoIt Forums 0028 Text: AutoIt Help and Support - AutoIt Forums 0029 Pane 0030 Button: Close 0031 TabItem: How to activate specific tabs in Google Chrome? - AutoIt General Help and Support - AutoIt Forums 0032 Text: How to activate specific tabs in Google Chrome? - AutoIt General Help and Support - AutoIt Forums 0033 Pane 0034 Button: Close 0035 TabItem: AutoIt Example Scripts - AutoIt Forums 0036 Text: AutoIt Example Scripts - AutoIt Forums 0037 Pane 0038 Button: Close 0039 TabItem: UIASpy - UI Automation Spy Tool - AutoIt Example Scripts - AutoIt Forums 0040 Text: UIASpy - UI Automation Spy Tool - AutoIt Example Scripts - AutoIt Forums 0041 Pane 0042 Button: Close 0043 Button: New Tab 0044 Pane 0045 Button: Back 0046 Button: Forward 0047 Button: Reload 0048 Custom 0049 MenuItem: View site information 0050 Edit: Address and search bar 0051 Pane 0052 Button: Bookmark this page 0053 Pane 0054 Custom: Extensions 0055 Button: Blank New Tab Page 0056 Separator 0057 Separator 0058 Button: Current user 0059 MenuItem: Chrome 0060 Pane Because this is about the outer elements of Chrome it's important that accessibility is not enabled. #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_UseX64=y #include "CUIAutomation2.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Window handle Local $hWindow = WinGetHandle( "[CLASS:Chrome_WidgetWin_1]" ) If Not IsHWnd( $hWindow ) Then Return ConsoleWrite( "$hWindow ERR" & @CRLF ) ConsoleWrite( "$hWindow OK" & @CRLF ) ; Activate window WinActivate( $hWindow ) Sleep( 100 ) ; UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement( $pDesktop ) $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) ; Chrome window Local $pCondition $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "Chrome_WidgetWin_1", $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pChrome, $oChrome $oDesktop.FindFirst( $TreeScope_Descendants, $pCondition, $pChrome ) $oChrome = ObjCreateInterface( $pChrome, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oChrome ) Then Return ConsoleWrite( "$oChrome ERR" & @CRLF ) ConsoleWrite( "$oChrome OK" & @CRLF ) ; --- Forums - AutoIt Forums --- ; Tab item Local $pCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_TabItemControlTypeId, $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) ; Tab name Local $pCondition2 ; Note that $UIA_NamePropertyId ia a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Forums - AutoIt Forums", $pCondition2 ) If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) ; And condition $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) ; Find tab item Local $pTab, $oTab $oChrome.FindFirst( $TreeScope_Descendants, $pCondition, $pTab ) $oTab = ObjCreateInterface( $pTab, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oTab ) Then Return ConsoleWrite( "$oTab ERR" & @CRLF ) ConsoleWrite( "$oTab OK" & @CRLF ) ; Rectangle Local $aRect ; l, t, w, h $oTab.GetCurrentPropertyValue( $UIA_BoundingRectanglePropertyId, $aRect ) If Not IsArray( $aRect ) Then Return ConsoleWrite( "$aRect ERR" & @CRLF ) ConsoleWrite( "$aRect OK" & @CRLF ) ; Activate tab MouseClick( "primary", $aRect[0]+$aRect[2]/2, $aRect[1]+$aRect[3]/2, 1, 0 ) EndFunc1 point
-
AutoIT and Redis
argumentum reacted to jchd for a topic
Never had experience with Redis either. I've very little time to look deep at it. Just looked what it became and I still have hard time seeing how SQLite and Redis would naturally work together. The former is a SQL RDBMS while the latter is a proprietary datastore. The underlying models of both products don't trivially compare. Yet such mixes have been tried in countless combinations. There are myriads of ways to mix SQL and NoSQL products, sometimes with perfectly valid reasons, other times just to follow current hype. The only real question is: "why do you think you have to?" Once you have loads of strong pro arguments and little or no against, then just go. Else seriously question your premises. Use Google translate if required: http://sametmax.com/nosql-arretons-de-dire-nimporte-quoi/1 point -
I just found a solution: Color = (256 * 256 * B) + G * 256 + R this is how excel convert RGB to string. Thanks all1 point