Jump to content

zelda like annoyingness


BAM5
 Share

Recommended Posts

Got it.

#Include <GDIPlus.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global Const $AC_SRC_ALPHA      = 1
Global Const $ULW_ALPHA         = 2

_GDIPlus_Startup()
$sImg = @ScriptDir & '\Navi.png'
$hImage = _GDIPlus_ImageLoadFromFile($sImg)
$iWidth =  _GDIPlus_ImageGetWidth ($hImage)
$iHeight = _GDIPlus_ImageGetHeight($hImage)

$iCount = 0
$gui = GUICreate('Navi', $iWidth, $iHeight, Default, Default, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
_SetBitMap($GUI, $hImage, 255)
GUISetState()

Dim $aText[2] = [ 'Hey!', 'Listen!' ]

Global $iTimer = TimerInit()
Global $iTextRand = Random(0, 1, 1)
Global $iTextTime = Random(3, 5, 1) * 1000
While 1
    If GUIGetMsg() = -3 Then Exit
    $aMouse = MouseGetPos()
    $iCount += 1
    
    $iX = $aMouse[0] + $iWidth + Cos($iCount / 30) * 40
    $iY = $aMouse[1] - ($iHeight * 2) + Sin($iCount / 15) * 20

    If TimerDiff($iTimer) > $iTextTime Then
        ToolTip($aText[$iTextRand], $iX + $iWidth, $iY + $iHeight, '', 0, 0)
        If TimerDiff($iTimer) > $iTextTime + 1000 Then
            $iTextRand = Random(0, 1, 1)
            $iTextTime = Random(3, 5, 1) * 1000
            $iTimer = TimerInit()
            ToolTip('')         
        EndIf
    EndIf

    WinMove($gui, '', $iX, $iY)
    Sleep(10)
WEnd

Func _SetBitMap($hGUI, $hImage, $iOpacity)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

    $hScrDC  = _WinAPI_GetDC(0)
    $hMemDC  = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld    = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize   = DllStructCreate($tagSIZE)
    $pSize   = DllStructGetPtr($tSize  )
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth ($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend  = DllStructCreate($tagBLENDFUNCTION)
    $pBlend  = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha" , $iOpacity    )
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC   (0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC    ($hMemDC)
EndFunc

You'll need this image:

http://www.therks.com/autoit/Navi.png

Link to comment
Share on other sites

I modified Saunders version :P

#Include <GDIPlus.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global Const $AC_SRC_ALPHA      = 1
Global Const $ULW_ALPHA         = 2

_GDIPlus_Startup()
$sImg = @ScriptDir & '\Navi.png'
$hImage = _GDIPlus_ImageLoadFromFile($sImg)
$iWidth =  _GDIPlus_ImageGetWidth ($hImage)
$iHeight = _GDIPlus_ImageGetHeight($hImage)

$iCount = 0
$gui = GUICreate('Navi', $iWidth, $iHeight, Default, Default, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
_SetBitMap($GUI, $hImage, 255)
GUISetState()

Dim $aText[2] = [ '\hey.mp3', '\listen.mp3' ]

Global $iTimer = TimerInit()
Global $iTextRand = Random(0, 1, 1)
Global $iTextTime = Random(3, 5, 1) * 1000
While 1
    If GUIGetMsg() = -3 Then Exit
    $aMouse = MouseGetPos()
    $iCount += 1
    
    $iX = $aMouse[0] + $iWidth + Cos($iCount / 30) * 40
    $iY = $aMouse[1] - ($iHeight * 2) + Sin($iCount / 15) * 20

    If TimerDiff($iTimer) > $iTextTime Then
        SoundPlay(@ScriptDir & $aText[$iTextRand])
        ;ToolTip($aText[$iTextRand], $iX + $iWidth, $iY + $iHeight, '', 0, 0)
        If TimerDiff($iTimer) > $iTextTime + 1000 Then
            $iTextRand = Random(0, 1, 1)
            $iTextTime = Random(3, 5, 1) * 1000
            $iTimer = TimerInit()
            ;ToolTip('')   
        EndIf
    EndIf

    WinMove($gui, '', $iX, $iY)
    Sleep(10)
WEnd

Func _SetBitMap($hGUI, $hImage, $iOpacity)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

    $hScrDC  = _WinAPI_GetDC(0)
    $hMemDC  = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld    = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize   = DllStructCreate($tagSIZE)
    $pSize   = DllStructGetPtr($tSize  )
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth ($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend  = DllStructCreate($tagBLENDFUNCTION)
    $pBlend  = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha" , $iOpacity    )
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC   (0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC    ($hMemDC)
EndFunc

Download these files:

http://sascha.kiloswiss.ch/uploads/files/sounds/hey.mp3

http://sascha.kiloswiss.ch/uploads/files/sounds/listen.mp3

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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