Leaderboard
Popular Content
Showing content with the highest reputation on 02/18/2016 in all areas
-
This is English-language forum. Please translate non English statements (EDIT: I meant strings/words).1 point
-
check array empty
rodiney reacted to InunoTaishou for a topic
Are you checking if the whole array is empty? #include <Array.au3> Global const $SORT_DESCENDING = 1 Global $array[] = [3, 2, 1, 5, 1, "Test", "String", 99, 3, 0] Global $array2[] = [0, 0, 0, 0, "", "", 0, 0] _ArraySort($array, $SORT_DESCENDING) _ArraySort($array2, $SORT_DESCENDING) If ($array[0] or StringLen($array)) Then MsgBox("", "", "The first array is not empty") Else MsgBox("", "", "The first array is empty") EndIf If ($array2[0] or StringLen($array2)) Then MsgBox("", "", "The second array is not empty") Else MsgBox("", "", "The second array is empty") EndIf1 point -
Image animation element running continuously
Rechard_Long reacted to UEZ for a topic
You have to modify Icons.au3: #Region Header #cs Title: Support for Icons UDF Library for AutoIt3 Filename: Icons.au3 Description: Additional and corrected functions for working with icons Author: Yashied Version: 1.8 Requirements: AutoIt v3.3 +, Developed/Tested on WindowsXP Pro Service Pack 2 Uses: Constants.au3, GDIPlus.au3, WinAPI.au3, WindowsConstants.au3 Notes: - http://www.autoitscript.com/forum/index.php?showtopic=92675 Available functions: _SetCombineBkIcon _SetIcon _SetImage Added special for Handles (HIcon and HBitmap): _SetHIcon _SetHImage Not documented (Internal) functions: _Icons_Bitmap_Crop _Icons_Bitmap_CreateFromIcon _Icons_Bitmap_CreateSolidBitmap _Icons_Bitmap_Duplicate _Icons_Bitmap_GetSize _Icons_Bitmap_IsAlpha _Icons_Bitmap_IsHBitmap _Icons_Bitmap_Load _Icons_Bitmap_Resize _Icons_Control_CheckHandle _Icons_Control_CheckSize _Icons_Control_Enum _Icons_Control_FitTo _Icons_Control_GetRect _Icons_Control_GetSize _Icons_Control_Invalidate _Icons_Control_SetImage _Icons_Control_Update _Icons_Icon_Duplicate _Icons_Icon_Extract _Icons_Icon_CreateFromBitmap _Icons_Icon_GetSize _Icons_Icon_Merge _Icons_System_GetColor _Icons_System_SwitchColor Example: #Include <GUIConstantsEx.au3> #Include <Icons.au3> Global Const $sPng = RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir') & '\Examples\GUI\Advanced\Images\Torus.png' Global Const $sJpg = @TempDir & '\~wallpaper.jpg' Global Const $sGreen = @TempDir & '\~green.png' Global Const $sRed = @TempDir & '\~red.png' Global Const $sLogo = @TempDir & '\~logo.png' Example1() Example2() Example3() Example4() Example5() Example6() Example7() Func Example1() GUICreate('Example1', 204, 108) $Icon1 = GUICtrlCreateIcon('', 0, 30, 38, 32, 32) $Icon2 = GUICtrlCreateIcon('', 0, 88, 38, 32, 32) $Icon3 = GUICtrlCreateIcon('', 0, 146, 38, 32, 32) GUISetState() _SetCombineBkIcon($Icon1, -1, @SystemDir & '\shell32.dll', 70, 32, 32, @SystemDir & '\shell32.dll', 22, 24, 24, 0, 8) _SetCombineBkIcon($Icon2, -1, @SystemDir & '\shell32.dll', 3, 32, 32, @SystemDir & '\shell32.dll', 28, 32, 32) _SetCombineBkIcon($Icon3, -1, @SystemDir & '\shell32.dll', 220, 32, 32, @SystemDir & '\shell32.dll', 29, 32, 32) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example1 Func Example2() GUICreate('Example2', 216, 128) $Icon = GUICtrlCreateIcon('', 0, 40, 40, 48, 48) GUICtrlCreateIcon(@WindowsDir & '\explorer.exe', 0, 128, 40, 48, 48) GUISetState() _SetIcon($Icon, @WindowsDir & '\explorer.exe', 0, 48, 48) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example2 Func Example3() GUICreate('Example3', 715, 388) $Pic1 = GUICtrlCreatePic('', 10, 10, 386, 368) $Pic2 = GUICtrlCreatePic('', 406, 10, 193, 184) $Pic3 = GUICtrlCreatePic('', 609, 10, 96, 92) GUISetState() _SetImage($Pic1, $sPng) _SetImage($Pic2, $sPng) _SetImage($Pic3, $sPng) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example3 Func Example4() GUICreate('Example4', 253, 244) $Pic1 = GUICtrlCreatePic('', 10, 10, 193, 184) $Pic2 = GUICtrlCreatePic('', 60, 60, 193, 184) GUISetState() _SetImage($Pic2, $sPng) _SetImage($Pic1, $sPng) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example4 Func Example5() Local $aIndex[10] = [4, 13, 23, 31, 86, 104, 130, 150, 168, 170] GUICreate('Example5', 600, 400) $Pic = GUICtrlCreatePic('', 0, 0, 600, 400) For $i = 1 To UBound($aIndex) GUICtrlCreatePic('', Random(0, 600 - 48, 1), Random(0, 400 - 48, 1), 48, 48) $hIcon = _Icons_Icon_Extract(@SystemDir & '\shell32.dll', $aIndex[$i - 1], 48, 48) $hBitmap = _Icons_Bitmap_CreateFromIcon($hIcon) _SetHImage($Pic + $i, $hBitmap) _WinAPI_DeleteObject($hBitmap) _WinAPI_DestroyIcon($hIcon) Next GUISetState() InetGet('http://dota.ru/3d/big/p324_42.jpg', $sJpg) $hBitmap = _Icons_Bitmap_Load($sJpg) $hArea = _Icons_Bitmap_Crop($hBitmap, 420, 320, 600, 400) _SetHImage($Pic, $hArea) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hArea) FileDelete($sJpg) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example5 Func Example6() GUICreate('Example6', 800, 500) $Background = GUICtrlCreatePic('', 0, 0, 800, 500) GUICtrlSetState(-1, $GUI_DISABLE) $Button = GUICtrlCreateButton('Test', 355, 460, 90, 23) $Pic1 = GUICtrlCreatePic('', 102, 122, 256, 256) $Pic2 = GUICtrlCreatePic('', 442, 122, 256, 256) GUISetState() InetGet('http://autoit.rv.ua/files/Pictures/icons_ex_back.jpg', $sJpg) InetGet('http://autoit.rv.ua/files/Pictures/icons_ex_green.png', $sGreen) InetGet('http://autoit.rv.ua/files/Pictures/icons_ex_red.png', $sRed) _SetImage($Background, $sJpg) $hGreen = _Icons_Bitmap_Load($sGreen) $hRed = _Icons_Bitmap_Load($sRed) _SetHImage($Pic1, $hRed) _SetHImage($Pic2, $hRed) FileDelete($sJpg) FileDelete($sGreen) FileDelete($sRed) $pCtrlID = 0 While 1 $Cursor = GUIGetCursorInfo() If @error Then ContinueLoop EndIf $nCtrlID = $Cursor[4] If $nCtrlID <> $pCtrlID Then Switch $pCtrlID Case $Pic1 _SetHImage($Pic1, $hRed) Case $Pic2 _SetHImage($Pic2, $hRed, -1) EndSwitch Switch $nCtrlID Case $Pic1 _SetHImage($Pic1, $hGreen) Case $Pic2 _SetHImage($Pic2, $hGreen, -1) EndSwitch $pCtrlID = $nCtrlID EndIf $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE ExitLoop Case $Button GUICtrlSetState($Button, $GUI_DISABLE) For $i = 1 To 50 GUIGetMsg() _SetHImage($Pic1, $hGreen) _SetHImage($Pic2, $hGreen, -1) Sleep(50) _SetHImage($Pic1, $hRed) _SetHImage($Pic2, $hRed, -1) Sleep(50) Next GUICtrlSetState($Button, $GUI_ENABLE) EndSwitch WEnd GUIDelete() EndFunc ;==>Example6 Func Example7() GUICreate('Example7', 400, 93) $Pic = GUICtrlCreatePic('', 0, 0, 400, 93) $hIcon = _Icons_Icon_Extract(@SystemDir & '\shell32.dll', 86, 24, 24) $hBitmap = _Icons_Bitmap_CreateFromIcon($hIcon) For $i = 1 To 5 GUICtrlCreatePic('', 258 + ($i - 1) * 28, 12, 24, 24) _SetHImage($Pic + $i, $hBitmap) Next _WinAPI_DeleteObject($hBitmap) _WinAPI_DestroyIcon($hIcon) GUISetState() InetGet('http://www.autoitscript.com/forum/public/style_images/autoit/logo.png', $sLogo) $hBitmap = _Icons_Bitmap_Load($sLogo) $hArea = _Icons_Bitmap_Crop($hBitmap, 0, 7, 400, 93) _SetHImage($Pic, $hArea) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hArea) FileDelete($sLogo) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example7 #ce #Include-once #Include <Constants.au3> #Include <GDIPlus.au3> #Include <WinAPI.au3> #Include <WindowsConstants.au3> #EndRegion Header #Region Local Variables and Constants Global Const $__SS_BITMAP = 0x0E Global Const $__SS_ICON = 0x03 Global Const $__STM_SETIMAGE = 0x0172 Global Const $__STM_GETIMAGE = 0x0173 #EndRegion Local Variables and Constants #Region Public Functions ; #FUNCTION# ==================================================================================================================== ; Name...........: _SetCombineBkIcon ; Description....: Creates the icon from a combination of the specified two icons on solid background and sets it to use for a control. ; Syntax.........: _SetCombineBkIcon ( $hWnd, $iBackground, $sIcon1 [, $iIndex1 [, $iWidth1 [, $iHeight1 [, $sIcon2 [, $iIndex2 [, $iWidth2 [, $iHeight2 [, $iX [, $iY [, $hOverlap]]]]]]]]]] ) ; Parameters.....: $hWnd - The control identifier (controlID) or handle as returned by a GUICtrlCreateIcon() function. ; $iBackground - Value of the color (in RGB) for background. If the value of this parameter is (-1), the color will match ; background color of the window that contains the control. ; $sIcon1 - Name of the file containing the icon for the back icon. ; $iIndex1 - Index of the icon in the file, for the back icon. ; $iWidth1 - Width of the back icon. (-1) - determined from the system metrics for large icon. ; $iHeight1 - Height of the back icon. (-1) - determined from the system metrics for large icon. ; $sIcon2 - Name of the file containing the icon for the top icon. ; $iIndex2 - Index of the icon in the file, for the top icon. ; $iWidth2 - Width of the top icon. ; $iHeight2 - Height of the back icon. ; $iX - X value of the upper-left corner of the top icon. ; $iY - Y value of the upper-left corner of the top icon. ; $hOverlap - The control identifier (controlID) or handle to the control that overlaps with the $hWnd control. ; If this parameter is 0 (flicker reducing is disable) the control will be redrawn by sending WM_ERASEBKGND ; and WM_NCPAINT messages to the parent window. If $hOverlap is (-1) the WM_... messages will be sent to ; all top and bottom-level controls. Note that method works only in case of a complete overlapping ; controls, such as icon is placed completely on top of the Tab. If $hOverlap is handle to the control ; the WM_... messages will be sent to this control only. All top-level controls will be ignored. ; Return values..: Success - 1 ; Failure - 0 and sets the @error flag to non-zero. ; Author.........: Yashied ; Modified.......: ; Remarks........: Created by using this function icon is always placed on a solid background (NOT transparent). Use value (-1) to automatically ; determine the background color of the current window. The window should not be a hidden state. The function uses GDI+, ; so if you often call this function, call the _GDIPlus_Startup() at the top of your code is a good idea. ; Related........: ; Link...........: ; Example........: Yes ; =============================================================================================================================== Func _SetCombineBkIcon($hWnd, $iBackground, $sIcon1, $iIndex1 = 0, $iWidth1 = -1, $iHeight1 = -1, $sIcon2 = '', $iIndex2 = 0, $iWidth2 = -1, $iHeight2 = -1, $iX = 0, $iY = 0, $hOverlap = 0) $hWnd = _Icons_Control_CheckHandle($hWnd) If $hWnd = 0 Then Return SetError(1, 0, 0) EndIf Local $hParent If $iBackground < 0 Then $hParent = _WinAPI_GetParent($hWnd) If (BitAND(WinGetState($hParent), 2)) And (Not BitAND(WinGetState($hParent), 16)) Then $iBackground = _Icons_System_GetColor($hParent) EndIf If $iBackground < 0 Then $iBackground = _Icons_System_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)) EndIf EndIf _Icons_Control_CheckSize($hWnd, $iWidth1, $iHeight1) _Icons_Control_CheckSize($hWnd, $iWidth2, $iHeight2) Local $hBack = _Icons_Icon_Extract($sIcon1, $iIndex1, $iWidth1, $iHeight1) Local $hFront = _Icons_Icon_Extract($sIcon2, $iIndex2, $iWidth2, $iHeight2) Local $hIcon = _Icons_Icon_Merge($iBackground, $hBack, $hFront, $iX, $iY, $iWidth1, $iHeight1) If $hBack Then _WinAPI_DestroyIcon($hBack) EndIf If $hFront Then _WinAPI_DestroyIcon($hFront) EndIf If Not ($hOverlap < 0) Then $hOverlap = _Icons_Control_CheckHandle($hOverlap) EndIf If Not _Icons_Control_SetImage($hWnd, $hIcon, $IMAGE_ICON, $hOverlap) Then If $hIcon Then _WinAPI_DestroyIcon($hIcon) EndIf Return SetError(1, 0, 0) EndIf Return 1 EndFunc ;==>_SetCombineBkIcon ; #FUNCTION# ==================================================================================================================== ; Name...........: _SetIcon ; Description....: Sets the icon to use for a control. ; Syntax.........: _SetIcon ( $hWnd, $sIcon [, $iIndex [, $iWidth [, $iHeight [, $hOverlap]]]] ) ; Parameters.....: $hWnd - The control identifier (controlID) or handle as returned by a GUICtrlCreateIcon() function. ; $sIcon - Name of the file containing the icon. ; $iIndex - Index of the icon in the file. ; $iWidth - Width of the icon. (-1) - determined from the system metrics for large icon. ; $iHeight - Height of the icon. (-1) - determined from the system metrics for large icon. ; $hOverlap - The control identifier (controlID) or handle to the control that overlaps with the $hWnd control. ; If this parameter is 0 (flicker reducing is disable) the control will be redrawn by sending WM_ERASEBKGND ; and WM_NCPAINT messages to the parent window. If $hOverlap is (-1) the WM_... messages will be sent to ; all top and bottom-level controls. Note that method works only in case of a complete overlapping ; controls, such as icon is placed completely on top of the Tab. If $hOverlap is handle to the control ; the WM_... messages will be sent to this control only. All top-level controls will be ignored. ; Return values..: Success - 1 ; Failure - 0 and sets the @error flag to non-zero. ; Author.........: Yashied ; Modified.......: ; Remarks........: This function is similar to GUICtrlSetImage(), but it can work correctly with icons of arbitrary size. See example 2 ; from this library. ; Related........: ; Link...........: ; Example........: Yes ; =============================================================================================================================== Func _SetIcon($hWnd, $sIcon, $iIndex = 0, $iWidth = -1, $iHeight = -1, $hOverlap = 0) $hWnd = _Icons_Control_CheckHandle($hWnd) If $hWnd = 0 Then Return SetError(1, 0, 0) EndIf _Icons_Control_CheckSize($hWnd, $iWidth, $iHeight) Local $hIcon = _Icons_Icon_Extract($sIcon, $iIndex, $iWidth, $iHeight) If Not ($hOverlap < 0) Then $hOverlap = _Icons_Control_CheckHandle($hOverlap) EndIf If Not _Icons_Control_SetImage($hWnd, $hIcon, $IMAGE_ICON, $hOverlap) Then If $hIcon Then _WinAPI_DestroyIcon($hIcon) EndIf Return SetError(1, 0, 0) EndIf Return 1 EndFunc ;==>_SetIcon ; #FUNCTION# ==================================================================================================================== ; Name...........: _SetImage ; Description....: Sets the image to use for a control. ; Syntax.........: _SetImage ( $hWnd, $sImage [, $hOverlap] ) ; Parameters.....: $hWnd - The control identifier (controlID) or handle as returned by a GUICtrlCreatePic() function. ; $sImage - Name of the file containing the image. ; $hOverlap - The control identifier (controlID) or handle to the control that overlaps with the $hWnd control. ; If this parameter is 0 (flicker reducing is disable) the control will be redrawn by sending WM_ERASEBKGND ; and WM_NCPAINT messages to the parent window. If $hOverlap is (-1) the WM_... messages will be sent to ; all top and bottom-level controls. Note that method works only in case of a complete overlapping ; controls, such as icon is placed completely on top of the Tab. If $hOverlap is handle to the control ; the WM_... messages will be sent to this control only. All top-level controls will be ignored. ; Return values..: Success - 1 ; Failure - 0 and sets the @error flag to non-zero. ; Author.........: Yashied ; Modified.......: ; Remarks........: This function is similar to GUICtrlSetImage(), but it can work with PNG, TIFF, etc image type. If the size of ; image and control are different, image will be resizing (using an antialiasing) to the control. The function uses ; GDI+, so if you often call this function, call the _GDIPlus_Startup() at the top of your code is a good idea. ; Related........: ; Link...........: ; Example........: Yes ; =============================================================================================================================== Func _SetImage($hWnd, $sImage, $hOverlap = 0) $hWnd = _Icons_Control_CheckHandle($hWnd) If $hWnd = 0 Then Return SetError(1, 0, 0) EndIf Local $Result, $hImage, $hBitmap, $hFit _GDIPlus_Startup() $hImage = _GDIPlus_BitmapCreateFromFile($sImage) $hFit = _Icons_Control_FitTo($hWnd, $hImage) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hFit) _GDIPlus_ImageDispose($hFit) _GDIPlus_Shutdown() If Not ($hOverlap < 0) Then $hOverlap = _Icons_Control_CheckHandle($hOverlap) EndIf $Result = _Icons_Control_SetImage($hWnd, $hBitmap, $IMAGE_BITMAP, $hOverlap) If $Result Then $hImage = _SendMessage($hWnd, $__STM_GETIMAGE, $IMAGE_BITMAP, 0) If (@error) Or ($hBitmap = $hImage) Then $hBitmap = 0 EndIf EndIf If $hBitmap Then _WinAPI_DeleteObject($hBitmap) EndIf Return SetError(1 - $Result, 0, $Result) EndFunc ;==>_SetImage ; #FUNCTION# ==================================================================================================================== ; Name...........: _SetHIcon ; Description....: Sets the icon object (HIcon) to use for a control. ; Syntax.........: _SetHIcon ( $hWnd, $hIcon [, $hOverlap] ) ; Parameters.....: $hWnd - The control identifier (controlID) or handle as returned by a GUICtrlCreateIcon() function. ; $hIcon - The handle to a icon (HIcon). If this value is 0, the function just release the control of the ; previous icons. ; $hOverlap - The control identifier (controlID) or handle to the control that overlaps with the $hWnd control. ; If this parameter is 0 (flicker reducing is disable) the control will be redrawn by sending WM_ERASEBKGND ; and WM_NCPAINT messages to the parent window. If $hOverlap is (-1) the WM_... messages will be sent to ; all top and bottom-level controls. Note that method works only in case of a complete overlapping ; controls, such as icon is placed completely on top of the Tab. If $hOverlap is handle to the control ; the WM_... messages will be sent to this control only. All top-level controls will be ignored. ; Return values..: Success - 1 ; Failure - 0 and sets the @error flag to non-zero. ; Author.........: Yashied ; Modified.......: ; Remarks........: This function works like SetIcon(), but only for the icon handles. The function copies the icon in the control, ; and if the icon is no longer needed, it is necessary to release the resources associated with the icon by ; using the _WinAPI_DestroyIcon() function. ; Related........: ; Link...........: ; Example........: Yes ; =============================================================================================================================== Func _SetHIcon($hWnd, $hIcon, $hOverlap = 0) $hWnd = _Icons_Control_CheckHandle($hWnd) If $hWnd = 0 Then Return SetError(1, 0, 0) EndIf If Not ($hOverlap < 0) Then $hOverlap = _Icons_Control_CheckHandle($hOverlap) EndIf $hIcon = _Icons_Icon_Duplicate($hIcon) If Not _Icons_Control_SetImage($hWnd, $hIcon, $IMAGE_ICON, $hOverlap) Then If $hIcon Then _WinAPI_DestroyIcon($hIcon) EndIf Return SetError(1, 0, 0) EndIf Return 1 EndFunc ;==>_SetHIcon ; #FUNCTION# ==================================================================================================================== ; Name...........: _SetHImage ; Description....: Sets the bitmap object (HBitmap) to use for a control. ; Syntax.........: _SetHImage ( $hWnd, $hBitmap [, $hOverlap] ) ; Parameters.....: $hWnd - The control identifier (controlID) or handle as returned by a GUICtrlCreatePic() function. ; $hBitmap - The handle to a bitmap (HBitmap). If this value is 0, the function just release the control of the ; previous image. ; $hOverlap - The control identifier (controlID) or handle to the control that overlaps with the $hWnd control. ; If this parameter is 0 (flicker reducing is disable) the control will be redrawn by sending WM_ERASEBKGND ; and WM_NCPAINT messages to the parent window. If $hOverlap is (-1) the WM_... messages will be sent to ; all top and bottom-level controls. Note that method works only in case of a complete overlapping ; controls, such as icon is placed completely on top of the Tab. If $hOverlap is handle to the control ; the WM_... messages will be sent to this control only. All top-level controls will be ignored. ; Return values..: Success - 1 ; Failure - 0 and sets the @error flag to non-zero. ; Author.........: Yashied ; Modified.......: ; Remarks........: This function works like SetImage(), but only for the bitmap handles, and does not support resizing. If necessary, ; use _GDIPlus_BitmapCreateHBITMAPFromBitmap() function to craete HBitmap from image object (HImage). The function copies ; the bitmap in the control, and if the bitmap is no longer needed, it is necessary to release the resources ; associated with the bitmap by using the _WinAPI_DeleteObject() function. ; Related........: ; Link...........: ; Example........: Yes ; =============================================================================================================================== Func _SetHImage($hWnd, $hBitmap, $hOverlap = 0) $hWnd = _Icons_Control_CheckHandle($hWnd) If $hWnd = 0 Then Return SetError(1, 0, 0) EndIf Local $Result, $hImage If Not ($hOverlap < 0) Then $hOverlap = _Icons_Control_CheckHandle($hOverlap) EndIf $hBitmap = _Icons_Bitmap_Duplicate($hBitmap) $Result = _Icons_Control_SetImage($hWnd, $hBitmap, $IMAGE_BITMAP, $hOverlap) If $Result Then $hImage = _SendMessage($hWnd, $__STM_GETIMAGE, $IMAGE_BITMAP, 0) If (@error) Or ($hBitmap = $hImage) Then $hBitmap = 0 EndIf EndIf If $hBitmap Then _WinAPI_DeleteObject($hBitmap) EndIf Return SetError(1 - $Result, 0, $Result) EndFunc ;==>_SetHImage #EndRegion Public Functions #Region Internal Functions Func _Icons_Bitmap_Crop($hBitmap, $iX, $iY, $iWidth, $iHeight) If Not _Icons_Bitmap_IsHBitmap($hBitmap) Then Return 0 EndIf Local $hDC, $hDestDC, $SrcDC, $hBmp $hDC = _WinAPI_GetDC(0) $hDestDC = _WinAPI_CreateCompatibleDC($hDC) $hBmp = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight) _WinAPI_SelectObject($hDestDC, $hBmp) $hSrcDC = _WinAPI_CreateCompatibleDC($hDC) _WinAPI_SelectObject($hSrcDC, $hBitmap) _WinAPI_ReleaseDC(0, $hDC) If Not _WinAPI_BitBlt($hDestDC, 0, 0, $iWidth, $iHeight, $hSrcDC, $iX, $iY, $SRCCOPY) Then _WinAPI_DeleteObject($hBmp) $hBmp = 0 EndIf _WinAPI_DeleteDC($hDestDC) _WinAPI_DeleteDC($hSrcDC) Return $hBmp EndFunc ;==>_Icons_Bitmap_Crop Func _Icons_Bitmap_CreateFromIcon($hIcon) Local $tICONINFO = DllStructCreate($tagICONINFO) Local $Ret, $hBitmap $Ret = DllCall('user32.dll', 'int', 'GetIconInfo', 'ptr', $hIcon, 'ptr', DllStructGetPtr($tICONINFO)) If (@error) Or ($Ret[0] = 0) Then Return 0 EndIf $hBitmap = _Icons_Bitmap_Duplicate(DllStructGetData($tICONINFO, 5), 1) If Not _Icons_Bitmap_IsAlpha($hBitmap) Then _GDIPlus_Startup() _WinAPI_DeleteObject($hBitmap) $Ret = DllCall($__g_hGDIPDll, 'int', 'GdipCreateBitmapFromHICON', 'ptr', $hIcon, 'ptr*', 0) If (Not @error) And ($Ret[0] = 0) Then $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Ret[2]) _GDIPlus_ImageDispose($Ret[2]) Else $hBitmap = 0 EndIf _GDIPlus_Shutdown() EndIf Return $hBitmap EndFunc ;==>_Icons_Bitmap_CreateFromIcon Func _Icons_Bitmap_CreateSolidBitmap($iColor, $iWidth, $iHeight) Local $hDC, $hMemDC, $tRect, $hBitmap, $hBrush, $tRect = DllStructCreate($tagRECT) DllStructSetData($tRect, 1, 0) DllStructSetData($tRect, 2, 0) DllStructSetData($tRect, 3, $iWidth) DllStructSetData($tRect, 4, $iHeight) $hDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight) _WinAPI_SelectObject($hMemDC, $hBitmap) _WinAPI_ReleaseDC(0, $hDC) $hBrush = _WinAPI_CreateSolidBrush(_Icons_System_SwitchColor($iColor)) If Not _WinAPI_FillRect($hMemDC, DllStructGetPtr($tRect), $hBrush) Then _WinAPI_DeleteObject($hBitmap) $hBitmap = 0 EndIf _WinAPI_DeleteObject($hBrush) _WinAPI_DeleteDC($hMemDC) Return $hBitmap EndFunc ;==>_Icons_Bitmap_CreateSolidBitmap Func _Icons_Bitmap_Duplicate($hBitmap, $fDelete = 0) If $fDelete Then $fDelete = $LR_COPYDELETEORG EndIf Local $Ret = DllCall('user32.dll', 'hwnd', 'CopyImage', 'ptr', $hBitmap, 'int', 0, 'int', 0, 'int', 0, 'int', BitOR($LR_CREATEDIBSECTION, $fDelete)) If (@error) Or ($Ret[0] = 0) Then Return SetError(1, 0, 0) EndIf Return $Ret[0] EndFunc ;==>_Icons_Bitmap_Duplicate Func _Icons_Bitmap_GetSize($hBitmap) If Not _Icons_Bitmap_IsHBitmap($hBitmap) Then Return 0 EndIf Local $tObj = DllStructCreate('long Type;long Width;long Height;long WidthBytes;ushort Planes;ushort BitsPixel;ptr Bits') Local $Ret = DllCall('gdi32.dll', 'int', 'GetObject', 'int', $hBitmap, 'int', DllStructGetSize($tObj), 'ptr', DllStructGetPtr($tObj)) If (@error) Or ($Ret[0] = 0) Then Return 0 EndIf Local $Size[2] = [DllStructGetData($tObj, 'Width'), DllStructGetData($tObj, 'Height')] If ($Size[0] = 0) Or ($Size[1] = 0) Then Return 0 EndIf Return $Size EndFunc ;==>_Icons_Bitmap_GetSize Func _Icons_Bitmap_IsAlpha($hBitmap) Local $Ret, $tBits $Ret = DllCall('gdi32.dll', 'int', 'GetBitmapBits', 'ptr', $hBitmap, 'long', 0, 'ptr', 0) If (@error) Or ($Ret[0] = 0) Then Return SetError(1, 0, 0) EndIf $Lenght = $Ret[0] / 4 $tBits = DllStructCreate('dword[' & $Lenght & ']') $Ret = DllCall('gdi32.dll', 'int', 'GetBitmapBits', 'ptr', $hBitmap, 'long', $Ret[0], 'ptr', DllStructGetPtr($tBits)) If (@error) Or ($Ret[0] = 0) Then Return SetError(1, 0, 0) EndIf For $i = 1 To $Lenght If BitAND(DllStructGetData($tBits, 1, $i), 0xFF000000) Then Return 1 EndIf Next Return 0 EndFunc ;==>_Icons_Bitmap_IsAlpha Func _Icons_Bitmap_IsHBitmap($hBitmap) Local $Ret = DllCall('gdi32.dll', 'dword', 'GetObjectType', 'ptr', $hBitmap) If (Not @error) And ($Ret[0] = 7) Then Return 1 EndIf Return 0 EndFunc ;==>_Icons_Bitmap_IsHBitmap Func _Icons_Bitmap_Load($sImage) _GDIPlus_Startup() Local $hImage = _GDIPlus_ImageLoadFromFile($sImage) Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Return $hBitmap EndFunc ;==>_Icons_Bitmap_Load Func _Icons_Bitmap_Resize($hBitmap, $iWidth, $iHeight, $fHalftone = 0) Local $Size = _Icons_Bitmap_GetSize($hBitmap) If $Size = 0 Then Return 0 EndIf Local $Ret, $hDC, $hDestDC, $SrcDC, $hBmp $hDC = _WinAPI_GetDC(0) $hDestDC = _WinAPI_CreateCompatibleDC($hDC) $hBmp = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight) _WinAPI_SelectObject($hDestDC, $hBmp) $hSrcDC = _WinAPI_CreateCompatibleDC($hDC) _WinAPI_SelectObject($hSrcDC, $hBitmap) _WinAPI_ReleaseDC(0, $hDC) If $fHalftone Then $fHalftone = 4 Else $fHalftone = 3 EndIf DllCall('gdi32.dll', 'int', 'SetStretchBltMode', 'hwnd', $hDestDC, 'int', $fHalftone) $Ret = DllCall('gdi32.dll', 'int', 'StretchBlt', 'hwnd', $hDestDC, 'int', 0, 'int', 0, 'int', $iWidth, 'int', $iHeight, 'hwnd', $hSrcDC, 'int', 0, 'int', 0, 'int', $Size[0], 'int', $Size[1], 'dword', $SRCCOPY) If (@error) Or ($Ret[0] = 0) Then _WinAPI_DeleteObject($hBmp) $hBmp = 0 EndIf _WinAPI_DeleteDC($hDestDC) _WinAPI_DeleteDC($hSrcDC) Return $hBmp EndFunc ;==>_Icons_Bitmap_Resize Func _Icons_Control_CheckHandle($hWnd) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) If $hWnd = 0 Then Return 0 EndIf EndIf Return $hWnd EndFunc ;==>_Icons_Control_CheckHandle Func _Icons_Control_CheckSize($hWnd, ByRef $iX, ByRef $iY) Local $Size = _Icons_Control_GetSize($hWnd) If $iX < 1 Then If $Size = 0 Then $iX = _WinAPI_GetSystemMetrics($SM_CXICON) Else $iX = $Size[0] EndIf EndIf If $iY < 1 Then If $Size = 0 Then $iY = _WinAPI_GetSystemMetrics($SM_CYICON) Else $iY = $Size[1] EndIf EndIf EndFunc ;==>_Icons_Control_CheckSize Func _Icons_Control_Enum($hWnd, $iDirection) Local $iWnd, $Count = 0, $aWnd[50] = [$hWnd] If $iDirection Then $iDirection = $GW_HWNDNEXT Else $iDirection = $GW_HWNDPREV EndIf While 1 $iWnd = _WinAPI_GetWindow($aWnd[$Count], $iDirection) If Not $iWnd Then ExitLoop EndIf $Count += 1 If $Count = UBound($aWnd) Then ReDim $aWnd[$Count + 50] EndIf $aWnd[$Count] = $iWnd WEnd ReDim $aWnd[$Count + 1] Return $aWnd EndFunc ;==>_Icons_Control_Enum Func _Icons_Control_FitTo($hWnd, $hImage) Local $Size = _Icons_Control_GetSize($hWnd) If $Size = 0 Then Return SetError(1, 0, $hImage) EndIf _GDIPlus_Startup() Local $Width = _GDIPlus_ImageGetWidth($hImage), $Height = _GDIPlus_ImageGetHeight($hImage) Local $Ret, $Error = 0 If ($Width = -1) Or ($Height = -1) Then $Error = 1 Else If ($Width <> $Size[0]) Or ($Height <> $Size[1]) Then $Ret = DllCall($__g_hGDIPDll, 'int', 'GdipGetImageThumbnail', 'ptr', $hImage, 'int', $Size[0], 'int', $Size[1], 'ptr*', 0, 'ptr', 0, 'ptr', 0) If (Not @error) And ($Ret[0] = 0) Then _GDIPlus_ImageDispose($hImage) $hImage = $Ret[4] Else $Error = 1 EndIf EndIf EndIf _GDIPlus_Shutdown() Return SetError($Error, 0, $hImage) EndFunc ;==>_Icons_Control_FitTo Func _Icons_Control_GetRect($hWnd) Local $Pos = ControlGetPos($hWnd, '', '') If (@error) Or ($Pos[2] = 0) Or ($Pos[3] = 0) Then Return 0 EndIf Local $tRect = DllStructCreate($tagRECT) DllStructSetData($tRect, 1, $Pos[0]) DllStructSetData($tRect, 2, $Pos[1]) DllStructSetData($tRect, 3, $Pos[0] + $Pos[2]) DllStructSetData($tRect, 4, $Pos[1] + $Pos[3]) Return $tRect EndFunc ;==>_Icons_Control_GetRect Func _Icons_Control_GetSize($hWnd) Local $tRect = DllStructCreate($tagRECT) Local $Ret = DllCall('user32.dll', 'int', 'GetClientRect', 'hwnd', $hWnd, 'ptr', DllStructGetPtr($tRect)) If (@error) Or ($Ret[0] = 0) Then Return 0 EndIf Local $Size[2] = [DllStructGetData($tRect, 3) - DllStructGetData($tRect, 1), DllStructGetData($tRect, 4) - DllStructGetData($tRect, 2)] If ($Size[0] = 0) Or ($Size[1] = 0) Then Return 0 EndIf Return $Size EndFunc ;==>_Icons_Control_GetSize Func _Icons_Control_Invalidate($hWnd) Local $tRect = _Icons_Control_GetRect($hWnd) If IsDllStruct($tRect) Then _WinAPI_InvalidateRect(_WinAPI_GetParent($hWnd), $tRect) EndIf EndFunc ;==>_Icons_Control_Invalidate Func _Icons_Control_SetImage($hWnd, $hImage, $iType, $hOverlap) Local $Static, $Style, $Update, $tRect, $hPrev Switch $iType Case $IMAGE_BITMAP $Static = $__SS_BITMAP Case $IMAGE_ICON $Static = $__SS_ICON Case Else Return 0 EndSwitch $Style = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) If @error Then Return 0 EndIf _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, BitOR($Style, $Static)) If @error Then Return 0 EndIf $tRect = _Icons_Control_GetRect($hWnd) $hPrev = _SendMessage($hWnd, $__STM_SETIMAGE, $iType, $hImage) If @error Then Return 0 EndIf If $hPrev Then If $iType = $IMAGE_BITMAP Then _WinAPI_DeleteObject($hPrev) Else _WinAPI_DestroyIcon($hPrev) EndIf EndIf If (Not $hImage) And (IsDllStruct($tRect)) Then _WinAPI_MoveWindow($hWnd, DllStructGetData($tRect, 1), DllStructGetData($tRect, 2), DllStructGetData($tRect, 3) - DllStructGetData($tRect, 1), DllStructGetData($tRect, 4) - DllStructGetData($tRect, 2), 0) EndIf If $hOverlap Then If Not IsHWnd($hOverlap) Then $hOverlap = 0 EndIf _Icons_Control_Update($hWnd, $hOverlap) Else _Icons_Control_Invalidate($hWnd) EndIf Return 1 EndFunc ;==>_Icons_Control_SetImage #cs Func _Icons_Control_Update($hWnd) Local $tBack, $tFront = _Icons_Control_GetRect($hWnd) Local $tIntersect = DllStructCreate($tagRECT), $pIntersect = DllStructGetPtr($tIntersect) Local $iWnd, $Ret, $XOffset, $YOffset, $Count = 0, $Result = 0 Local $aWnd[50] = [$hWnd] While 1 $iWnd = _WinAPI_GetWindow($aWnd[$Count], $GW_HWNDPREV) If Not $iWnd Then ExitLoop EndIf $Count += 1 If $Count = UBound($aWnd) Then ReDim $aWnd[$Count + 50] EndIf $aWnd[$Count] = $iWnd WEnd If ($Count > 0) And (Not IsDllStruct($tFront)) Then Return 1 EndIf For $i = $Count To 1 Step -1 $tBack = _Icons_Control_GetRect($aWnd[$i]) $Ret = DllCall('user32.dll', 'int', 'IntersectRect', 'ptr', $pIntersect, 'ptr', DllStructGetPtr($tFront), 'ptr', DllStructGetPtr($tBack)) If (Not @error) And ($Ret[0]) Then $Ret = DllCall('user32.dll', 'int', 'IsRectEmpty', 'ptr', $pIntersect) If (Not @error) And (Not $Ret[0]) Then $XOffset = DllStructGetData($tBack, 1) $YOffset = DllStructGetData($tBack, 2) $Ret = DllCall('user32.dll', 'int', 'OffsetRect', 'ptr', $pIntersect, 'int', -$XOffset, 'int', -$YOffset) If (Not @error) And ($Ret[0]) Then _WinAPI_InvalidateRect($aWnd[$i], $tIntersect) $Result += 1 EndIf EndIf EndIf Next Return $Result EndFunc ;==>_Icons_Control_Update #ce Func _Icons_Control_Update($hWnd, $hOverlap) Local $tBack, $tFront = _Icons_Control_GetRect($hWnd) If $tFront = 0 Then Return EndIf Local $aNext = _Icons_Control_Enum($hWnd, 1) Local $aPrev = _Icons_Control_Enum($hWnd, 0) If UBound($aPrev) = 1 Then _WinAPI_InvalidateRect(_WinAPI_GetParent($hWnd), $tFront) Return EndIf Local $aWnd[UBound($aNext) + UBound($aPrev - 1)] Local $tIntersect = DllStructCreate($tagRECT), $pIntersect = DllStructGetPtr($tIntersect) Local $iWnd, $Ret, $XOffset, $YOffset, $Count = 0, $Update = 0 For $i = UBound($aPrev) - 1 To 1 Step -1 $aWnd[$Count] = $aPrev[$i] $Count += 1 Next For $i = 0 To UBound($aNext) - 1 $aWnd[$Count] = $aNext[$i] $Count += 1 Next For $i = 0 To $Count - 1 If $aWnd[$i] = $hWnd Then _WinAPI_InvalidateRect($hWnd) Else If (Not $hOverlap) Or ($aWnd[$i] = $hOverlap) Then $tBack = _Icons_Control_GetRect($aWnd[$i]) $Ret = DllCall('user32.dll', 'int', 'IntersectRect', 'ptr', $pIntersect, 'ptr', DllStructGetPtr($tFront), 'ptr', DllStructGetPtr($tBack)) If (Not @error) And ($Ret[0]) Then $Ret = DllCall('user32.dll', 'int', 'IsRectEmpty', 'ptr', $pIntersect) If (Not @error) And (Not $Ret[0]) Then $XOffset = DllStructGetData($tBack, 1) $YOffset = DllStructGetData($tBack, 2) $Ret = DllCall('user32.dll', 'int', 'OffsetRect', 'ptr', $pIntersect, 'int', -$XOffset, 'int', -$YOffset) If (Not @error) And ($Ret[0]) Then _WinAPI_InvalidateRect($aWnd[$i], $tIntersect) $Update += 1 EndIf EndIf EndIf EndIf EndIf Next If Not $Update Then _WinAPI_InvalidateRect(_WinAPI_GetParent($hWnd), $tFront) EndIf EndFunc ;==>_Icons_Control_Update Func _Icons_Icon_Duplicate($hIcon) If $hIcon Then Return _WinAPI_CopyIcon($hIcon) EndIf Return 0 EndFunc ;==>_Icons_Icon_Duplicate Func _Icons_Icon_Extract($sIcon, $iIndex, $iWidth, $iHeight) Local $Ret = DllCall('shell32.dll', 'int', 'SHExtractIconsW', 'wstr', $sIcon, 'int', $iIndex, 'int', $iWidth, 'int', $iHeight, 'ptr*', 0, 'ptr*', 0, 'int', 1, 'int', 0) If (@error) Or ($Ret[0] = 0) Then Return SetError(1, 0, 0) EndIf Return $Ret[5] EndFunc ;==>_Icons_Icon_Extract #cs Func _Icons_Icon_CreateFromBitmap($hBitmap) Local $Ret, $hImage, $hIcon = 0 _GDIPlus_Startup() $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) If $hImage Then $Ret = DllCall($__g_hGDIPDll, 'int', 'GdipCreateHICONFromBitmap', 'ptr', $hImage, 'int*', 0) If (Not @error) And ($Ret[0] = 0) Then $hIcon = $Ret[2] EndIf _GDIPlus_ImageDispose($hImage) EndIf _GDIPlus_Shutdown() Return $hIcon EndFunc ;==>_Icons_Icon_CreateFromBitmap #ce Func _Icons_Icon_CreateFromBitmap($hBitmap) Local $Size = _Icons_Bitmap_GetSize($hBitmap) If $Size = 0 Then Return 0 EndIf Local $tICONINFO = DllStructCreate($tagICONINFO) Local $hMask = _Icons_Bitmap_CreateSolidBitmap(0, $Size[0], $Size[1]) Local $hIcon = 0 DllStructSetData($tICONINFO, 1, 1) DllStructSetData($tICONINFO, 2, 0) DllStructSetData($tICONINFO, 3, 0) DllStructSetData($tICONINFO, 4, $hMask) DllStructSetData($tICONINFO, 5, $hBitmap) $Ret = DllCall('user32.dll', 'ptr', 'CreateIconIndirect', 'ptr', DllStructGetPtr($tICONINFO)) If (Not @error) And ($Ret[0]) Then $hIcon = $Ret[0] EndIf _WinAPI_DeleteObject($hMask) Return $hIcon EndFunc ;==>_Icons_Icon_CreateFromBitmap Func _Icons_Icon_GetSize($hIcon) Local $tICONINFO = DllStructCreate($tagICONINFO) Local $Ret = DllCall('user32.dll', 'int', 'GetIconInfo', 'ptr', $hIcon, 'ptr', DllStructGetPtr($tICONINFO)) If (@error) Or ($Ret[0] = 0) Then Return 0 EndIf Local $Size = _Icons_Bitmap_GetSize(DllStructGetData($tICONINFO, 5)) _WinAPI_DeleteObject(DllStructGetData($tICONINFO, 4)) _WinAPI_DeleteObject(DllStructGetData($tICONINFO, 5)) If ($Size[0] = 0) Or ($Size[1] = 0) Then Return 0 EndIf Return $Size EndFunc ;==>_Icons_Icon_GetSize Func _Icons_Icon_Merge($iBackground, $hBack, $hFront, $iX, $iY, $iWidth = -1, $iHeight = -1) Local $Size If ($iWidth < 1) Or ($iHeight < 1) Then $Size = _Icons_Icon_GetSize($hBack) If $Size = 0 Then Return 0 EndIf If $iWidth < 1 Then $iWidth = $Size[0] EndIf If $iHeight < 1 Then $iHeight = $Size[0] EndIf EndIf Local $hDC, $hMemDC, $hImage, $hBitmap, $hIcon $hDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _Icons_Bitmap_CreateSolidBitmap($iBackground, $iWidth, $iHeight) _WinAPI_SelectObject($hMemDC, $hBitmap) _WinAPI_ReleaseDC(0, $hDC) If $hBack Then _WinAPI_DrawIconEx($hMemDC, 0, 0, $hBack, 0, 0, 0, 0, $DI_NORMAL) EndIf If $hFront Then _WinAPI_DrawIconEx($hMemDC, $iX, $iY, $hFront, 0, 0, 0, 0, $DI_NORMAL) EndIf _GDIPlus_Startup() $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) $hIcon = DllCall($__g_hGDIPDll, 'int', 'GdipCreateHICONFromBitmap', 'ptr', $hImage, 'ptr*', 0) If (Not @error) And ($hIcon[0] = 0) Then $hIcon = $hIcon[2] Else $hIcon = 0 EndIf _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) Return $hIcon EndFunc ;==>_Icons_Icon_Merge Func _Icons_System_GetColor($hWnd) Local $Ret, $hDC = _WinAPI_GetDC($hWnd) If $hDC = 0 Then Return -1 EndIf $Ret = DllCall('gdi32.dll', 'int', 'GetBkColor', 'hwnd', $hDC) If (@error) Or ($Ret[0] < 0) Then $Ret = -1 EndIf _WinAPI_ReleaseDC($hWnd, $hDC) If $Ret < 0 Then Return -1 EndIf Return _Icons_System_SwitchColor($Ret[0]) EndFunc ;==>_Icons_System_GetColor Func _Icons_System_SwitchColor($iColor) Return BitOR(BitAND($iColor, 0x00FF00), BitShift(BitAND($iColor, 0x0000FF), -16), BitShift(BitAND($iColor, 0xFF0000), 16)) EndFunc ;==>_Icons_System_SwitchColor #EndRegion Internal Functions This should work with latest AutoIt version.1 point -
Image animation element running continuously
Rechard_Long reacted to UEZ for a topic
You have to modify the example I've posted in #14 a little bit: #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <Screencapture.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global Const $hHBitmap_Bg = _ScreenCapture_Capture("", 0, 0, 615, 438) ;background image Global Const $hBitmap_Bg = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap_Bg) Global Const $STM_SETIMAGE = 0x0172 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 438, 192, 124) ;~ GUISetBkColor(0) $ANIMATED = GUICtrlCreatePic("", 0, 0, 615, 438) ;~ $ANIMATED = GUICtrlCreatePic("", 30, 30, 264, 90) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $i, $aFrames[51] For $i = 1 To 51 $aFrames[$i - 1] = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\REZ_Systems\UI\UI_BI_FX\BI_FX0" & $i & ".PNG") Next Global $iClear = 0xFFF0F0F0 Global $hBitmap = _GDIPlus_BitmapCreateFromScan0(615, 438), $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) AdlibRegister("Play_Anim", 70) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE AdlibUnRegister("Play_Anim") GUIDelete() For $i = 0 To 50 _GDIPlus_ImageDispose($aFrames[$i]) Next _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_ImageDispose($hBitmap_Bg) _WinAPI_DeleteObject($hHBitmap_Bg) _GDIPlus_Shutdown() Exit EndSwitch WEnd Func Play_Anim() Local Static $iFrame = 0 _GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap_Bg, 0, 0, 615, 438) _GDIPlus_GraphicsDrawImageRect($hGfx, $aFrames[$iFrame], 30, 30, 264, 90) Local $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _WinAPI_DeleteObject(GUICtrlSendMsg($ANIMATED, $STM_SETIMAGE, $IMAGE_BITMAP, $hGDIBitmap)) _WinAPI_DeleteObject($hGDIBitmap) $iFrame += 1 If $iFrame > 50 Then $iFrame = 0 EndFunc1 point -
Image animation element running continuously
Rechard_Long reacted to UEZ for a topic
If you can provide more information about your project then maybe.1 point -
Image animation element running continuously
Rechard_Long reacted to UEZ for a topic
Handling transparent images is not easy. You have to adjust the $iClear value according to the background color. $iClear must be in format ARGB -> AlphaRedGreenBlue Further it is much easier to handle the color value in hex decimal format -> $iClear = 0xFFF0F0F0 Each color channel must be in the range of 0x00 until 0xFF which is in decimal 0 - 255. 0x is the prefix for hex decimal numbers. If you clear the picture image first it will start to twitsching again.1 point -
double click in autoit3 how ?
Gianni reacted to InunoTaishou for a topic
Are you wanting to detect when the label is double clicked? Here's one way #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <WinApi.au3> Global $hGUI = GUICreate("Double Click", 144, 144) Global $lblLabel = GUICtrlCreateLabel("Double click this!" & @CRLF & "For something cool", 10, 10) Global $hWnd_wndproc = DllCallbackRegister("NewWndProc", "ptr", "hwnd;uint;wparam;lparam") Global $ptr_new_wndproc = DllCallbackGetPtr($hWnd_wndproc) Global $ptr_old_wndproc = _WinAPI_SetWindowLong(GUICtrlGetHandle($lblLabel), $GWL_WNDPROC, $ptr_new_wndproc) GUISetState(@SW_SHOW, $hGUI) While (True) Switch (GUIGetMsg()) Case $GUI_EVENT_CLOSE GUIDelete($hGUI) DllCallbackFree($hWnd_wndproc) Exit 0 Case $lblLabel ConsoleWrite("Label clicked" & @LF) EndSwitch WEnd Func NewWndProc($hWndFrom, $iMsg, $wParam, $lParam) Switch $hWndFrom Case GUICtrlGetHandle($lblLabel) Switch $iMsg Case $WM_LBUTTONDBLCLK ConsoleWrite("Label Double clicked!" & @LF) MsgBox("", "Double Click!", "You double clicked my label!") EndSwitch EndSwitch Return _WinAPI_CallWindowProc($ptr_old_wndproc, $hWndFrom, $iMsg, $wParam, $lParam) EndFunc ;==>NewWndProc Here's another one using WM_COMMAND #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <WinApi.au3> Global $hGUI = GUICreate("Double Click", 144, 144) Global $lblLabel = GUICtrlCreateLabel("Double click this!" & @CRLF & "For something cool", 10, 10) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState(@SW_SHOW, $hGUI) While (True) Switch (GUIGetMsg()) Case $GUI_EVENT_CLOSE GUIDelete($hGUI) Exit 0 Case $lblLabel ConsoleWrite("Label clicked" & @LF) EndSwitch WEnd Func WM_COMMAND($hWndFrom, $iMsg, $wParam, $lParam) Local $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word Local $iCode = BitShift($wParam, 16) ; Hi Word Switch ($hWndFrom) Case $hGUI Switch ($iIDFrom) Case $lblLabel If ($iCode) Then ConsoleWrite("Label Double clicked!" & @LF) MsgBox("", "Double Click!", "You double clicked my label!") EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND1 point -
Is this any help? #include <Array.au3> #include <MsgBoxConstants.au3> Local $aArray[4] = [2, 2, 0, 2] ; array to search Local $vSearchWhat = 2 Local $iIndex = -1, $iItems = 0, $aResults[UBound($aArray)] While 1 $iIndex = _ArraySearch($aArray, $vSearchWhat, $iIndex +1) If $iIndex <> -1 Then $aResults[$iItems] = $iIndex $iItems += 1 Else ExitLoop EndIf WEnd ReDim $aResults[$iItems] _ArrayDisplay($aResults) ; indeces ; additional code Local $sRet = "" If UBound($aResults) = 0 Then MsgBox($MB_SYSTEMMODAL, "Not Found", '"' & $vSearchWhat & '" was not found') Else For $i = 0 To UBound($aResults) -1 ; loop through the results $sRet &= $aResults[$i] & ", " Next $sRet = StringTrimRight($sRet, 2) MsgBox($MB_SYSTEMMODAL, "Found", '"' & $vSearchWhat & '" was found in the array at positions ' & $sRet) EndIf1 point
-
Image animation element running continuously
Rechard_Long reacted to mLipok for a topic
@UEZ Interesting implementation.1 point -
Image animation element running continuously
Rechard_Long reacted to UEZ for a topic
Try this: #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 438, 192, 124) $ANIMATED = GUICtrlCreatePic("", 30, 30, 264, 90) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global Const $STM_SETIMAGE = 0x0172 _GDIPlus_Startup() Global $i, $aFrames[51] For $i = 1 To 51 $aFrames[$i - 1] = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\REZ_Systems\UI\UI_BI_FX\BI_FX0" & $i & ".PNG") Next Global $iClear = 0xFFF0F0F0 Global $hBitmap = _GDIPlus_BitmapCreateFromScan0(264, 90), $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) AdlibRegister("Play_Anim", 70) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE AdlibUnRegister("Play_Anim") GUIDelete() For $i = 0 To 50 _GDIPlus_ImageDispose($aFrames[$i]) Next _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_Shutdown() Exit EndSwitch WEnd Func Play_Anim() Local Static $iFrame = 0 _GDIPlus_GraphicsClear($hGfx, $iClear) _GDIPlus_GraphicsDrawImageRect($hGfx, $aFrames[$iFrame], 0, 0, 264, 90) Local $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _WinAPI_DeleteObject(GUICtrlSendMsg($ANIMATED, $STM_SETIMAGE, $IMAGE_BITMAP, $hGDIBitmap)) _WinAPI_DeleteObject($hGDIBitmap) $iFrame += 1 If $iFrame > 50 Then $iFrame = 0 EndFunc1 point -
Image animation element running continuously
Rechard_Long reacted to UEZ for a topic
Hmm, your operating system is in English but you don't understand English. Maybe you can provide also the images in a zip archive.1 point -
Image animation element running continuously
Rechard_Long reacted to mLipok for a topic
Please read this: How to post code on the forum1 point -
Return it to the store, and have it replaced.1 point
-
Using that it seems to me that you're only getting values from the column named 'column'. You can read the whole 2D recordset into an 2D array in one shot by replacing the For..Next loop by: $aReturn = $oRS.GetRows() The parameters should be cursortype and locktype. FYI I join an ADO UDF with ready-to-use wrappers modelled on the SQLite UDF functions (see help file and this UDF functions headers). Once you have your connection string working, you should be able to use it with little issue(s) if any. AdoSQL.au31 point
-
Just thought about how to store the little bits and pieces I stumble over, so I decided to collect them in this "Useful snippets Collection Thread", ready to be found via the forum search . 1. Set FileOpenDialog, FileSaveDialog or FileSelectFolder topmost I wondered how to set these standard dialog topmost. Turns out it's quite easy by using a topmost dummy GUI as parent without displaying it. ; Not topmost FileOpenDialog("FileOpenDialog", @ScriptDir, "All (*.*)", 1 + 4, "") FileSaveDialog("FileSaveDialog", @ScriptDir, "All (*.*)", 2, "") FileSelectFolder("Choose a folder.", "", 7, @ScriptDir) ; Topmost #include <windowsconstants.au3> $hGUI = GUICreate("$WS_EX_TOPMOST", Default, Default, Default, Default, Default, $WS_EX_TOPMOST) FileOpenDialog("FileOpenDialog", @ScriptDir, "All (*.*)", 1 + 4, "", $hGUI) FileSaveDialog("FileSaveDialog", @ScriptDir, "All (*.*)", 2, "", $hGUI) FileSelectFolder("Choose a folder.", "", 7, @ScriptDir, $hGUI) ; Another method provided by guinness FileOpenDialog("FileOpenDialog", @ScriptDir, "All (*.*)", 1 + 4, "", _OnTop()) FileSaveDialog("FileSaveDialog", @ScriptDir, "All (*.*)", 2, "", _OnTop()) FileSelectFolder("Choose a folder.", "", 7, @ScriptDir, _OnTop()) Func _OnTop() Local $sHandle = WinGetHandle(AutoItWinGetTitle()) WinSetOnTop($sHandle, "", 1) Return $sHandle EndFunc ;==>_OnTop 2. Change TabStop Order of Controls To change the TabStop ($WS_TABSTOP) Order of controls you have to change their respective Z-Order. #include <guiconstantsex.au3> #include <winapi.au3> #include <constants.au3> GUICreate("My GUI", 120, 160) $c_Input1 = GUICtrlCreateInput("", 10, 10, 100) $c_Input2 = GUICtrlCreateInput("", 10, 50, 100) $c_Input3 = GUICtrlCreateInput("", 10, 90, 100) $c_Input4 = GUICtrlCreateInput("", 10, 130, 100) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd _WinAPI_SetWindowPos(GUICtrlGetHandle($c_Input1), GUICtrlGetHandle($c_Input2), 0, 0, 0, 0, BitOR($SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOACTIVATE)) _WinAPI_SetWindowPos(GUICtrlGetHandle($c_Input3), GUICtrlGetHandle($c_Input4), 0, 0, 0, 0, BitOR($SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOACTIVATE)) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() 3. Set Position and change font _GUICtrlComboBoxEx() of controls A small example on two _GUICtrlComboBoxEx issues I didn't found an answer to in the help-file or on the board, how to set the control position and how to change the control font. Espc. note that the height of the dropdown is defined during control creation. I set it to 17 and wondered why I couldn't see a dropdown. The height of the control itself is derived from the used font (see font change #1 and #2). The font objects should be deleted on exit, because they're needed to redraw the control if you change the selection (see how changing the selection after font change #2 suddenly changes font size again). #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.6.1 Author: KaFu Script Function: _GUICtrlComboBoxEx examples for positioning and set font #ce ---------------------------------------------------------------------------- #include <guicomboboxex.au3> #include <constants.au3> #include <guiconstantsex.au3> #include <winapi.au3> #include <fontconstants.au3> OnAutoItExitRegister("_Delete_Font_Objects") $hGUI = GUICreate("ComboBoxEx Create", 400, 300) $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "This is a test|Line 2", 2, 2, 394, 268) $cCombo = _WinAPI_GetWindowLong($hCombo, $GWL_ID) consolewrite("Combo ctrlID: " & $cCombo & @crlf) _GUICtrlComboBoxEx_AddString($hCombo, "Some More Text") _GUICtrlComboBoxEx_InsertString($hCombo, "Inserted Text", 1) _GUICtrlComboBoxEx_SetCurSel($hCombo, 0) GUISetState() ; How to set position of _GUICtrlComboBoxEx Sleep(2000) _WinAPI_SetWindowPos($hCombo, $HWND_TOPMOST, 2, 100, 394, 268, $SWP_NOZORDER) ; How to change font of _GUICtrlComboBoxEx Sleep(2000) $hFont1 = _WinAPI_CreateFont(40, 0, 0, 0, 800, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, _ $CLIP_DEFAULT_PRECIS, $PROOF_QUALITY, 0, "Arial") _WinAPI_SetFont($hCombo, $hFont1, True) Sleep(2000) $hFont2 = _WinAPI_CreateFont(10, 0, 0, 0, 800, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, _ $CLIP_DEFAULT_PRECIS, $PROOF_QUALITY, 0, "Arial") _WinAPI_SetFont($hCombo, $hFont2, True) _WinAPI_DeleteObject($hFont2) Sleep(2000) _GUICtrlComboBoxEx_SetCurSel($hCombo, 1) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _Delete_Font_Objects() _WinAPI_DeleteObject($hFont1) EndFunc ;==>_Delete_Font_Object 4. Internet Explorer UDF: Toggle Javascript Seems to be quite complex. As I read it, you'll have to tweak the zone definition. http://support.microsoft.com/default.aspx?scid=KB;en-us;q182569 The easiest way seems to be to assign a site with the domain switch to zone 4 (Restricted Sites Zone). #include <ie.au3> $sURL = "internet.com" RegWrite("HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet SettingsZoneMapDomains" & $sURL, "http", "REG_DWORD", 4) $oIE = _IECreate("http://javascript.internet.com/games/button-mania.html") RegDelete("HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet SettingsZoneMapDomains" & $sURL, "http") Another method would be to edit the zones themselves: [HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet SettingsZonesX Where X is the number from 0 to 4 representing the security zones. Set: 1400 Scripting: Active scripting 1402 Scripting: Scripting of Java applets to 3 which means disable. 5. Internet Explorer UDF: Disable Scrollbars #include <guiconstantsex.au3> #include <ie.au3> $hGUI = GUICreate("", 762, 574) Global $oIE = _IECreateEmbedded() Global $hIE = GUICtrlCreateObj($oIE, 10, 10, 742, 554) _IENavigate($oIE, "http://www.yahoo.com") $oIE.document.body.scroll = "no" $oIE.document.body.style.border = "0px" GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd 6. Internet Explorer UDF: Re-Enable Basic Authentication URL Syntax ; http://support.microsoft.com/kb/834489 #include <ie.au3> RegWrite("HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMainFeatureControlFEATURE_HTTP_USERNAME_PASSWORD_DISABLE","iexplore.exe","REG_DWORD",0) _IECreate ("http://USERNAME:PASSWORD@website.com/protected_dir/") RegWrite("HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMainFeatureControlFEATURE_HTTP_USERNAME_PASSWORD_DISABLE","iexplore.exe","REG_DWORD",1) 7. Create big empty files #include <constants.au3> Local Const $sFile = "test.txt" Local $hFile = FileOpen($sFile, 2) ; Check if file opened for writing OK If $hFile = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileSetPos($hFile, (1024*1024*100)-1, $FILE_BEGIN) FileWrite($hFile, 0) ; Close the handle. FileClose($hFile) 8. Facts on UAC #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator Microsoft recommends that all executables, such as Setup programs (which need access to protected areas of Windows), should be marked as requireAdministrator. This will always result in an UAC prompt on program start. #AutoIt3Wrapper_Res_requestedExecutionLevel=highestAvailable If you are Admin, the program will run as Admin and prompt an UAC request. #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker Program will run without an UAC request even if you are Admin. This might lead to UAC issues, e.g. you can not access the HKEY_LOCAL_MACHINE registry hive, you can not change or delete files with higher authorizations needed. There are a number of ways to elevate the execution level of an executable: Right-click an EXE or its shortcut and select "Run as administrator" from the context menu.Right-click and select properties. Click the advanced button (General Tab) and check the "Run as administrator" checkbox.Right-click and select properties. Click the "Show Settings for all users" (Compatibility Tab) and check the "Run as administrator" checkbox.Login as a real Administrator and run from there (Don't do this. Not secure).The system behavior regarding UAC requests can be read from the registry: ; http://technet.microsoft.com/en-us/library/dd835564%28WS.10%29.aspx Global $b_ScriptIsRunningWithAdminRights, $b_UAC_IsEnabled, $s_UAC_BehaviorAdmin, $s_UAC_BehaviorUser, $s_UAC_EnableInstallerDetection Switch IsAdmin() Case 0 $b_ScriptIsRunningWithAdminRights = False Case Else $b_ScriptIsRunningWithAdminRights = True EndSwitch Switch RegRead("HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionPoliciesSystem", "EnableLUA") Case 0 $b_UAC_IsEnabled = "UAC (formally known as LUA) is disabled." Case 1 $b_UAC_IsEnabled = "UAC (formally known as LUA) is enabled." EndSwitch Switch RegRead("HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionPoliciesSystem", "ConsentPromptBehaviorAdmin") Case 0 $s_UAC_BehaviorAdmin = "Elevate without prompting (Use this option only in the most constrained environments)" Case 1 $s_UAC_BehaviorAdmin = "Prompt for credentials on the secure desktop" Case 2 $s_UAC_BehaviorAdmin = "Prompt for consent on the secure desktop" Case 3 $s_UAC_BehaviorAdmin = "Prompt for credentials" Case 4 $s_UAC_BehaviorAdmin = "Prompt for consent" Case 5 $s_UAC_BehaviorAdmin = "Prompt for consent for non-Windows binaries (default)" EndSwitch Switch RegRead("HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionPoliciesSystem", "ConsentPromptBehaviorUser") Case 0 $s_UAC_BehaviorUser = "Automatically deny elevation requests" Case 1 $s_UAC_BehaviorUser = "Prompt for credentials on the secure desktop (default)" Case 3 $s_UAC_BehaviorUser = "Prompt for credentials" EndSwitch Switch RegRead("HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionPoliciesSystem", "EnableInstallerDetection") Case 0 $s_UAC_EnableInstallerDetection = "Disabled (default for enterprise)" Case 1 $s_UAC_EnableInstallerDetection = "Enabled (default for home)" EndSwitch MsgBox(64 + 262144, "Script Info - " & @UserName, "Script is started by user with Admin rights = " & _IsAdministrator() & @CRLF & _ "Script is started with Admin access = " & $b_ScriptIsRunningWithAdminRights & @CRLF & @CRLF & _ "EnableLUA:" & @CRLF & $b_UAC_IsEnabled & @CRLF & @CRLF & _ "ConsentPromptBehaviorAdmin:" & @CRLF & $s_UAC_BehaviorAdmin & @CRLF & @CRLF & _ "ConsentPromptBehaviorUser:" & @CRLF & $s_UAC_BehaviorUser & @CRLF & @CRLF & _ "EnableInstallerDetection:" & @CRLF & $s_UAC_EnableInstallerDetection) ; trancexx ; http://www.autoitscript.com/forum/topic/113611-if-isadmin-not-detected-as-admin/page__view__findpost__p__795036 Func _IsAdministrator($sUser = @UserName, $sCompName = ".") Local $aCall = DllCall("netapi32.dll", "long", "NetUserGetInfo", "wstr", $sCompName, "wstr", $sUser, "dword", 1, "ptr*", 0) If @error Or $aCall[0] Then Return SetError(1, 0, False) Local $fPrivAdmin = DllStructGetData(DllStructCreate("ptr;ptr;dword;dword;ptr;ptr;dword;ptr", $aCall[4]), 4) = 2 DllCall("netapi32.dll", "long", "NetApiBufferFree", "ptr", $aCall[4]) Return $fPrivAdmin EndFunc ;==>_IsAdministratorThe IsAdmin() function will show you, if the script is running with elevated execution level. Scripts compiled with "asInvoker" will never do so without further actions. IsRunningWithAdminExecutionLevel() would have been a better name. To detect if an UAC prompt (prompt for consent/credentials) currently exists, look out for the underlying default Windows process "consent.exe". "Installer Detection" Policy = Automatic Elevation It turns out that Windows actually examines the names of all executable you run, and if they contain the words "setup", "install", "update", "patch" etc then the executable is automatically elevated; e.g. MySetup001.exe will run elevated. I've heard of cases where a word such as "update" found within an executables resources also trigged elevation. I've also heard that Windows can recognize and elevate setup files created by InstallShield and Wise. I'm not sure of the exact heuristics used. For more on UAC also take a look at my example of how to From Windows Vista Application Development Requirements for User Account Control (UAC): User Interface Privilege Isolation (UIPI) A lower privilege process cannot: [*]Perform a window handle validation of higher process privilege. [*]SendMessage or PostMessage to higher privilege application windows. These Application Programming Interfaces (APIs) return success but silently drop the window message. [*]Use thread hooks to attach to a higher privilege process. [*]Use Journal hooks to monitor a higher privilege process. [*]Perform DLL injection to a higher privilege process. With UIPI enabled, the following shared USER resources are still shared between processes at different privilege levels: [*]Desktop window, which actually owns the screen surface. [*]Desktop heap read-only shared memory. [*]Global atom table. [*]Clipboard If you're creating the process with higher elevation you can use the ChangeWindowMessageFilter function to allow certain messages being posted to you from lower privileged processes.1 point
-
Any framework for the automation testing
justdoit123 reacted to zfisherdrums for a topic
Sounds awesome!1 point