KenKen Posted October 30, 2021 Share Posted October 30, 2021 Hi ! I try to do a mouse bounce on my screen like the famous dvd bounce screen but i don't understand how to do it. So if anyone made this script could they share it so i can learn how its was done ? Thanks in advance. Link to comment Share on other sites More sharing options...
Gianni Posted October 30, 2021 Share Posted October 30, 2021 (edited) expandcollapse popup#include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> ; #include <WinAPISysWin.au3> #include <WinAPI.au3> HotKeySet("{ESC}", "_Exit") Global $hGUI, $iWidth, $iHeight example() Func example() Local $sFileImage = @TempDir & "\logo.png" Local $sImageURL = "https://logodix.com/logo/1059815.png" Local $x = 10, $y = 10, $xDirection = 3, $yDirection = 3, $aPos If Not FileExists($sFileImage) Then InetGet($sImageURL, $sFileImage) _SetImage($x, $y, $sFileImage) ; FileDelete($sFileImage) While 1 $aPos = WinGetPos($hGUI) $x = $aPos[0] $y = $aPos[1] If $x + $iWidth > @DesktopWidth Then $x = @DesktopWidth - $iWidth $xDirection *= -1 EndIf If $x < 0 Then $x = 0 $xDirection *= -1 EndIf If $y + $iHeight > @DesktopHeight Then $y = @DesktopHeight - $iHeight $yDirection *= -1 EndIf If $y < 0 Then $y = 0 $yDirection *= -1 EndIf $x += $xDirection $y += $yDirection WinMove($hGUI, '', $x, $y) Sleep(10) WEnd FileDelete($sFileImage) EndFunc ;==>example Func _SetImage($Left, $Top, $Picture, $iOpacity = 255) _GDIPlus_Startup() Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend Local $hImage = _GDIPlus_ImageLoadFromFile($Picture) $iWidth = _GDIPlus_ImageGetWidth($hImage) $iHeight = _GDIPlus_ImageGetHeight($hImage) $hGUI = GUICreate('', $iWidth, $iHeight, $Left, $Top, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) Local $hLabel = GUICtrlCreateLabel('', 0, 0, $iWidth, $iHeight, -1, $GUI_WS_EX_PARENTDRAG) GUISetState(@SW_SHOW, $hGUI) $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", $iWidth) DllStructSetData($tSize, "Y", $iHeight) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _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) _GDIPlus_Shutdown() Return $hGUI EndFunc ;==>_SetImage Func _Exit() If WinActive("[ACTIVE]") = $hGUI Then Exit EndFunc ;==>_Exit Edited October 31, 2021 by Chimp removed FileDelete() Leendert-Jan 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now