Sign in to follow this  
Followers 0
henrychien

how can i make my move-pic stable on my gui ?

11 posts in this topic

#1 ·  Posted (edited)

I got something problem on my scrip ,

(i got 36 * pic , if continue show it from 1~36 pic , then it will be show a cool move-show-pic .)

i want to show a move-pic on my GUI , BUT ,

THE pic always unstable,coz the pic always flash ,

why?

how can i make it stable?

could someone can teach me and thank you first!!

#include <GUIConstants.au3>

Global $right, $Photo_path, $msg, $Main_Win

Global $0,$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$23,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31,$32,$33,$34,$35,$36

Global $AD_Pic_Left, $AD_Pic_Top, $AD_Pic_Width, $AD_Pic_Height

$right=0

$Photo_path = "F:\PROGRAMEFILE\PIC\"

$AD_Pic_Left = 10

$AD_Pic_Top = 260

$AD_Pic_Width = 380

$AD_Pic_Height = 100

;==================================== MAIN =======================================

MainMenu ()

AD_Flash ()

;===================================== FUNC =======================================

Func MainMenu ()

$Main_Win = GUICreate("MY GUI MOVE-PIC")

GUISetBkColor (0xE0FFFF) ;MY GUI BACKGROUND COLOR

GUISetState ()

Return

EndFunc

Func Check_GUImsg ()

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then Exit

Return

EndFunc

Func AD_Flash ()

While 1

Check_GUImsg ()

Select

Case $right = 0

Check_GUImsg ()

$0=GUICtrlCreatePic($Photo_path & "1.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 1

Case $right = 1

Check_GUImsg ()

$1=GUICtrlCreatePic($Photo_path & "2.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 2

Case $right = 2

Check_GUImsg ()

$2=GUICtrlCreatePic($Photo_path & "3.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 3

Case $right = 3

Check_GUImsg ()

$3=GUICtrlCreatePic($Photo_path & "4.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 4

Case $right = 4

Check_GUImsg ()

$4=GUICtrlCreatePic($Photo_path & "5.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 5

Case $right = 5

Check_GUImsg ()

$5=GUICtrlCreatePic($Photo_path & "6.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 6

Case $right = 6

Check_GUImsg ()

$6=GUICtrlCreatePic($Photo_path & "7.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 7

Case $right = 7

Check_GUImsg ()

$7=GUICtrlCreatePic($Photo_path & "8.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 8

Case $right = 8

Check_GUImsg ()

$8=GUICtrlCreatePic($Photo_path & "9.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 9

Case $right = 9

Check_GUImsg ()

$9=GUICtrlCreatePic($Photo_path & "10.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 10

Case $right = 10

Check_GUImsg ()

$10=GUICtrlCreatePic($Photo_path & "11.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 11

Case $right = 11

Check_GUImsg ()

$11=GUICtrlCreatePic($Photo_path & "12.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 12

Case $right = 12

Check_GUImsg ()

$12=GUICtrlCreatePic($Photo_path & "13.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 13

Case $right = 13

Check_GUImsg ()

$13=GUICtrlCreatePic($Photo_path & "14.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 14

Case $right = 14

Check_GUImsg ()

$14=GUICtrlCreatePic($Photo_path & "15.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 15

Case $right = 15

Check_GUImsg ()

$15=GUICtrlCreatePic($Photo_path & "16.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 16

Case $right = 16

Check_GUImsg ()

$16=GUICtrlCreatePic($Photo_path & "17.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 17

Case $right = 17

Check_GUImsg ()

$17=GUICtrlCreatePic($Photo_path & "18.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 18

Case $right = 18

Check_GUImsg ()

$18=GUICtrlCreatePic($Photo_path & "19.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 19

Case $right = 19

Check_GUImsg ()

$19=GUICtrlCreatePic($Photo_path & "20.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 20

Case $right = 20

Check_GUImsg ()

$20=GUICtrlCreatePic($Photo_path & "21.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 21

Case $right = 21

Check_GUImsg ()

$21=GUICtrlCreatePic($Photo_path & "22.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 22

Case $right = 22

Check_GUImsg ()

$22=GUICtrlCreatePic($Photo_path & "23.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 23

Case $right = 23

Check_GUImsg ()

$23=GUICtrlCreatePic($Photo_path & "24.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 24

Case $right = 24

Check_GUImsg ()

$24=GUICtrlCreatePic($Photo_path & "25.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 25

Case $right = 25

Check_GUImsg ()

$25=GUICtrlCreatePic($Photo_path & "26.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 26

Case $right = 26

Check_GUImsg ()

$26=GUICtrlCreatePic($Photo_path & "27.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 27

Case $right = 27

Check_GUImsg ()

$27=GUICtrlCreatePic($Photo_path & "28.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 28

Case $right = 28

Check_GUImsg ()

$28=GUICtrlCreatePic($Photo_path & "29.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 29

Case $right = 29

Check_GUImsg ()

$29=GUICtrlCreatePic($Photo_path & "30.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 30

Case $right = 30

Check_GUImsg ()

$30=GUICtrlCreatePic($Photo_path & "31.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 31

Case $right = 31

Check_GUImsg ()

$31=GUICtrlCreatePic($Photo_path & "32.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 32

Case $right = 32

Check_GUImsg ()

$32=GUICtrlCreatePic($Photo_path & "33.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 33

Case $right = 33

Check_GUImsg ()

$33=GUICtrlCreatePic($Photo_path & "34.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 34

Case $right = 34

Check_GUImsg ()

$34=GUICtrlCreatePic($Photo_path & "35.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 35

Case $right = 35

Check_GUImsg ()

$35=GUICtrlCreatePic($Photo_path & "36.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 36

Case $right = 36

Check_GUImsg ()

$36=GUICtrlCreatePic($Photo_path & "37.gif",$AD_Pic_Left,$AD_Pic_Top, $AD_Pic_Width,$AD_Pic_Height)

$right = 0

EndSelect

Sleep ( 100 )

Wend

Return

EndFunc

Edited by henrychien

Share this post


Link to post
Share on other sites



If you are making a pseudo-animated gif, I think the flicker is something you'll have to accept.

Side note (suggestion): You might want to look into Arrays for this. Would be less code... could be smoother.

Share this post


Link to post
Share on other sites

If you are making a pseudo-animated gif, I think the flicker is something you'll have to accept.

Side note (suggestion): You might want to look into Arrays for this. Would be less code... could be smoother.

this gif is my file ( i created it ) , coz original file is one file , but "GUICtrlCreatePic()" funtion only could be read one pic,

so then i let it become to 36 pic and to do this .

i just dont know why can't stable

i was try many times , when $0 ~ $5 , they are smooth , but when go to $6 , it just got a flicker and i dont know why

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

so....could u tell me how could i to do , and let my GUI show a animated pic ,

what kind of function i could use it (howabout use "GUICtrlCreateAvi()" ? i dont know ),

or i need trace my gif file to "jpg" "bmp" or "avi" file????

now i dont have any idea to disposed of my problem

and thank you yur help

Edited by henrychien

Share this post


Link to post
Share on other sites

so....could u tell me how could i to do , and let my GUI show a animated pic ,

what kind of function i could use it (howabout use "GUICtrlCreateAvi()" ? i dont know ),

or i need trace my gif file to "jpg" "bmp" or "avi" file????

now i dont have any idea to disposed of my problem

and thank you yur help

You could use an AVI, but that is resource heavy.

The only other option, as far as i know, is to embed IE and display a webpage with the Gif file. Link below might help.

http://www.autoitscript.com/forum/index.ph...st&p=242515

Share this post


Link to post
Share on other sites

You could use an AVI, but that is resource heavy.

The only other option, as far as i know, is to embed IE and display a webpage with the Gif file. Link below might help.

http://www.autoitscript.com/forum/index.ph...st&p=242515

thank you "The Ape"

you are a kind man , i will say " you are a kind man " & "thank you" "thank you" "thank you" "thank you" "thank you"

I LOVE YOU & THANK YOU VERY MUCH

Share this post


Link to post
Share on other sites

#include<GUIConstants.au3>
#include<Ie.au3>
$gui=GUICreate("",610,800)
$oie=_IECreateEmbedded()
GUICtrlCreateObj($oie,0,0,610,800)
_IENavigate($oie,"about:blank")
_IEDocWriteHTML($oie,"<IMG src='http://ai.stanford.edu/~drago/Projects/scape/box.gif' />")
GUISetState()


While 1
    If GUIGetMsg()=$GUI_EVENT_CLOSE Then Exit
    Sleep(10)
WEnd

Here's an example of using gifs in html :) embeded in autoit


Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Hi henrychien,

why don't you shorten your code to this ... ? :)

(That's what 'Ape' meant ...)

#include <GUIConstants.au3>

$Photo_path = "F:\PROGRAMEFILE\PIC\"
$AD_Pic_Left = 10
$AD_Pic_Top = 260
$AD_Pic_Width = 380
$AD_Pic_Height = 100

$Main_Win = GUICreate("MY GUI MOVE-PIC")
GUISetBkColor (0xE0FFFF) ;MY GUI BACKGROUND COLOR
GUISetState ()

AD_Flash ()

Func AD_Flash ()
    
    $arGifs = _FileListToArray('$Photo_path', '*.gif', 1)    ; reads all gifs into an array ...
    While 1
        For $i = 1 To $arGifs[0]
            GUICtrlCreatePic($Photo_path & $arGifs[$i], $AD_Pic_Left, $AD_Pic_Top, $AD_Pic_Width, $AD_Pic_Height)
        Next
    WEnd
    
EndFunc

Take also a look at the AutoIt helpfile under 'GUICtrlCreatePic'.

The example script uses gif files !!! ^_^

Greetz

Greenhorn

Edited by Greenhorn

Share this post


Link to post
Share on other sites

Here's crude example using GDIPlus to draw your image on the gui, good thing is you can have the image moving or changing without flickering.

#include <GUIConstants.au3>
#include <File.au3>
#include <GDIPlus.au3>

Opt("GUIOnEventMode", 1)

Global $Filter = "*.jpg" ; Set this to the format you want to load  eg: *.gif or *.png or *.bmp ... etc
Global $PicturePath = @WindowsDir & "\Web\Wallpaper" ; Set this to the path you want

Global $FL2A = _FileListToArray($PicturePath, $Filter, 1)
If @error Then Exit 
Global $ShowNewPic, $y = 10 

$Gui = GUICreate("MY GUI MOVE-PIC", 390, 335)
GUISetBkColor (0xE0FFFF)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $Gui)
GUISetState(@SW_SHOW, $Gui)

AdlibEnable("RandomPicture", 200)

_GDIPlus_Startup()

While 1
    Sleep(100)
    MoveGraphicsImage()
WEnd

Func MoveGraphicsImage()
    Local $stRegion, $hGraphic, $hImage
    For $i = -140 To 390 Step 2
        $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($Gui)
        $hImage = _GDIPlus_ImageLoadFromFile($ShowNewPic)
        _GDIPLus_GraphicsDrawImageRect($hGraphic, $hImage, $i, $y, 140, 105)
        _GDIPlus_GraphicsDispose ($hGraphic)
        _GDIPlus_ImageDispose($hImage)
        $stRegion = DllStructCreate($tagRECT)
        DllStructSetData($stRegion, 1, $i)
        DllStructSetData($stRegion, 2, $y)
        DllStructSetData($stRegion, 3, $i + 2)
        DllStructSetData($stRegion, 4, $y + 115)
        _WinAPI_InvalidateRect($Gui, $stRegion, True)       
        Sleep(5)
    Next
    If $y < 275 Then $y += 105
    If $y >= 275 Then $y = 10
EndFunc

Func RandomPicture()
    $ShowNewPic = $PicturePath & "\" & $FL2A[Random(1, $FL2A[0], 1)]
EndFunc 

Func _GDIPLus_GraphicsDrawImageRect($hGraphics, $hImage, $iX, $iY, $iW, $iH)
    Local $aResult
    $aResult = DllCall($ghGDIPDll, "int", "GdipDrawImageRectI", "hwnd", $hGraphics, "hwnd", $hImage, "int", $iX, "int", $iY, "int", $iW, "int", $iH)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc   ;==>_GDIPlus_GraphicsDrawImage

Func Close()
    _GDIPlus_ShutDown()
    Exit
EndFunc

Cheers

Share this post


Link to post
Share on other sites

Here's crude example using GDIPlus to draw your image on the gui, good thing is you can have the image moving or changing without flickering.

Smashly, Can you change this to only the minimum required to move from the left to the right just enough to see what its doing. I just need the minimum so I know what to study. I can use this for something I am working on. Thanks! :) -Also can you add a little documentation? ^_^

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Instead of GUICtrlCreatePic() in loop

just do GUICtrlCreatePic() once at start of script and in your loop do GUICtrlSetImage()

Look at my Radar project in my signature.

#include <GUIConstants.au3>
#include <File.au3>

$Photo_path = "F:\PROGRAMEFILE\PIC\"
$AD_Pic_Left = 10
$AD_Pic_Top = 260
$AD_Pic_Width = 380
$AD_Pic_Height = 100

$Main_Win = GUICreate("MY GUI MOVE-PIC")
$pic = GUICtrlCreatePic("", $AD_Pic_Left, $AD_Pic_Top, $AD_Pic_Width, $AD_Pic_Height)
GUISetBkColor (0xE0FFFF) ;MY GUI BACKGROUND COLOR
GUISetState ()
    
$arGifs = _FileListToArray($Photo_path, '*.gif', 1)    ; reads all gifs in an array ...
While 1
    For $i = 1 To $arGifs[0]
        GUICtrlSetImage($pic, $Photo_path & $arGifs[$i])
    Next
WEnd
Edited by Zedna

Share this post


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
Sign in to follow this  
Followers 0