Jump to content

Seeking reason why one transparent GIF works GuiCtrlCreatePic but another doesn't

Recommended Posts

I found the following code in a forum post by newbiescripter, which displays a transparent gif "crosshair".

#include <WindowsConstants.au3>

$x = @DesktopWidth/2 - 13/2
$y = @DesktopHeight/2 - 13/2



It works great... with the gif file included in newbiescripter's post. I was able to modify the gif in CS6 for my needs but I'm really curious why another gif that I created from scratch in CS6 does not display with transparency in the same script. (I know how to create transparent gifs, and mine opens in CS6 with transparency intact.) I'm probably just knackered from long hours but I give up and submit my question here despite the probability of embarrassment. 

See attached. "Crosshair.gif" is the one that works. "Target.gif" is the one that doesn't. "Target.psd" is the original PSD file. (oops, not allowed)



Edited by timmy2
Link to post
Share on other sites

Did you set correct height and weight for your picture?


Actually, I want the crosshairs to be smaller than the original so I changed my version of the code to 13 (see multiple occurrences) from the original value of 68. It shrinks the crosshair.gif file perfectly.  My target.gif is 8-bit just like crosshair.gif is.

Link to post
Share on other sites

Use GDI+. Example here:




Thank you for replying, UEZ, but what are the advantages of GDI+ over what newbiescripter used?

I'm trying to figure out why my gif's transparency won't play when the original gif's transparency will.

Link to post
Share on other sites

Image handling via GDI+ is much better than using the built-in stuff. Why are built-in functions not working for some image formats properly? I don't know.



Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Gianni
      (This example uses a "flash" animation and therefore needs the "flash player" to work. Since "flash player" is discontinued and no longer present on many systems, this script may not work. I have therefore prepared a new script which does not use flash, but is based only on javascript. You can find it in this new post: www.autoitscript.com/forum/topic/206853-aquarium)
      If you set within a window, a given color as transparent, every area of that window painted with that color, act as an hole through wich you can see what's behind, and click on what's behind as well.
      What's funny is that if you embed a browser control within that window, the "transparent" color works even within the browser! This allow some interesting effects by simply opening any of the many javascript animations, or css effects or whatever within a browser control embedded into a GUI:
      Here, for example, is a simple effect of fishes swimming around on the screen.
      For lazyness I have embedded an ready made swf flash by a link to the web, but is of course possible embed any web page with javascripts css or whatever.....
      Have fun
      #include <WinAPI.au3> #include <WindowsConstants.au3> #include <Misc.au3> ; for _IsPressed (23 END key) Local $hDLL = DllOpen("user32.dll"), $oIE = ObjCreate("Shell.Explorer.2") Local $hBackground = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUPWINDOW, $WS_EX_LAYERED + $WS_EX_TOPMOST) Local $AlphaKey = 0xF0F7FF ; everything with color $AlphaKey within this window will be transparent ; even if within an embedded browser control!..... _WinAPI_SetLayeredWindowAttributes($hBackground, $AlphaKey, 0, $LWA_COLORKEY) GUISetState(@SW_SHOW, $hBackground) $hIE = GUICtrlCreateObj($oIE, 0, 0, @DesktopWidth, @DesktopHeight) ; <- embedd $oIE in the AutoIt GUI GUISetBkColor($AlphaKey, $hBackground) ; $AlphaKey $hBackground transparent $oIE.navigate('http://cdn.abowman.com/widgets/fish/fish.swf') ; $oIE.navigate('http://cdn.abowman.com/widgets/spider/spider.swf') ; a spider goes around on the screen .... ; !! to use the spider.swf, you need to set $AlphaKey = 0xffffff on line 7 "! While True If _IsPressed("23", $hDLL) Then ExitLoop ; END key was pressed Sleep(250) WEnd $oIE = "" $hDLL = "" GUIDelete($hBackground)  
    • By Gianni
      This script is an alternative (improvement) to the script published at this link (www.autoitscript.com/forum/topic/186225-interesting-effect-with-transparency). In that post a flash animation was used and therefore you need the flash player to work, while here only javascript is used.
      Here, too, the aim is to show an interesting effect that can be obtained by exploiting transparency, but can also be used as it is just for fun.
      The animation consists of some fish wandering around the screen. You can continue working on the computer by letting them swim.
      The javascript source was not written by me, but I got it from this link: https://github.com/lrusso/Aquarium. I shrunk it down a bit and tweaked it so that fish can swim across the entire screen even with different sized monitors.
      The fish images and html and javascript sources have been bundled into a single "monolithic" AutoIt script, so it's easier to run.
      I hope you find it relaxing.
      Have fun
    • By XGamerGuide
      I'm trying to display a GIF. However, the GUI should not be visible. Here is an attempt that doesn't work:
      $sGIF = "MyGIF.gif" #Include <IE.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WINAPI.au3> #include <SendMessage.au3> Global Const $SC_DRAGMOVE = 0xF012 HotKeySet("{ESC}", "_Exit") $hGui = GUICreate("Test", 400, 300, -1, -1, $WS_POPUP, $WS_EX_LAYERED) GUISetBkColor(0xABCDEF) $oIE = _IECreateEmbedded() GUICtrlCreateObj($oIE, 10, 10, 380, 280) _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 250) _IENavigate($oIE, $sGIF) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_PRIMARYDOWN _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndSwitch WEnd Func _Exit() Exit  
    • By MASKED
      hi guys
      i am using imagesearch2015 library. (used another one before)
      but transparency parameter doesn't working. how i can solve this problem.
      here's my code
      #include "ImageSearch2015.au3" #include <Date.au3> ; Script Start - Add your code below here Global $x = 0 Global $y = 0 HotKeySet("{UP}","hey") HotKeySet("{DOWN}","heyo") Func hey() $balikcisaniye = _Date_Time_GetTickCount() $array = _ImageSearchArea("bul.bmp", 1, 0, 0, @DesktopWidth, @DesktopHeight, $x, $y, 2,0x000000) if($array = True) Then $balikcisaniye1 = _Date_Time_GetTickCount() MouseMove($x,$y) MsgBox(1,"","Found." & $x & "-" & $y & " / " & $balikcisaniye1-$balikcisaniye) Else MsgBox(1,"","Not Found.") EndIf EndFunc Func heyo() exit EndFunc while 1 WEnd when i disable transparency parameter, it work normal. but with parameter, this function is always returning false.
      please help.
      here's library i use :
    • By Emanoel
      Hi, I have a problem with GUICtrlCreatePic(). In topic WMPlayer.ocx how to change the shuttle picture? I wanted to replace the shuttle picture with a custom one (which I sent below the code) but got some weird results.
      #include <GuiConstants.au3> #include <Misc.au3> Global $Paused = False, $SliderButton = @ScriptDir & "\SliderButton.jpg" $hGui = GUICreate("Music Player", 400, 75, -1, -1) $Label1 = GUICtrlCreateButton("", 0, 0, 400, 20) ;music name GUICtrlSetState(-1, $GUI_DISABLE) $Shuttle = GUICtrlCreatePic($SliderButton, 0, 6, 30, 13) $PauseButton = GUICtrlCreateButton("Pause", 208, 40, 80, 20) GUISetOnEvent($PauseButton, "PauseButton") $PlayButton = GUICtrlCreateButton("Play", 112, 40, 80, 20) $Progress = GUICtrlCreateLabel("0:00", 4, 25, 45, 20, $SS_LEFT) ; current media position $Length = GUICtrlCreateLabel("0:00", 350, 25, 45, 20, $SS_RIGHT) ; media length GUISetState(@SW_SHOW) $FilePath = "" ;your music path & .mp3 $oPlayer = ObjCreate("WMPlayer.OCX") If Not IsObj($oPlayer) Then MsgBox(0, "WMPlayer.OCX", "Cannot create a WMP object.", 5) GUIDelete($hGui) Exit EndIf $iPos = 0 ; x coordinate of $Shuttle control in progress bar $hDLL = DllOpen("user32.dll") ; to dectect mouse down on the $Shuttle control $sliderLength = 380 ; in pixels $adlibInterval = 250 ; in milliseconds $oPlayer.Settings.Volume = 100 While 1 $oPlayer.URL = $FilePath $hTimer = TimerInit() While $oPlayer.playState <> 3 ; 1 - stopped, 2 - paused, 3 - playing If TimerDiff($hTimer) > 3000 Then MsgBox(0, "WMPlayer.OCX", $FilePath & @CRLF & @CRLF & "Cannot play this file.", 5) ExitLoop EndIf Sleep(5) WEnd If $oPlayer.playState <> 3 Then ContinueLoop EndIf $sFile = StringMid($FilePath, StringInStr($FilePath, "\", 0, -1) + 1) GUICtrlSetData($Label1, $sFile) $mediaLength = Int($oPlayer.currentMedia.Duration) ; in seconds GUICtrlSetData($Length, Int($mediaLength / 60) & ":" & StringFormat("%02i", Mod($mediaLength, 60))) AdlibRegister("Slider", $adlibInterval) $oPlayer.Controls.Pause While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE $oPlayer.Close Exit Case $PlayButton If GUICtrlRead($PlayButton) = "Play" Then $oPlayer.Controls.Play AdlibRegister("Slider") GUICtrlSetData($PlayButton, "Stop") Else $oPlayer.Controls.currentPosition = 0 $oPlayer.Controls.Pause GUICtrlSetData($PlayButton, "Play") EndIf If $Paused Then While $Paused Sleep(100) WEnd EndIf Case $Shuttle AdlibUnRegister() $x = MouseGetPos(0) $xOffset = $x - $iPos While _IsPressed("01", $hDLL) = 1 $x = MouseGetPos(0) If $x > 380 + $xOffset Then $x = 380 + $xOffset ElseIf $x < $xOffset Then $x = $xOffset EndIf $iPos = $x - $xOffset GUICtrlSetPos($Shuttle, $iPos) Sleep(1) WEnd $mediaPos = $iPos / $sliderLength * $mediaLength $oPlayer.Controls.currentPosition = $mediaPos AdlibRegister("Slider", $adlibInterval) GUICtrlSetData($PauseButton, "Pause") EndSwitch If $oPlayer.playState = 1 Then ExitLoop EndIf WEnd WEnd Func PauseButton() If $Paused = False Then $oPlayer.Controls.Pause AdlibUnRegister() $Paused = True GUICtrlSetData($PauseButton, "Resume") Else $oPlayer.Controls.Play AdlibRegister("Slider") $Paused = False GUICtrlSetData($PauseButton, "Pause") EndIf EndFunc ;==>PauseButton Func Slider() $mediaPos = $oPlayer.Controls.currentPosition $iPos = $mediaPos * $sliderLength / $mediaLength GUICtrlSetPos($Shuttle, $iPos) GUICtrlSetData($Progress, Int($mediaPos / 60) & ":" & StringFormat("%02i", Mod($mediaPos, 60))) EndFunc ;==>Slider Also how can I set buttons to act like OnEvent button? I tried for $PauseButton but didn't make it. So I didn't do it for $PlayButton and $Shuttle. I want to add some lines from my main source to $PlayButton and since I used while loop in those lines (while the song is not over), I should control song (Pause/Resume, adjust position) anytime I want.

  • Create New...