Jump to content

Recommended Posts

Posted (edited)

A simple example of creating a pop-up circular menu in the style of >iKey. Menu is activated by pressing and holding down the middle mouse button. Also I wrote six animated effects (commented out) for a pop-up menu. All required images and cursors is in the archive. To run this script required >WinAPIEx UDF library.

 

post_img_073.png

 

#Include <APIConstants.au3>
#Include <GDIPlus.au3>
#Include <Misc.au3>
#Include <WinAPIEx.au3>

Opt('WinWaitDelay', 0)

_GDIPlus_Startup()

$hHand = _WinAPI_LoadCursorFromFile(@ScriptDir & '\Arrow.cur')
$hPrev = _WinAPI_CopyCursor(_WinAPI_LoadCursor(0, 32512))

Dim $hImage[9][2]
For $i = 0 To 8
    $hImage[$i][0] = _GDIPlus_ImageLoadFromFile(StringFormat(@ScriptDir & '\%02d.png', $i))
    $hImage[$i][1] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage[$i][0])
Next

$hForm = GUICreate('', 190, 190, -1, -1, $WS_POPUPWINDOW, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST), GUICreate('', -1, -1, -1, -1, -1, $WS_EX_TOOLWINDOW))

Dim $Tip[2]

While 1
    Sleep(100)
    If _IsPressed('04') Then
        $XY = MouseGetPos()
        GUISetState(@SW_SHOWNOACTIVATE, $hForm)

; Animation 1

        WinMove($hForm, '', $XY[0] - 95, $XY[1] - 95, 190, 190)
        $hPng = _GDIPlus_ImageClone($hImage[0][0])
        $hGraphic = _GDIPlus_ImageGetGraphicsContext($hPng)
        For $i = 5 To 255 Step 5
            $Size = Round(190 * $i / 255)
            If Mod($Size, 2) Then
                $Size += 1
            EndIf
            _GDIPlus_GraphicsClear($hGraphic, 0)
            _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage[0][0], (190 - $Size) / 2, (190 - $Size) / 2, $Size, $Size)
            _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, _GDIPlus_BitmapCreateHBITMAPFromBitmap($hPng), $i, 1)
;           _Sleep(1)
        Next
        _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[0][1])
        _GDIPlus_GraphicsDispose($hGraphic)
        _GDIPlus_ImageDispose($hPng)

; Animation 2

#cs
        WinMove($hForm, '', $XY[0] - 190, $XY[1] - 190, 380, 380)
        $hPng = _GDIPlus_ImageGetThumbnail($hImage[0][0], 380, 380)
        $hGraphic = _GDIPlus_ImageGetGraphicsContext($hPng)
        For $i = 5 To 255 Step 5
            $Size = Round(190 * (2 - $i / 255))
            If Mod($Size, 2) Then
                $Size += 1
            EndIf
            _GDIPlus_GraphicsClear($hGraphic, 0)
            _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage[0][0], (380 - $Size) / 2, (380 - $Size) / 2, $Size, $Size)
            _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, _GDIPlus_BitmapCreateHBITMAPFromBitmap($hPng), $i, 1)
;           _Sleep(1)
        Next
        _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[0][1], 0)
        WinMove($hForm, '', $XY[0] - 95, $XY[1] - 95, 190, 190)
        _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[0][1])
        _GDIPlus_GraphicsDispose($hGraphic)
        _GDIPlus_ImageDispose($hPng)
#ce

; Animation 3

#cs
        WinMove($hForm, '', $XY[0] - 95, $XY[1] - 95, 190, 190)
        $hMatrix = _GDIPlus_MatrixCreate()
        $hPng = _GDIPlus_ImageClone($hImage[0][0])
        $hGraphic = _GDIPlus_ImageGetGraphicsContext($hPng)
        _GDIPlus_MatrixTranslate($hMatrix, 95, 95)
        For $i = 5 To 255 Step 5
            If $i = 5 Then
                _GDIPlus_MatrixRotate($hMatrix, -75)
            Else
                _GDIPlus_MatrixRotate($hMatrix, 1.5)
            EndIf
            _GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix)
            _GDIPlus_GraphicsClear($hGraphic, 0)
            _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage[0][0], -95, -95, 190, 190)
            _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, _GDIPlus_BitmapCreateHBITMAPFromBitmap($hPng), $i, 1)
;           _Sleep(1)
        Next
        _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[0][1])
        _GDIPlus_GraphicsDispose($hGraphic)
        _GDIPlus_MatrixDispose($hMatrix)
        _GDIPlus_ImageDispose($hPng)
#ce

; Animation 4

#cs
        WinMove($hForm, '', $XY[0] - 95, $XY[1] - 95, 190, 190)
        For $i = 5 To 255 Step 5
            _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[0][1], $i)
            _Sleep(1)
        Next
#ce

; Animation 5

#cs
        WinMove($hForm, '', $XY[0] - 95, $XY[1] - 95, 190, 190)
        $hMatrix = _GDIPlus_MatrixCreate()
        $hPng = _GDIPlus_ImageClone($hImage[0][0])
        $hGraphic = _GDIPlus_ImageGetGraphicsContext($hPng)
        _GDIPlus_MatrixTranslate($hMatrix, 95, 95)
        For $i = 5 To 255 Step 5
            $Size = Round(190 * $i / 255)
            If Mod($Size, 2) Then
                $Size += 1
            EndIf
            If $i = 5 Then
                _GDIPlus_MatrixRotate($hMatrix, -100)
            Else
                _GDIPlus_MatrixRotate($hMatrix, 2)
            EndIf
            _GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix)
            _GDIPlus_GraphicsClear($hGraphic, 0)
            _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage[0][0], (190 - $Size) / 2 - 95, (190 - $Size) / 2 - 95, $Size, $Size)
            _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, _GDIPlus_BitmapCreateHBITMAPFromBitmap($hPng), $i, 1)
            _Sleep(1)
        Next
        _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[0][1])
        _GDIPlus_GraphicsDispose($hGraphic)
        _GDIPlus_MatrixDispose($hMatrix)
        _GDIPlus_ImageDispose($hPng)
#ce

; Animation 6

#cs
        WinMove($hForm, '', $XY[0] - 190, $XY[1] - 190, 380, 380)
        $hMatrix = _GDIPlus_MatrixCreate()
        $hPng = _GDIPlus_ImageGetThumbnail($hImage[0][0], 380, 380)
        $hGraphic = _GDIPlus_ImageGetGraphicsContext($hPng)
        _GDIPlus_MatrixTranslate($hMatrix, 190, 190)
        For $i = 5 To 255 Step 5
            $Size = Round(190 * (2 - $i / 255))
            If Mod($Size, 2) Then
                $Size += 1
            EndIf
            If $i = 5 Then
                _GDIPlus_MatrixRotate($hMatrix, -100)
            Else
                _GDIPlus_MatrixRotate($hMatrix, 2)
            EndIf
            _GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix)
            _GDIPlus_GraphicsClear($hGraphic, 0)
            _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage[0][0], (380 - $Size) / 2 - 190, (380 - $Size) / 2 - 190, $Size, $Size)
            _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, _GDIPlus_BitmapCreateHBITMAPFromBitmap($hPng), $i, 1)
            _Sleep(1)
        Next
        _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[0][1], 0)
        WinMove($hForm, '', $XY[0] - 95, $XY[1] - 95, 190, 190)
        _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[0][1])
        _GDIPlus_GraphicsDispose($hGraphic)
        _GDIPlus_MatrixDispose($hMatrix)
        _GDIPlus_ImageDispose($hPng)
#ce

        $Timer = 0
        $Tip[0] = -1
        $Tip[1] = -1
        $Item = 0
        $Prev = 0
        _WinAPI_SetSystemCursor($hHand, 32512, 1)
        While _IsPressed('04')
            $Pos = MouseGetPos()
            $R = Sqrt(($XY[0] - $Pos[0]) ^ 2 + ($XY[1] - $Pos[1]) ^ 2)
            If ($R < 47) Or ($R > 95) Then
                $Item = 0
            Else
                $Ang = _Angle($Pos[0], $Pos[1], $XY[0], $XY[1])
                Select
                    Case ($Ang >= 0  ) And ($Ang < 45 )
                        $Item = 1
                    Case ($Ang >= 45 ) And ($Ang < 90 )
                        $Item = 2
                    Case ($Ang >= 90 ) And ($Ang < 135)
                        $Item = 3
                    Case ($Ang >= 135) And ($Ang < 180)
                        $Item = 4
                    Case ($Ang >= 180) And ($Ang < 225)
                        $Item = 5
                    Case ($Ang >= 225) And ($Ang < 270)
                        $Item = 6
                    Case ($Ang >= 270) And ($Ang < 315)
                        $Item = 7
                    Case Else
                        $Item = 8
                EndSelect
            EndIf
            If $Prev <> $Item Then
                _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[$Item][1])
                $Prev = $Item
            EndIf
            If ($Pos[0] = $Tip[0]) And ($Pos[1] = $Tip[1]) Then
                If ($Item) And ($Timer) And (TimerDiff($Timer) > 500) Then
                    ToolTip('Action ' & $Item, $Pos[0] + 8, $Pos[1] + 22)
                    $Timer = 0
                EndIf
            Else
                $Timer = TimerInit()
                $Tip[0] = $Pos[0]
                $Tip[1] = $Pos[1]
                ToolTip('')
            EndIf
        WEnd
        _WinAPI_SetSystemCursor($hPrev, 32512, 1)
        ToolTip('')
        For $i = 250 To 0 Step -5
            _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[$Item][1], $i)
            _Sleep(1)
        Next
        GUISetState(@SW_HIDE, $hForm)
        If $Item Then
            MsgBox(0, '', 'Action ' & $Item & '...')
        EndIf
    EndIf
WEnd

Func _Angle($X, $Y, $XC, $YC)
    If ($X = $XC) And ($Y = $YC) Then
        Return 0
    Else
        Return Mod(360 + 22.5 + ($Y > $YC) * 180 - ATan(($XC - $X) / ($YC - $Y)) * 45 / ATan(1), 360)
    EndIf
EndFunc   ;==>_Angle

Func _Sleep($iDelay)

    Local $Timer = TimerInit()

    While TimerDiff($Timer) < $iDelay
    WEnd
EndFunc   ;==>_Sleep

#Region GDI+ Functions

Func _GDIPlus_ImageClone($hImage)

    Local $aResult = DllCall($ghGDIPDll, 'uint', 'GdipCloneImage', 'ptr', $hImage, 'ptr*', 0)

    If @error Then
        Return SetError(@error, @extended, 0)
    EndIf
    Return $aResult[2]
EndFunc   ;==>_GDIPlus_ImageClone

Func _GDIPlus_ImageGetThumbnail($hImage, $iWidth, $iHeight)

    Local $aResult = DllCall($ghGDIPDll, 'uint', 'GdipGetImageThumbnail', 'ptr', $hImage, 'int', $iWidth, 'int', $iHeight, 'ptr*', 0, 'ptr', 0, 'ptr', 0)

    If @error Then
        Return SetError(@error, @extended, 0)
    EndIf
    Return $aResult[4]
EndFunc   ;==>_GDIPlus_ImageGetThumbnail

#EndRegion GDI+ Functions

CircularMenu.7z

Previous downloads: 663

CircularMenu.7z

Edited by Yashied
  • 10 months later...
Posted

Just came across this script and wanted to give it a try, sadly I'm getting some errors that I'm unable to resolve.

>Running AU3Check (1.54.19.0)  from:C:Program Files (x86)AutoIt3
C:UsersmdwerneDownloadsCircularMenuEx.au3(52,54) : ERROR: _WinAPI_UpdateLayeredWindowEx() called with wrong number of args.
  _WinAPI_UpdateLayeredWindowEx($hForm, $hImage[0][1])
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersmdwerneDownloadsCircularMenuWinAPIEx.au3(29916,93) : REF: definition of _WinAPI_UpdateLayeredWindowEx().
Func _WinAPI_UpdateLayeredWindowEx($hWnd, $iX, $iY, $hBitmap, $iOpacity = 255, $fDelete = 0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersmdwerneDownloadsCircularMenuEx.au3(210,60) : ERROR: _WinAPI_UpdateLayeredWindowEx() called with wrong number of args.
    _WinAPI_UpdateLayeredWindowEx($hForm, $hImage[$Item][1])
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersmdwerneDownloadsCircularMenuWinAPIEx.au3(29916,93) : REF: definition of _WinAPI_UpdateLayeredWindowEx().
Func _WinAPI_UpdateLayeredWindowEx($hWnd, $iX, $iY, $hBitmap, $iOpacity = 255, $fDelete = 0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersmdwerneDownloadsCircularMenuEx.au3(228,63) : ERROR: _WinAPI_UpdateLayeredWindowEx() called with wrong number of args.
   _WinAPI_UpdateLayeredWindowEx($hForm, $hImage[$Item][1], $i)
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersmdwerneDownloadsCircularMenuWinAPIEx.au3(29916,93) : REF: definition of _WinAPI_UpdateLayeredWindowEx().
Func _WinAPI_UpdateLayeredWindowEx($hWnd, $iX, $iY, $hBitmap, $iOpacity = 255, $fDelete = 0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersmdwerneDownloadsCircularMenuEx.au3 - 3 error(s), 0 warning(s)
!>08:26:11 AU3Check ended.rc:2
>Exit code: 0    Time: 4.833

I assume some changes were made to WinAPIEx.au3 that are affecting this script. Any thoughts?

Thanks,

-Mike

Posted (edited)

Replace everywhere

_WinAPI_UpdateLayeredWindowEx($hForm, ...)

to

_WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, ...)

Sure ? ( _WinAPI_UpdateLayeredWindowEx ( $hWnd, $hBitmap, $iX, $iY [, $iOpacity [, $fDelete]] ) ) :D

Can't get it working...

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Posted (edited)

Can't get it working..

Try start this and press middle mouse button anywhere. To select menu item you should hold and move mouse cursor.

This ex1.au3 is Yashied's one which can change animation of itself from it's circular menu.

Look at $Action and cases of Switch.

#Include <GDIPlus.au3>
#Include <Misc.au3>
#Include <WinAPIEx.au3>
#Include <WindowsConstants.au3>
Opt('WinWaitDelay', 0)
Global $Action = 1
_GDIPlus_Startup()
$hHand = _WinAPI_LoadCursorFromFile(@ScriptDir & 'Arrow.cur')
$hPrev = _WinAPI_CopyCursor(_WinAPI_LoadCursor(0, 32512))
Dim $hImage[9][2]
For $i = 0 To 8
$hImage[$i][0] = _GDIPlus_ImageLoadFromFile(StringFormat(@ScriptDir & '%02d.png', $i))
$hImage[$i][1] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage[$i][0])
Next
$hForm = GUICreate('', 190, 190, -1, -1, $WS_POPUPWINDOW, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST), GUICreate('', -1, -1, -1, -1, -1, $WS_EX_TOOLWINDOW))
Dim $Tip[2]
While 1
Sleep(100)
If _IsPressed('04') Then
  $XY = MouseGetPos()
  GUISetState(@SW_SHOWNOACTIVATE, $hForm)
Switch $Action
; Animation 1
case 1
  WinMove($hForm, '', $XY[0] - 95, $XY[1] - 95, 190, 190)
  $hPng = _GDIPlus_ImageClone($hImage[0][0])
  $hGraphic = _GDIPlus_ImageGetGraphicsContext($hPng)
  For $i = 5 To 255 Step 5
   $Size = Round(190 * $i / 255)
   If Mod($Size, 2) Then
    $Size += 1
   EndIf
   _GDIPlus_GraphicsClear($hGraphic, 0)
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage[0][0], (190 - $Size) / 2, (190 - $Size) / 2, $Size, $Size)
   _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, _GDIPlus_BitmapCreateHBITMAPFromBitmap($hPng), $i, 1)
;   _Sleep(1)
  Next
  _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[0][1])
  _GDIPlus_GraphicsDispose($hGraphic)
  _GDIPlus_ImageDispose($hPng)
; Animation 2
case 2
;#cs
  WinMove($hForm, '', $XY[0] - 190, $XY[1] - 190, 380, 380)
  $hPng = _GDIPlus_ImageGetThumbnail($hImage[0][0], 380, 380)
  $hGraphic = _GDIPlus_ImageGetGraphicsContext($hPng)
  For $i = 5 To 255 Step 5
   $Size = Round(190 * (2 - $i / 255))
   If Mod($Size, 2) Then
    $Size += 1
   EndIf
   _GDIPlus_GraphicsClear($hGraphic, 0)
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage[0][0], (380 - $Size) / 2, (380 - $Size) / 2, $Size, $Size)
   _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, _GDIPlus_BitmapCreateHBITMAPFromBitmap($hPng), $i, 1)
;   _Sleep(1)
  Next
  _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[0][1], 0)
  WinMove($hForm, '', $XY[0] - 95, $XY[1] - 95, 190, 190)
  _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[0][1])
  _GDIPlus_GraphicsDispose($hGraphic)
  _GDIPlus_ImageDispose($hPng)
;#ce
; Animation 3
case 3
;#cs
  WinMove($hForm, '', $XY[0] - 95, $XY[1] - 95, 190, 190)
  $hMatrix = _GDIPlus_MatrixCreate()
  $hPng = _GDIPlus_ImageClone($hImage[0][0])
  $hGraphic = _GDIPlus_ImageGetGraphicsContext($hPng)
  _GDIPlus_MatrixTranslate($hMatrix, 95, 95)
  For $i = 5 To 255 Step 5
   If $i = 5 Then
    _GDIPlus_MatrixRotate($hMatrix, -75)
   Else
    _GDIPlus_MatrixRotate($hMatrix, 1.5)
   EndIf
   _GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix)
   _GDIPlus_GraphicsClear($hGraphic, 0)
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage[0][0], -95, -95, 190, 190)
   _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, _GDIPlus_BitmapCreateHBITMAPFromBitmap($hPng), $i, 1)
;   _Sleep(1)
  Next
  _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[0][1])
  _GDIPlus_GraphicsDispose($hGraphic)
  _GDIPlus_MatrixDispose($hMatrix)
  _GDIPlus_ImageDispose($hPng)
;#ce
; Animation 4
case 4
;#cs
  WinMove($hForm, '', $XY[0] - 95, $XY[1] - 95, 190, 190)
  For $i = 5 To 255 Step 5
   _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[0][1], $i)
   _Sleep(1)
  Next
;#ce
; Animation 5
case 5
;#cs
  WinMove($hForm, '', $XY[0] - 95, $XY[1] - 95, 190, 190)
  $hMatrix = _GDIPlus_MatrixCreate()
  $hPng = _GDIPlus_ImageClone($hImage[0][0])
  $hGraphic = _GDIPlus_ImageGetGraphicsContext($hPng)
  _GDIPlus_MatrixTranslate($hMatrix, 95, 95)
  For $i = 5 To 255 Step 5
   $Size = Round(190 * $i / 255)
   If Mod($Size, 2) Then
    $Size += 1
   EndIf
   If $i = 5 Then
    _GDIPlus_MatrixRotate($hMatrix, -100)
   Else
    _GDIPlus_MatrixRotate($hMatrix, 2)
   EndIf
   _GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix)
   _GDIPlus_GraphicsClear($hGraphic, 0)
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage[0][0], (190 - $Size) / 2 - 95, (190 - $Size) / 2 - 95, $Size, $Size)
   _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, _GDIPlus_BitmapCreateHBITMAPFromBitmap($hPng), $i, 1)
   _Sleep(1)
  Next
  _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[0][1])
  _GDIPlus_GraphicsDispose($hGraphic)
  _GDIPlus_MatrixDispose($hMatrix)
  _GDIPlus_ImageDispose($hPng)
;#ce
; Animation 6
case 6
;#cs
  WinMove($hForm, '', $XY[0] - 190, $XY[1] - 190, 380, 380)
  $hMatrix = _GDIPlus_MatrixCreate()
  $hPng = _GDIPlus_ImageGetThumbnail($hImage[0][0], 380, 380)
  $hGraphic = _GDIPlus_ImageGetGraphicsContext($hPng)
  _GDIPlus_MatrixTranslate($hMatrix, 190, 190)
  For $i = 5 To 255 Step 5
   $Size = Round(190 * (2 - $i / 255))
   If Mod($Size, 2) Then
    $Size += 1
   EndIf
   If $i = 5 Then
    _GDIPlus_MatrixRotate($hMatrix, -100)
   Else
    _GDIPlus_MatrixRotate($hMatrix, 2)
   EndIf
   _GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix)
   _GDIPlus_GraphicsClear($hGraphic, 0)
   _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage[0][0], (380 - $Size) / 2 - 190, (380 - $Size) / 2 - 190, $Size, $Size)
   _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, _GDIPlus_BitmapCreateHBITMAPFromBitmap($hPng), $i, 1)
   _Sleep(1)
  Next
  _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[0][1], 0)
  WinMove($hForm, '', $XY[0] - 95, $XY[1] - 95, 190, 190)
  _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[0][1])
  _GDIPlus_GraphicsDispose($hGraphic)
  _GDIPlus_MatrixDispose($hMatrix)
  _GDIPlus_ImageDispose($hPng)
;#ce
    case else
        WinMove($hForm, '', $XY[0] - 95, $XY[1] - 95, 190, 190)
        For $i = 5 To 255 Step 5
            _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[0][1], $i)
            _Sleep(1)
        Next
endswitch
  $Timer = 0
  $Tip[0] = -1
  $Tip[1] = -1
  $Item = 0
  $Prev = 0
  _WinAPI_SetSystemCursor($hHand, 32512, 1)
  While _IsPressed('04')
   $Pos = MouseGetPos()
   $R = Sqrt(($XY[0] - $Pos[0]) ^ 2 + ($XY[1] - $Pos[1]) ^ 2)
   If ($R < 47) Or ($R > 95) Then
    $Item = 0
   Else
    $Ang = _Angle($Pos[0], $Pos[1], $XY[0], $XY[1])
    Select
     Case ($Ang >= 0  ) And ($Ang < 45 )
      $Item = 1
     Case ($Ang >= 45 ) And ($Ang < 90 )
      $Item = 2
     Case ($Ang >= 90 ) And ($Ang < 135)
      $Item = 3
     Case ($Ang >= 135) And ($Ang < 180)
      $Item = 4
     Case ($Ang >= 180) And ($Ang < 225)
      $Item = 5
     Case ($Ang >= 225) And ($Ang < 270)
      $Item = 6
     Case ($Ang >= 270) And ($Ang < 315)
      $Item = 7
     Case Else
      $Item = 8
    EndSelect
   EndIf
   If $Prev <> $Item Then
    _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[$Item][1])
    $Prev = $Item
   EndIf
   If ($Pos[0] = $Tip[0]) And ($Pos[1] = $Tip[1]) Then
    If ($Item) And ($Timer) And (TimerDiff($Timer) > 500) Then
     ToolTip('Action ' & $Item, $Pos[0] + 8, $Pos[1] + 22)
     $Timer = 0
    EndIf
   Else
    $Timer = TimerInit()
    $Tip[0] = $Pos[0]
    $Tip[1] = $Pos[1]
    ToolTip('')
   EndIf
  WEnd
  _WinAPI_SetSystemCursor($hPrev, 32512, 1)
  ToolTip('')
  For $i = 250 To 0 Step -5
   _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hImage[$Item][1], $i)
   _Sleep(1)
  Next
  GUISetState(@SW_HIDE, $hForm)
  If $Item Then
   $Action = $Item
   ;MsgBox(0, '', 'Action ' & $Item & '...')
  EndIf
EndIf
WEnd
Func _Angle($X, $Y, $XC, $YC)
If ($X = $XC) And ($Y = $YC) Then
  Return 0
Else
  Return Mod(360 + 22.5 + ($Y > $YC) * 180 - ATan(($XC - $X) / ($YC - $Y)) * 45 / ATan(1), 360)
EndIf
EndFunc   ;==>_Angle
Func _Sleep($iDelay)
Local $Timer = TimerInit()
While TimerDiff($Timer) < $iDelay
WEnd
EndFunc   ;==>_Sleep
#Region GDI+ Functions
Func _GDIPlus_ImageClone($hImage)
Local $aResult = DllCall($ghGDIPDll, 'uint', 'GdipCloneImage', 'ptr', $hImage, 'ptr*', 0)
If @error Then
  Return SetError(@error, @extended, 0)
EndIf
Return $aResult[2]
EndFunc   ;==>_GDIPlus_ImageClone
Func _GDIPlus_ImageGetThumbnail($hImage, $iWidth, $iHeight)
Local $aResult = DllCall($ghGDIPDll, 'uint', 'GdipGetImageThumbnail', 'ptr', $hImage, 'int', $iWidth, 'int', $iHeight, 'ptr*', 0, 'ptr', 0, 'ptr', 0)
If @error Then
  Return SetError(@error, @extended, 0)
EndIf
Return $aResult[4]
EndFunc   ;==>_GDIPlus_ImageGetThumbnail
#EndRegion GDI+ Functions
Edited by ValeryVal

The point of world view

Posted (edited)

Wrong description. Fixed.

You are right, but i have extract this Syntax of the description of _WinAPI_UpdateLayeredWindowEx Function in WinApiEx.au3 3.5 :D

; Syntax.........: _WinAPI_UpdateLayeredWindowEx ( $hWnd, $hBitmap, $iX, $iY [, $iOpacity [, $fDelete]] )

...

Func _WinAPI_UpdateLayeredWindowEx($hWnd, $iX, $iY, $hBitmap, $iOpacity = 255, $fDelete = 0)

Nice Work !

@ValeryVal

Thanks.

In the doubt i have tried on another PC and it works well with Yashield modifs.

My middle mouse button was in cause... :oops:

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Posted

for some reason I get

C:UsersraintabbedEx.au3(44,55) : ERROR: _WinAPI_UpdateLayeredWindowEx() called with wrong number of args.
  _WinAPI_UpdateLayeredWindowEx($hForm,  $hImage[0][1])
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersraintabbedWinAPIEx.au3(29916,93) : REF: definition of _WinAPI_UpdateLayeredWindowEx().
Func _WinAPI_UpdateLayeredWindowEx($hWnd, $iX, $iY, $hBitmap, $iOpacity = 255, $fDelete = 0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersraintabbedEx.au3(202,60) : ERROR: _WinAPI_UpdateLayeredWindowEx() called with wrong number of args.
    _WinAPI_UpdateLayeredWindowEx($hForm, $hImage[$Item][1])
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersraintabbedWinAPIEx.au3(29916,93) : REF: definition of _WinAPI_UpdateLayeredWindowEx().
Func _WinAPI_UpdateLayeredWindowEx($hWnd, $iX, $iY, $hBitmap, $iOpacity = 255, $fDelete = 0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersraintabbedEx.au3(220,63) : ERROR: _WinAPI_UpdateLayeredWindowEx() called with wrong number of args.
   _WinAPI_UpdateLayeredWindowEx($hForm, $hImage[$Item][1], $i)
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersraintabbedWinAPIEx.au3(29916,93) : REF: definition of _WinAPI_UpdateLayeredWindowEx().
Func _WinAPI_UpdateLayeredWindowEx($hWnd, $iX, $iY, $hBitmap, $iOpacity = 255, $fDelete = 0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersraintabbedEx.au3 - 3 error(s), 0 warning(s)

edited

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...