Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/23/2019 in all areas

  1. Oh. That's way easier. I was trying to bit shift, rotate, and string mid... was going nowhere fast. That's a much better solution
    1 point
  2. #include <Array.au3> _ArrayDisplay(CalcRGBAvg(20, 50, 100, 0, 0, 0)) _ArrayDisplay(CalcRGBAvg(0, 0, 255, 255, 0, 0)) Func CalcRGBAvg($iRed, $iGreen, $iBlue, $iRed2, $iGreen2, $iBlue2, $iMidPoints = 9) ; Add one to midpoints... don't know why :D $iMidPoints += 1 Local $aColors[0] Local $iRedDiff = Abs($iRed - $iRed2) Local $bRedRev = ($iRedDiff = $iRed - $iRed2) Local $iGreenDiff = Abs($iGreen - $iGreen2) Local $bGreenRev = ($iGreenDiff = $iGreen - $iGreen2) Local $iBlueDiff = Abs($iBlue - $iBlue2) Local $bBlueRev = ($iBlueDiff = $iBlue - $iBlue2) For $i = 0 To $iMidPoints ;~ _ArrayAdd($aColors, "RGB(" & _ ;~ Abs(($bRedRev ? 0 : -255) + $iRedDiff/$iMidPoints * $i) & ", " & _ ;~ Abs(($bGreenRev ? 0 : -255) + $iGreenDiff/$iMidPoints * $i) & ", " & _ ;~ Abs(($bBlueRev ? 0 : -255) + $iBlueDiff/$iMidPoints * $i) & ")") _ArrayAdd($aColors, "0x" & _ Hex(Int(Abs(($bRedRev ? 0 : -255) + $iRedDiff / $iMidPoints * $i)), 2) & _ Hex(Int(Abs(($bGreenRev ? 0 : -255) + $iGreenDiff / $iMidPoints * $i)), 2) & _ Hex(Int(Abs(($bBlueRev ? 0 : -255) + $iBlueDiff / $iMidPoints * $i)), 2)) Next Return $aColors EndFunc ;==>CalcRGBAvg Thanks
    1 point
  3. Oh, I see what I did... give me a minute, they need to be ordered. Should've tested before posting 😐
    1 point
  4. you didn't add a double quote around the filenames! Try: $cmd = Run($7zDir & ' a -mx "' & GUICtrlRead($Out) & '" "' & GUICtrlRead($Inp) & '\*"') Jos
    1 point
  5. Add quotes around out and inp like you did for the exe.
    1 point
  6. Even if AutoIt doesn't care, you should use correct prefixes for variables, see : Best_coding_practices Otherwise you will only confuse yourself . A look at the Help will not hurt either, there are good reasons why people have spent thousands of hours creating it. WinList returns an array - not a handle, so use e.g. : Local $aWindowsList = WinList()
    1 point
  7. Iczer, I don't think your functionality can be coded using LVN_ODFINDITEM notifications. It's much easier to use an input control or similar. powerofos 1. Use this line at the bottom of the code: _WinAPI_DrawText( $hDC, $aResult[$iItem-$iFrom+1][$iSubItem], $tRect, $DT_WORD_ELLIPSIS ) ; Draw text 3. In the NM_CLICK code, you can extract item (=index) and subitem from the tagNMITEMACTIVATE structure. Then you can read data from $aResult as in the code line above. 2. Since you have already determined both item and subitem in the NM_CLICK code, you do not need any subclassing code. banged, In a virtual listview, data isn't stored in items/subitems. Data is only stored in the data source. Therefore, _GUICtrlListView_GetItemText doesn't work. Read data directly from the source as you do in the LVN_GETDISPINFOW code.
    1 point
  8. AZJIO

    Convert RGB to HSB

    HSB <> HSL #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Color.au3> ; En $LngTitle = 'Color' $LngHue = 'Hue' $LngSaturation = 'Saturation' $LngLightness = 'Lightness' $LngRed = 'Red' $LngGreen = 'Green' $LngBlue = 'Blue' ; Ru ; если русская локализация, то русский язык If @OSLang = 0419 Then $LngTitle = 'Цвет' $LngHue = 'Тон' $LngSaturation = 'Насыщенность' $LngLightness = 'Светлота' $LngRed = 'Красный' $LngGreen = 'Зелёный' $LngBlue = 'Синий' EndIf Global $HSB[3] = [40, 240, 185], $RGB[3] $GUI = GUICreate($LngTitle, 340, 270) $iColorLabel = GUICtrlCreateLabel('', 90, 5, 200, 30, $WS_BORDER) $iNumLabel = GUICtrlCreateLabel('', 20, 12, 70, 17) GUICtrlCreateGroup('HSL', 3, 45, 333, 103) GUICtrlCreateGroup('RGB', 3, 155, 333, 103) GUICtrlCreateLabel($LngHue, 10, 61, 80, 17) $iValSld1 = GUICtrlCreateLabel($HSB[0], 300, 60, 30, 17) $slider1 = GUICtrlCreateSlider(90, 55, 200, 30) GUICtrlSetLimit(-1, 240, 0) GUICtrlSetData(-1, $HSB[0]) $hSlider_Handle1 = GUICtrlGetHandle(-1) GUICtrlCreateLabel($LngSaturation, 10, 91, 80, 17) $iValSld2 = GUICtrlCreateLabel($HSB[1], 300, 90, 30, 17) $slider2 = GUICtrlCreateSlider(90, 85, 200, 30) GUICtrlSetLimit(-1, 240, 0) GUICtrlSetData(-1, $HSB[1]) $hSlider_Handle2 = GUICtrlGetHandle(-1) GUICtrlCreateLabel($LngLightness, 10, 121, 80, 17) $iValSld3 = GUICtrlCreateLabel($HSB[2], 300, 120, 30, 17) $slider3 = GUICtrlCreateSlider(90, 115, 200, 30) GUICtrlSetLimit(-1, 240, 0) GUICtrlSetData(-1, $HSB[2]) $hSlider_Handle3 = GUICtrlGetHandle(-1) GUICtrlCreateLabel($LngRed, 10, 171, 80, 17) $iValSldRGB1 = GUICtrlCreateLabel($HSB[0], 300, 170, 30, 17) $sliderRGB1 = GUICtrlCreateSlider(90, 165, 200, 30) GUICtrlSetLimit(-1, 255, 0) GUICtrlSetData(-1, $HSB[0]) $hSlider_HandleRGB1 = GUICtrlGetHandle(-1) GUICtrlCreateLabel($LngGreen, 10, 201, 80, 17) $iValSldRGB2 = GUICtrlCreateLabel($HSB[1], 300, 200, 30, 17) $sliderRGB2 = GUICtrlCreateSlider(90, 195, 200, 30) GUICtrlSetLimit(-1, 255, 0) GUICtrlSetData(-1, $HSB[1]) $hSlider_HandleRGB2 = GUICtrlGetHandle(-1) GUICtrlCreateLabel($LngBlue, 10, 231, 80, 17) $iValSldRGB3 = GUICtrlCreateLabel($HSB[2], 300, 230, 30, 17) $sliderRGB3 = GUICtrlCreateSlider(90, 225, 200, 30) GUICtrlSetLimit(-1, 255, 0) GUICtrlSetData(-1, $HSB[2]) $hSlider_HandleRGB3 = GUICtrlGetHandle(-1) _SetColorRGB() GUISetState() GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL") Do Until GUIGetMsg() = -3 Func WM_HSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $nScrollCode = BitAND($wParam, 0xFFFF) ; _WinAPI_LoWord Local $value = BitShift($wParam, 16) ; _WinAPI_HiWord If $nScrollCode = 5 Then Switch $lParam Case $hSlider_Handle1 GUICtrlSetData($iValSld1, $value) $HSB[0] = $value _SetColorRGB() Case $hSlider_Handle2 GUICtrlSetData($iValSld2, $value) $HSB[1] = $value _SetColorRGB() Case $hSlider_Handle3 GUICtrlSetData($iValSld3, $value) $HSB[2] = $value _SetColorRGB() Case $hSlider_HandleRGB1 GUICtrlSetData($iValSldRGB1, $value) $RGB[0] = $value _SetColorHSB() Case $hSlider_HandleRGB2 GUICtrlSetData($iValSldRGB2, $value) $RGB[1] = $value _SetColorHSB() Case $hSlider_HandleRGB3 GUICtrlSetData($iValSldRGB3, $value) $RGB[2] = $value _SetColorHSB() EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc Func _SetColorRGB() $a = _ColorConvertHSLtoRGB($HSB) For $i = 0 To 2 $RGB[$i] = Round($a[$i]) Next $a = Hex($RGB[0], 2) & Hex($RGB[1], 2) & Hex($RGB[2], 2) GUICtrlSetData($iNumLabel, $a) GUICtrlSetBkColor($iColorLabel, Dec($a)) GUICtrlSetData($iValSldRGB1, $RGB[0]) GUICtrlSetData($iValSldRGB2, $RGB[1]) GUICtrlSetData($iValSldRGB3, $RGB[2]) GUICtrlSetData($sliderRGB1, $RGB[0]) GUICtrlSetData($sliderRGB2, $RGB[1]) GUICtrlSetData($sliderRGB3, $RGB[2]) EndFunc Func _SetColorHSB() $a = _ColorConvertRGBtoHSL($RGB) For $i = 0 To 2 $HSB[$i] = Round($a[$i]) Next $a = Hex($RGB[0], 2) & Hex($RGB[1], 2) & Hex($RGB[2], 2) GUICtrlSetData($iNumLabel, $a) GUICtrlSetBkColor($iColorLabel, Dec($a)) GUICtrlSetData($iValSld1, $HSB[0]) GUICtrlSetData($iValSld2, $HSB[1]) GUICtrlSetData($iValSld3, $HSB[2]) GUICtrlSetData($slider1, $HSB[0]) GUICtrlSetData($slider2, $HSB[1]) GUICtrlSetData($slider3, $HSB[2]) EndFuncPhotoshop uses the HSL (Ctrl + U) Color.au3 UDF H[0-240], S[0-240], L[0-240] Global Const $__COLORCONSTANTS_HSLMAX = 240 ;... Local $nH = Number($avArray[0]) / $__COLORCONSTANTS_HSLMAX Local $nS = Number($avArray[1]) / $__COLORCONSTANTS_HSLMAX Local $nL = Number($avArray[2]) / $__COLORCONSTANTS_HSLMAX Edit Color.au3 H[0-360], S[0-100], L[0-100] Local $nH = Number($avArray[0]) / 360 Local $nS = Number($avArray[1]) / 100 Local $nL = Number($avArray[2]) / 100
    1 point
×
×
  • Create New...