Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/05/2021 in all areas

  1. Not sure what you are asking help for, but this may help you. It calculates the contrast between 2 colors, and if it larger than 7:1, it is considered as a high contrast. (based on W3C) #include <GUIConstants.au3> #include <Constants.au3> #include <Color.au3> ; see https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-procedure Local $c1 = 0xFFFF80 Local $c2 = 0x000000 GUICreate("Calculate color Contrast", 550, 400) GUICtrlCreateLabel("", 50, 50, 200, 200) GUICtrlSetBkColor(-1, $c1) GUICtrlCreateLabel("", 300, 50, 200, 200) GUICtrlSetBkColor(-1, $c2) Local $iContrast = ColorContrast($c1, $c2) GUICtrlCreateLabel(Round($iContrast, 3), 225, 280, 100, 30, $SS_CENTERIMAGE+$SS_CENTER) GUICtrlSetFont(-1, 20) GUICtrlCreateLabel(($iContrast >= 7 ? "High" : "Low") & " Contrast", 10, 320, 530, 35, $SS_CENTERIMAGE+$SS_CENTER) GUICtrlSetFont(-1, 24) GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func ColorContrast($iC1, $iC2) Local $iL1 = RelativeLuminescence($iC1) Local $iL2 = RelativeLuminescence($iC2) Return $iL1 > $iL2 ? ($iL1+0.05)/($iL2+0.05) : ($iL2+0.05)/($iL1+0.05) EndFunc Func RelativeLuminescence($iColor) Local $aCol = _ColorGetRGB($iColor) Local $R = $aCol[0]/255, $G = $aCol[1]/255, $B = $aCol[2]/255 $R = $R <= 0.03928 ? $R /12.92 : (($R + 0.055)/1.055) ^ 2.4 $G = $G <= 0.03928 ? $G /12.92 : (($G + 0.055)/1.055) ^ 2.4 $B = $B <= 0.03928 ? $B /12.92 : (($B + 0.055)/1.055) ^ 2.4 Return 0.2126 * $R + 0.7152 * $G + 0.0722 * $B EndFunc
    3 points
  2. IsArray($array) will tell you if there is an array returned by the function and Ubound will tell you the number of occurrences found
    2 points
  3. ; Note that we usually say 'a' before array type variables Local $aElement = _WD_FindElement(...) ; For each element in the array For $i=0 To UBound($aElement) - 1 ; Perform the action on that element, we access it with $i, which goes from 0, 1, 2, etc until the size of the array _WD_ElementAction($sSession, $aElement[$i], "click") Next Edit: You should probably be checking for @error after each _WD_ call if you aren't already
    1 point
  4. Sorry Danp2, we're done talking about WebDriver now
    1 point
×
×
  • Create New...