
grham
Active Members-
Posts
66 -
Joined
-
Last visited
Everything posted by grham
-
Cool! I will give it a try this weekend. Danke schön für die Information!
-
I started: here and here
-
Hello, I was playing around with the bitblt function, this time I was using it to create a Mask for an image. It's successfull when I load the image with _WinAPI_LoadImage It has to be from a BMP file. Here an simple working example (with double buffering). In my case the "color for transparency" is black but you can change it. The "color for transparency has to be BGR. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Don't forget to put your image there!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Winapi.au3> #include <Constants.au3> #include <WindowsConstants.au3> $sImage = "(PUT HERE THE PATH OF YOUR IMAGE!!!!!!!!!).bmp" $hBmp_Source = _WinAPI_LoadImage(0, $sImage, $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE) $stBitmap = DllStructCreate("long bmType;long bmWidth;long bmHeight;long bmWidthBytes;WORD bmPlanes;WORD bmBitsPixel;ptr bmBits") _WinAPI_GetObject($hBmp_Source, DllStructGetSize($stBitmap), DllStructGetPtr($stBitmap)) $nWidth = DllStructGetData($stBitmap, "bmWidth") $nHeight = DllStructGetData($stBitmap, "bmHeight") $hWindow = GUICreate("GDI BitBlt (Masked image)", $nWidth, $nHeight) Global $clrBackground = 0x10A040 GUISetBkColor($clrBackground, $hWindow) Global $clrTransparent = 0x000000 ; BGR! $hBmp_Mask = _CreateMask($hBmp_Source, $clrTransparent) ; Now we have our source image and its mask that we will use ; in the _OnPaint function GUIRegisterMsg($WM_PAINT, "WM_PAINT") GUISetState() While True If GUIGetMsg() = -3 Then ExitLoop WEnd _WinAPI_DeleteObject($hBmp_Mask) _WinAPI_DeleteObject($hBmp_Source) ; ======================================================================== ; FUNCTIONS ; ======================================================================== Func _CreateMask(ByRef $hBmp_Source, $clrTransparent) $hDC_Dest = _WinAPI_CreateCompatibleDC(0) ; DC (Mask) $hBmp_Mask = _WinAPI_CreateBitmap($nWidth, $nHeight, 1, 1, 0) ; Mask (1 bit per pixel) $hBmp_Mask_Prev = _WinAPI_SelectObject($hDC_Dest, $hBmp_Mask) ; Select Mask to DC $hDC_Source = _WinAPI_CreateCompatibleDC(0) ; DC (Source) $hBmp_Source_Prev = _WinAPI_SelectObject($hDC_Source, $hBmp_Source) ; Select Source image (BMP) to DC (Source) _WinAPI_SetBkColor($hDC_Source, $clrTransparent) ; Set background color of the Source DC _WinAPI_BitBlt ($hDC_Dest, 0, 0, $nWidth, $nHeight, $hDC_Source, 0, 0, $SRCCOPY) ; pixels in the "Source color bitmap" that are equal to the background color ; are blitted as white. All the remaining pixels are blitted as black. _WinAPI_BitBlt ($hDC_Source, 0, 0, $nWidth, $nHeight, $hDC_Dest, 0, 0, $SRCINVERT) ; Paint onto the original image, making sure that ; the "transparent" area is set to black. _WinAPI_SelectObject($hDC_Source, $hBmp_Source_Prev) ; Clean te two DCs _WinAPI_DeleteDC ($hDC_Source) _WinAPI_SelectObject($hDC_Dest, $hBmp_Mask_Prev) _WinAPI_DeleteDC ($hDC_Dest) Return $hBmp_Mask EndFunc ; ==> _CreateMask Func _OnPaint($hWnd) $hDC = _WinAPI_GetDC($hWnd) ; DC (Screen / Window) $hDC_Buf = _WinAPI_CreateCompatibleDC($hDC) ; Do all the painting on this buffer $hBmp_Buf = _WinAPI_CreateCompatibleBitmap($hDC, $nWidth, $nHeight) ; Then copy the content of this buffer to your Window / GUI (see 4.) $Buf_Prev = _WinAPI_SelectObject($hDC_Buf, $hBmp_Buf) _WinAPI_BitBlt ($hDC_Buf, 0, 0, $nWidth, $nHeight, $hDC, 0, 0, $SRCCOPY) ; 1. Copy the content of your Window / GUI to the buffer $hDC_Mem = _WinAPI_CreateCompatibleDC(0) ; Memory DC $hBmp_Prev = _WinAPI_SelectObject($hDC_Mem, $hBmp_Mask) _WinAPI_BitBlt ($hDC_Buf, 0, 0, $nWidth, $nHeight, $hDC_Mem, 0, 0, $SRCAND) ; 2. (AND) BitBlt the mask to the buffer with SRCAND _WinAPI_SelectObject($hDC_Mem, $hBmp_Source) _WinAPI_BitBlt ($hDC_Buf, 0, 0, $nWidth, $nHeight, $hDC_Mem, 0, 0, $SRCPAINT) ; 3. (OR) BitBlt your source image to he buffer with $SRCPAINT _WinAPI_BitBlt($hDC, 0, 0, $nWidth, $nHeight, $hDC_Buf, 0, 0, $SRCCOPY) ; 4. Copy the content of the buffer back to your Window / GUI _WinAPI_SelectObject($hDC_Mem, $hBmp_Prev) ; Clean ressources _WinAPI_DeleteDC ($hDC_Mem) _WinAPI_SelectObject($hDC_Buf, $Buf_Prev) _WinAPI_DeleteDC ($hDC_Buf) _WinAPI_DeleteObject($hBmp_Buf) _WinAPI_ReleaseDC($hWnd, $hDC) EndFunc ; ==> _OnPaint Func WM_PAINT($hWnd, $Msg, $wParam, $lParam) _OnPaint($hWnd) EndFunc ; ==> WM_PAINT but if you load an image from (for instance) a jpg with gdi+, you have to create a GDI hBitmap from it first. This hBitmap is not the same as when its loaded directly with GDI. When you bitblt it to an 1 bit per pixel Bitmap (to create a mask) the result is all black. If I understand it correctly, this is because it's a DIB and not a DDB. In that case it should be "converted" to a DDB Bitmap. I tried to do it but still without success. There is somethig incorrect in the code. I use _GDI_CreateDIBitmap (by Prog@ndy). RGBQuad member of BITMAPINFO has to be an array but I don't know the required size of that array. but from MSDN (for a 32 bpp image): _GDI_CreateDIBitmap returns a Handle to a new bitmap but it's all black. Here is what I tried (and is wrong). !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Don't forget to put your image there!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GdiPlus.au3> #include <Winapi.au3> #include <Constants.au3> #include <WindowsConstants.au3> Global Const $BI_RGB = 0 Global Const $DIB_RGB_COLORS = 0 Global Const $CBM_INIT = 0x4 ; tagBITMAPINFOHEADER Global Const $tagBITMAPINFOHEADER = "DWORD biSize;" & _ "LONG biWidth;" & _ "LONG biHeight;" & _ "ushort biPlanes;" & _ "ushort biBitCount;" & _ "DWORD biCompression;" & _ "DWORD biSizeImage;" & _ "LONG biXPelsPerMeter;" & _ "LONG biYPelsPerMeter;" & _ "DWORD biClrUsed;" & _ "DWORD biClrImportant;" Global Const $tagBMPInfo256 = $tagBITMAPINFOHEADER & "dword RGBQuad;" $BMPInfo = DllStructCreate ($tagBMPInfo256) $stBitmap = DllStructCreate("long bmType;long bmWidth;long bmHeight;long bmWidthBytes;WORD bmPlanes;WORD bmBitsPixel;ptr bmBits") ; ============================================= _GDIPlus_Startup() $pImage = _GDIPlus_ImageLoadFromFile ("HERE THE IMAGE FROM FILE PATH") $hBmp_Source = _GDIPlus_BitmapCreateHBITMAPFromBitmap($pImage) _GDIPlus_ImageDispose($pImage) _GDIPlus_Shutdown() ; ========================================================= ; Get DDC Bitmap $hdcTmp = _WinAPI_GetDC (0) $hdcMem = _WinAPI_CreateCompatibleDC ($hdcTmp) _WinAPI_ReleaseDC (0, $hdcTmp) $hBitmapOld = _WinAPI_SelectObject ($hdcMem, $hBmp_Source) _WinAPI_GetObject($hBmp_Source, DllStructGetSize($stBitmap), DllStructGetPtr($stBitmap)) $xWidth = DllStructGetData($stBitmap, "bmWidth") $xHeight = DllStructGetData($stBitmap, "bmHeight") DllStructSetData ($BMPInfo, 1, DllStructGetSize($BMPInfo)) DllStructSetData ($BMPInfo, "biWidth" , $xWidth) DllStructSetData ($BMPInfo, "biHeight" , -$xHeight) DllStructSetData ($BMPInfo, "biPlanes" , 1) DllStructSetData ($BMPInfo, "biBitCount" , 32) DllStructSetData ($BMPInfo, "biCompression", $BI_RGB) DllStructSetData ($BMPInfo, "biSizeImage" , $xWidth * $xHeight) DllStructSetData ($BMPInfo, "biClrUsed" , 2^32) $BMPData = DllStructCreate("byte[" & ($xWidth * $xHeight) & "]") Local $pBMPData = DllStructGetPtr($BMPData) $hDDC_BMP = _GDI_CreateDIBitmap($hdcMem, DllStructGetPtr($BMPInfo), 0, $pBMPData, DllStructGetPtr($BMPInfo), $DIB_RGB_COLORS) ConsoleWrite("New Bitmap Handle: " & $hDDC_BMP & @CRLF & @CRLF) _WinAPI_SelectObject($hdcMem, $hBitmapOld) _WinAPI_DeleteDC ($hdcMem) _WinAPI_DeleteObject($hBmp_Source) If Not $hDDC_BMP Then Exit _WinAPI_GetObject($hDDC_BMP, DllStructGetSize($stBitmap), DllStructGetPtr($stBitmap)) ; Get Info about the new bitmap ConsoleWrite("Info about the new bitmap: " & @CRLF) For $i = 1 To 7 ConsoleWrite(DllStructGetData($stBitmap, $i) & @CRLF) Next ; EndOf DDC Bitmap Creation ; =========================================================== $nWidth = DllStructGetData($stBitmap, "bmWidth") $nHeight = DllStructGetData($stBitmap, "bmHeight") $hWindow = GUICreate("GDI BitBlt", $nWidth, $nHeight) GUISetState() ; ==================================================================== $hDC = _WinAPI_GetDC($hWindow) ; DC (Screen / Window) $hDC_Source = _WinAPI_CreateCompatibleDC($hDC) $hBmp_Prev = _WinAPI_SelectObject($hDC_Source, $hDDC_BMP) ; ===================================================================== _WinAPI_BitBlt($hDC, 0, 0, $nWidth, $nHeight, $hDC_Source, 0, 0, $SRCCOPY) ; BitBlt (Source to Buffer) _WinAPI_SelectObject($hDC_Source, $hBmp_Prev) _WinAPI_DeleteDC ($hDC_Source) _WinAPI_DeleteObject($hDDC_BMP) _WinAPI_ReleaseDC($hWindow, $hDC) While True If GUIGetMsg() = -3 Then ExitLoop WEnd Func _GDI_CreateDIBitmap($hDC, $lpbmih, $fdwInit, $lpbInit, $lpbmi, $fuUsage) Local $aResult = DllCall("Gdi32.dll", "ptr", "CreateDIBitmap", "ptr", $hDC, "ptr", $lpbmih, "DWORD", $fdwInit, "ptr", $lpbInit, "ptr", $lpbmi, "UINT", $fuUsage) If @error Then Return SetError(1, 0, 0) Return $aResult[0] EndFunc ;==>_GDI_CreateDIBitmap Info in Console. Thanks (AKA Grham)
-
Hello, to Valuater: I used your _ButtonHover() UDF for two of my projects and I must say it's very, very good. I like it (with XSkin and all - by the way also one of great scripts) Yesterday I got this new __ButtonHoverTag UDF and everything is OK. I have only one note for (some) people that can't get two different button "styles" to work. Why? This was my case, but only till I realized that the images for some buttons and these for other buttons had different extensions (gif - jpg). So I passed these $XBType to an Array (like the tags) and solved. Thank you for it! ...
-
Cool! Thanks
-
From MSDN: EM_LIMITTEXT Message Sets the text limit of an edit control. The text limit is the maximum amount of text, in TCHARs, that the user can type into the edit control. You can send this message to either an edit control or a rich edit control. For edit controls and Microsoft Rich Edit 1.0, bytes are used. For Rich Edit 2.0 and later, characters are used. ...
-
Yes, this is by default, but with this: _SendMessage($the_handel_ of_ your_ richedit, $EM_LIMITTEXT, $put_here_the_number_of_caracters_as_a_limit!, 0) you can increase it.
-
Thanks GtaSpider, I'm glad you (someone) like it and you are fully right that in a gui we see better what is it about. See in the first post the same with a "little changed" gui (using graphics as you proposed) ...
-
Imagine you have a color (RGB) and you want to know his hue, saturation and brightness and get it's complementary color, set the brightness or saturation for the same hue or other hues with the same B and S .... maybe it's not much usefull for the major part of you, but just for playing a little: #include<Array.au3> #include<Color.au3> #include<GUIConstantsEx.au3> #include <GuiSlider.au3> Global $Sel_Hue, $Sel_Saturation, $Sel_Brightness Const $WS_EX_COMPOSITED = 0x2000000 $GUI = GUICreate("", 440, 260, -1, -1, -1, $WS_EX_COMPOSITED) $gra1 = GUICtrlCreateGraphic(50, 20, 362, 20, $SS_SUNKEN) $gra2 = GUICtrlCreateGraphic(50, 70, 362, 20, $SS_SUNKEN) $gra3 = GUICtrlCreateGraphic(50, 120, 362, 20, $SS_SUNKEN) GUISetBkColor(0xc0c0c0) GUISetState() GUISetState(@SW_LOCK) $Color = 0x4383C0 $Start_Hue = _Color_GetHue($Color) $Start_Saturation = _Color_GetSaturation($Color) $Start_Brightness = _Color_GetBrightness($Color) $Start_Complementary = _Color_FindComplementary($Color) ConsoleWrite("Color: 0x" & Hex($Color, 6) & @CRLF) ConsoleWrite("Saturation: " & $Start_Saturation & " %" & @CRLF) ConsoleWrite("Brightness: " & $Start_Brightness & " %" & @CRLF) ConsoleWrite("Hue: " & $Start_Hue & " º" & @CRLF) ConsoleWrite("Complementary color: " & $Start_Complementary & @CRLF & @CRLF) GUICtrlCreateLabel("H:", 10, 23, 40, 15) GUICtrlCreateLabel("S:", 10, 73, 40, 15) GUICtrlCreateLabel("B:", 10, 123, 40, 15) For $x = 0 To 360 Step 2 $hue = _Color_SetHue($Color, $x) ConsoleWrite("Hue: " & $x & " º" & $hue & @CRLF) GUICtrlSetGraphic($gra1, $GUI_GR_COLOR, $hue, $hue) GUICtrlSetGraphic($gra1, $GUI_GR_RECT, $x, 0, 2, 20) Next GUICtrlSetGraphic($gra1, $GUI_GR_REFRESH) ConsoleWrite(" Saturation: Brightness:" & @CRLF) $Pass = 3.6 $Step = 0 $Diff = 0 For $x = 0 To 100 $sat = _Color_SetSaturation($Color, $x) $brigth = _Color_SetBrightness($Color, $x) ConsoleWrite($x & " % " & $sat & " " & $brigth & @CRLF) GUICtrlSetGraphic($gra2, $GUI_GR_COLOR, $sat, $sat) GUICtrlSetGraphic($gra3, $GUI_GR_COLOR, $brigth, $brigth) GUICtrlSetGraphic($gra2, $GUI_GR_RECT, Round($Diff), 0, 4, 20) GUICtrlSetGraphic($gra3, $GUI_GR_RECT, Round($Diff), 0, 4, 20) $Diff += $Pass If $x = 1 Then $Diff = 3 Next GUICtrlSetGraphic($gra2, $GUI_GR_REFRESH) GUICtrlSetGraphic($gra3, $GUI_GR_REFRESH) $Slider_H = _GUICtrlSlider_Create ($GUI, 45, 42, 372, 18, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE, $TBS_TOP)) _GUICtrlSlider_SetRange($Slider_H, 0, 360) _GUICtrlSlider_SetPos($Slider_H, $Start_Hue) $Slider_S = _GUICtrlSlider_Create ($GUI, 45, 92, 372, 18, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE, $TBS_TOP)) _GUICtrlSlider_SetRange($Slider_S, 0, 100) _GUICtrlSlider_SetPos($Slider_S, $Start_Saturation) $Slider_B = _GUICtrlSlider_Create ($GUI, 45, 142, 372, 18, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE, $TBS_TOP)) _GUICtrlSlider_SetRange($Slider_B, 0, 100) _GUICtrlSlider_SetPos($Slider_B, $Start_Brightness) $Original_Label = GUICtrlCreateLabel("H: " & $Start_Hue & @CRLF & "S: " & $Start_Saturation & @CRLF & "B: " & $Start_Brightness, 50, 185, 50, 60) GUICtrlCreateLabel("==>", 170, 200, 25, 15) $New_Label = GUICtrlCreateLabel("H: " & $Start_Hue & @CRLF & "S: " & $Start_Saturation & @CRLF & "B: " & $Start_Brightness, 280, 185, 50, 60) $Original = GUICtrlCreateGraphic(100, 190, 60, 35, $SS_SUNKEN) GUICtrlSetGraphic($Original, $GUI_GR_COLOR, $Color, $Color) GUICtrlSetGraphic($Original, $GUI_GR_RECT, 0, 0, 60, 35) GUICtrlSetGraphic($Original, $GUI_GR_REFRESH) GUICtrlCreateLabel("0x" & Hex($Color, 6), 103, 227, 54, 15) $New = GUICtrlCreateGraphic(200, 190, 60, 35, $SS_SUNKEN) GUICtrlSetGraphic($New, $GUI_GR_COLOR, $Color, $Color) GUICtrlSetGraphic($New, $GUI_GR_RECT, 0, 0, 60, 35) GUICtrlSetGraphic($New, $GUI_GR_REFRESH) $New_Input = GUICtrlCreateInput("0x" & Hex($Color, 6), 203, 227, 54, 15, "", $WS_EX_STATICEDGE) GUICtrlSetBkColor(-1, 0xc0c0c0) $Complementary = GUICtrlCreateButton("complementary" & @CRLF & "color?", 326, 190, 82, 30, $BS_MULTILINE) GUICtrlSetBkColor($Complementary, 0xc0c0c0) GUISetState(@SW_UNLOCK) While 1 $msg = GUIGetMsg() If $msg = -3 Then Exit If $msg = $Complementary Then _GUICtrlSlider_SetPos($Slider_H, Mod(($Start_Hue+180), 360)) $Read_H = _GUICtrlSlider_GetPos($Slider_H) $Read_S = _GUICtrlSlider_GetPos($Slider_S) $Read_B = _GUICtrlSlider_GetPos($Slider_B) If $Read_H <> $Sel_Hue Then $Sel_Hue = $Read_H $Sel_Color = _Color_SetHue($Color, $Sel_Hue) GUICtrlSetGraphic($New, $GUI_GR_COLOR, $Sel_Color, $Sel_Color) GUICtrlSetGraphic($New, $GUI_GR_RECT, 0, 0, 60, 35) GUICtrlSetGraphic($New, $GUI_GR_REFRESH) If _GUICtrlSlider_GetPos($Slider_S) <> $Start_Saturation Then _GUICtrlSlider_SetPos($Slider_S, $Start_Saturation) If _GUICtrlSlider_GetPos($Slider_B) <> $Start_Brightness Then _GUICtrlSlider_SetPos($Slider_B, $Start_Brightness) GUICtrlSetData($New_Label, "H: " & $Read_H & @CRLF & "S: " & $Start_Saturation & @CRLF & "B: " & $Start_Brightness) GUICtrlSetData($New_Input, $Sel_Color) ElseIf $Read_S <> $Sel_Saturation Then $Sel_Saturation = $Read_S $Sel_Color = _Color_SetSaturation($Color, $Sel_Saturation) GUICtrlSetGraphic($New, $GUI_GR_COLOR, $Sel_Color, $Sel_Color) GUICtrlSetGraphic($New, $GUI_GR_RECT, 0, 0, 60, 35) GUICtrlSetGraphic($New, $GUI_GR_REFRESH) If _GUICtrlSlider_GetPos($Slider_H) <> $Start_Hue Then _GUICtrlSlider_SetPos($Slider_H, $Start_Hue) If _GUICtrlSlider_GetPos($Slider_B) <> $Start_Brightness Then _GUICtrlSlider_SetPos($Slider_B, $Start_Brightness) GUICtrlSetData($New_Label, "H: " & $Start_Hue & @CRLF & "S: " & $Read_S & @CRLF & "B: " & $Start_Brightness) GUICtrlSetData($New_Input, $Sel_Color) ElseIf $Read_B <> $Sel_Brightness Then $Sel_Brightness = $Read_B $Sel_Color = _Color_SetBrightness($Color, $Sel_Brightness) GUICtrlSetGraphic($New, $GUI_GR_COLOR, $Sel_Color, $Sel_Color) GUICtrlSetGraphic($New, $GUI_GR_RECT, 0, 0, 60, 35) GUICtrlSetGraphic($New, $GUI_GR_REFRESH) If _GUICtrlSlider_GetPos($Slider_H) <> $Start_Hue Then _GUICtrlSlider_SetPos($Slider_H, $Start_Hue) If _GUICtrlSlider_GetPos($Slider_S) <> $Start_Saturation Then _GUICtrlSlider_SetPos($Slider_S, $Start_Saturation) GUICtrlSetData($New_Label, "H: " & $Start_Hue & @CRLF & "S: " & $Start_Saturation & @CRLF & "B: " & $Read_B) GUICtrlSetData($New_Input, $Sel_Color) EndIf Sleep(10) WEnd ;============================================================================================== Func _Color_SetSaturation($iColor, $nPercent) Local $aColorArray[4] $nPercent = 1 - ($nPercent / 100) $aColorArray[1] = _ColorGetRed($iColor) $aColorArray[2] = _ColorGetGreen($iColor) $aColorArray[3] = _ColorGetBlue($iColor) If $aColorArray[1] = $aColorArray[2] And $aColorArray[2] = $aColorArray[3] Then Return -1 $IndexMax = _ArrayMaxIndex($aColorArray, 1, 1) $IndexMin = _ArrayMinIndex($aColorArray, 1, 1) $IndexMid = 6 - ($IndexMax + $IndexMin) $aColorArray[$IndexMid] = ($aColorArray[$IndexMax] * ($aColorArray[$IndexMid] - $aColorArray[$IndexMin])) / ($aColorArray[$IndexMax] - $aColorArray[$IndexMin]) $aColorArray[$IndexMid] = Round($aColorArray[$IndexMid] + ($aColorArray[$IndexMax] - $aColorArray[$IndexMid]) * $nPercent, 0) $aColorArray[$IndexMin] = Round($aColorArray[$IndexMax] * $nPercent, 0) Return 0 & "x" & Hex($aColorArray[1], 2) & Hex($aColorArray[2], 2) & Hex($aColorArray[3], 2) EndFunc;==>_Color_SetSaturation Func _Color_GetSaturation($iColor) Local $aColorArray[4] $aColorArray[1] = _ColorGetRed($iColor) $aColorArray[2] = _ColorGetGreen($iColor) $aColorArray[3] = _ColorGetBlue($iColor) $IndexMax = _ArrayMaxIndex($aColorArray, 1, 1) $IndexMin = _ArrayMinIndex($aColorArray, 1, 1) $IndexMid = 6 - ($IndexMax + $IndexMin) Return Round((1 - $aColorArray[$IndexMin] / $aColorArray[$IndexMax]) * 100, 0) EndFunc;==>_Color_GetSaturation Func _Color_SetBrightness($iColor, $nPercent) Local $aColorArray[4] $nPercent = $nPercent / 100 $aColorArray[1] = _ColorGetRed($iColor) $aColorArray[2] = _ColorGetGreen($iColor) $aColorArray[3] = _ColorGetBlue($iColor) $IndexMax = _ArrayMaxIndex($aColorArray, 1, 1) $ActBrightness = $aColorArray[$IndexMax] / 255 For $i = 1 To 3 $aColorArray[$i] = Round($aColorArray[$i] * $nPercent / $ActBrightness, 0) Next Return 0 & "x" & Hex($aColorArray[1], 2) & Hex($aColorArray[2], 2) & Hex($aColorArray[3], 2) EndFunc;==>_Color_SetBrightness Func _Color_GetBrightness($iColor) Local $aColorArray[4] $aColorArray[1] = _ColorGetRed($iColor) $aColorArray[2] = _ColorGetGreen($iColor) $aColorArray[3] = _ColorGetBlue($iColor) $IndexMax = _ArrayMaxIndex($aColorArray, 1, 1) Return Round(($aColorArray[$IndexMax] / 255) * 100, 0) EndFunc;==>_Color_GetBrightness Func _Color_SetHue($iColor, $iHue) Local $aColorArray[4] $aColorArray[1] = _ColorGetRed($iColor) $aColorArray[2] = _ColorGetGreen($iColor) $aColorArray[3] = _ColorGetBlue($iColor) $iMax = _ArrayMax($aColorArray, 1, 1) $iMin = _ArrayMin($aColorArray, 1, 1) If $iHue >= 61 And $iHue <= 180 Then $IndexMax = 2 If $iHue < 120 Then $IndexMin = 3 $iMid = (($iMax - $iMin) * (120 - $iHue)) / 60 + $iMin Else $IndexMin = 1 $iMid = (($iMax - $iMin) * ($iHue - 120)) / 60 + $iMin EndIf ElseIf $iHue >= 181 And $iHue <= 299 Then $IndexMax = 3 If $iHue <= 240 Then $IndexMin = 1 $iMid = (($iMax - $iMin) * (240 - $iHue)) / 60 + $iMin Else $IndexMin = 2 $iMid = (($iMax - $iMin) * ($iHue - 240)) / 60 + $iMin EndIf ElseIf $iHue >= 300 Or $iHue <= 60 Then $IndexMax = 1 If $iHue <= 60 Then $IndexMin = 3 $iMid = (($iMax - $iMin) * ($iHue)) / 60 + $iMin Else $IndexMin = 2 $iMid = (($iMax - $iMin) * (360 - $iHue)) / 60 + $iMin EndIf EndIf $IndexMid = 6 - ($IndexMin + $IndexMax) $aColorArray[$IndexMin] = $iMin $aColorArray[$IndexMax] = $iMax $aColorArray[$IndexMid] = $iMid Return 0 & "x" & Hex($aColorArray[1], 2) & Hex($aColorArray[2], 2) & Hex($aColorArray[3], 2) EndFunc;==>_Color_SetHue Func _Color_GetHue($iColor) Local $aColorArray[4], $Hue $aColorArray[1] = _ColorGetRed($iColor) $aColorArray[2] = _ColorGetGreen($iColor) $aColorArray[3] = _ColorGetBlue($iColor) $IndexMax = _ArrayMaxIndex($aColorArray, 1, 1) $IndexMin = _ArrayMinIndex($aColorArray, 1, 1) $IndexMid = 6 - ($IndexMax + $IndexMin) $Lambda = ($aColorArray[$IndexMid] - $aColorArray[$IndexMin]) * 60 / ($aColorArray[$IndexMax] - $aColorArray[$IndexMin]) Switch $IndexMax Case 1 Switch $IndexMin Case 2 $Hue = 360 - $Lambda Case 3 $Hue = $Lambda EndSwitch Case 2 Switch $IndexMin Case 1 $Hue = 120 + $Lambda Case 3 $Hue = 120 - $Lambda EndSwitch Case 3 Switch $IndexMin Case 1 $Hue = 240 - $Lambda Case 2 $Hue = 240 + $Lambda EndSwitch EndSwitch Return Mod(Round($Hue, 0), 360) EndFunc;==>_Color_GetHue Func _Color_FindComplementary($iColor) Local $iHue = Mod(_Color_GetHue($iColor) + 180, 360) Return _Color_SetHue($iColor, $iHue) EndFunc;==>_Color_FindComplementary
-
Ok I get it now. It was only a coincidence that it worked with "OR". When I put a coma, this behavior disapears. Thanks Siao and Gary And sorry (my fault)
-
Hi! I have discovered something "strange" (for me) while using (registering) a wm_notify function for two controls. Details: In my exemple it was for a rich text box and (then) a toolbar in another (child) window. When I put within the "switch hWndFrom" first the "case" of a toolbar and then the "case" for the RTB, the RTB doesn't send any message. In reversed order : first the "case" of the TRB and then the "case" of the toolbar, both of them send messages. So my solution was only to "reorder" the "case's" within the "switch hWndFrom" and that's it. Used with 3.2.10. an exemple of illustration (now correct!!!): Func _WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tNMHDR, $event, $hwndFrom, $code, $i_idNew, $dwFlags, $lResult, $idFrom, $i_idOld Local $tNMTOOLBAR, $tNMTBHOTITEM $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hwndFrom = DllStructGetData($tNMHDR, "hWndFrom") $idFrom = DllStructGetData($tNMHDR, "IDFrom") $code = DllStructGetData($tNMHDR, "Code") Switch $hwndFrom Case $RichEdit Switch $code Case $EN_SELCHANGE Local $tSELCHANGE = DllStructCreate($tagSELCHANGE, $lParam) Local $cpMin = DllStructGetData($tSELCHANGE, 4) Local $cpMax = DllStructGetData($tSELCHANGE, 5) ConsoleWrite("Sel change:" & @LF & $cpMin & " --- " & $cpMax & @LF) EndSwitch Case $Typo_Toolbar, $Typo_Toolbar2 Switch $code Case $NM_LDOWN ;---------------------------------------------------------------------------------------------- $What_TB = $hWndFrom ConsoleWrite("$NM_LDOWN: Clicked Item: " & $iItem & " at index: " & _GUICtrlToolbar_CommandToIndex ($What_TB, $iItem) & @CRLF) ;---------------------------------------------------------------------------------------------- Case $TBN_HOTITEMCHANGE $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam) $i_idOld = DllStructGetData($tNMTBHOTITEM, "idOld") $i_idNew = DllStructGetData($tNMTBHOTITEM, "idNew") $iItem = $i_idNew $dwFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags") EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc;==>_WM_NOTIFY ??? Maybe it has to be like this.
-
may a toolbar clip images of any dimensions?
grham replied to grham's topic in AutoIt GUI Help and Support
Thanks! It works with an image list. -
Hello, have you tried make a "simple" toolbar (with 3.2.10) with your proper bmp's? I don't find out where there might be a restriction, but a bmp of any resolution and dimensions get cropped (right + bottom) on a toolbar button. I have tried to set the size of the buttons, the size of the bitmaps and set it as autosize. Setting the button size seems not having an effect on it (?). For example: Just make a small red bmp, (ex.: 24 x 22 pixels, res: 72 ppp) with black borders and save it with 16 bits depth Func _TypoPalette_Create() $Palette_GUI = GUICreate("Paleta", 200, 100, -1, -1) GUISetBkColor(0xa2a2a2, $Palette_GUI) ;WinSetOnTop($Palette_GUI, "", 1) ;$hReBar = _GUICtrlReBar_Create($Palette_GUI, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_BANDBORDERS)) $Typo_Toolbar = _GUICtrlToolbar_Create ($Palette_GUI);, $BTNS_AUTOSIZE) _GUICtrlToolbar_AddButtonSep($Typo_Toolbar) ;_GUICtrlToolbar_SetButtonWidth($Typo_Toolbar, 30, 32) ;_GUICtrlToolbar_SetButtonSize($Typo_Toolbar, 36, 38) _GUICtrlToolbar_SetBitmapSize($Typo_Toolbar, 48, 46) $Image1 = _GUICtrlToolbar_LoadBitmap($Typo_Toolbar, @ScriptDir & "\Res\Negrita.bmp") $Image2 = _GUICtrlToolbar_LoadBitmap($Typo_Toolbar, @ScriptDir & "\Res\proba.bmp") _GUICtrlToolbar_AddButton ($Typo_Toolbar, $idNegr, 0, 0, $BTNS_CHECK) _GUICtrlToolbar_AddButton ($Typo_Toolbar, $idCurs, 1, 0, $BTNS_CHECK) GUISetState() EndFunc If you need more, I will put it. ???
-
ToyleY: "I don't have Microsoft office installed - how come the rich text stuff works?" ToyleY, could you look please (only if you want to and have time ....) and try to find out which of your applications could have installed "rich edit"? I would then try to find out the "minimum" files that are needed to get BetaPad to work? (comparing it with what ms office installs) thanks (if not, doesn't matter) greetings!
-
Multi-colour GUICtrlCreateLabel()?
grham replied to jacQues's topic in AutoIt General Help and Support
If it helps you, look here for Rich Edit Control. You can simulate a multicolor lable: Create a one-line richedit control and set it's background to any color of your choise and the font color as you like. greetings -
got it! After having to understand that the res files hade to be in the temp dir (your exemple - post 1 unchanged), ==> with: #AutoIt3Wrapper_Res_File_Add="%scriptdir%\ etc. the resources can be in the script dir. It's a very good work! Thank you Zedna.
-
StringRegExpReplace vs. StringRegExp (is this a feature ?)
grham replied to grham's topic in AutoIt General Help and Support
I'm sorry Mega (my fault) your example Works as expected too!!! (Entschuldigung) and Thank you Very much -
StringRegExpReplace vs. StringRegExp (is this a feature ?)
grham replied to grham's topic in AutoIt General Help and Support
OK, I got it This works exactly as expected ("lack" in my knowledge) Siao: Thank you! Mega: Ooops (btw., ich bin nicht deutsch, Ich kenne Dich nur aus dem deutschen Forum, spreche ein bisschen Deutsch) Danke für "Samstag"!!!!! -
StringRegExpReplace vs. StringRegExp (is this a feature ?)
grham replied to grham's topic in AutoIt General Help and Support
For example: $String = "Montag,Dienstag,Mittwoch, Donnerstag,Freitag,Samstag,Sonntag" Try to put a whitespace after any comma with my "example" so that you don't get two whitespaces between Mittwoch and Donnerstag. Not: ..., Mittwoch, 'white' 'white' Donnerstag, ..." ==> "Montag, Dienstag, M ...." I know it can be done in a different way. -
Hello, maybe I don't see anything or I'm doing something wrong? This is a pattern that matches - correctly - a comma (,) in a string before a non white space character. $Res = StringRegExp($String, '(,)(?:\H)', 3) Non obstant I can't use the same pattern for StringRegExpReplace: (HelpFile?) This matches the comma (,) and "non capturing (?:\H)" (both of them) $String = StringRegExpReplace($String, '(,)(?:\H)', ', ', 0) I imagine a workaround to accomplish my goal (would not be so hard) (replace all commas only before a non white space character with a comma + white space) but could someone tell me, please, if it's a feature of StringRegExpReplace because I didn't find anything "on the topic"? Than you.
-
???????????? Run("D:\Games\Counter-Strike\hl.exe") ? See AutoItHelp Are you sure, you read the downloaded scripts before you run them?
-
Try this if you want to: $File = "GIMPPortable.exe" $Dir = "c:" MsgBox(1, "", _FileFind($Dir, $File)) Func _FileFind($sDir, $sFile) Dim $HoldPath[1], $F_HoldPath[1] $HoldPath[0] = $sDir $z = 0 While 1 While 1 $sFound = _SubDir($HoldPath[$z], $sFile, $F_HoldPath) If $sFound Then Return $sFound If $z = UBound($HoldPath)-1 Then $HoldPath = $F_HoldPath ExitLoop EndIf $z += 1 WEnd If UBound($HoldPath) = 1 Then ExitLoop $z = 1 Dim $F_HoldPath[1] WEnd Return 0 EndFunc Func _SubDir($sDir, $sFile, ByRef $F_HoldPath) $n_Search = FileFindFirstFile($sDir & "\*.*") If $n_Search = -1 Then Return While 1 $n_File = FileFindNextFile($n_Search) If @error Then ExitLoop If $n_File = $sFile Then Return $sDir & "\" & $n_File If StringInStr(FileGetAttrib($sDir & "\" & $n_File), "D") Then ReDim $F_HoldPath[UBound($F_HoldPath)+1] $F_HoldPath [UBound($F_HoldPath)-1] = $sDir & "\" & $n_File EndIf Wend FileClose($n_Search) Return 0 EndFunc
-
very good!!!! I have this because of my curiosity. I'm still looking for the scite window after minimizing it within the firefox window. jaja
-
rich edit control (another?) - text format, color, links ...
grham replied to grham's topic in AutoIt Example Scripts
just don't put the final 0 (i know it's not documented, because I used it instead of writing 4 lines to change the font) Expl.: 1. par. 4 numbers (0,1) in this order: bold, italic, underline, strikeout or -1 = no changes 2. par. font color (or -1 = no changes) 3. par. font background color (or -1 = no changes) 4. par. font name 5. par. font size 6. par. optional: 1 (default - selection), 0 whole control -
rich edit control (another?) - text format, color, links ...
grham replied to grham's topic in AutoIt Example Scripts
What is exactly what you change? Color, size, fontname .....? and how do you change it?