Jump to content

Gui images


kayser2008
 Share

Recommended Posts

Hi all

I´m doing a Gui that has one image on the background and need to show several images on top of that main image in diferent places (w/h) when i press a keyboard button

i have done  that with the Random() function, but that way i can´t control the last image that will show can someone point me what´s the best way to do that 

show 30 images and stop on image 24

show 30 images and stop on image 12

show 30 images and stop on image 1

Thanks 

Link to comment
Share on other sites

HotKeySet("{5}", "Play")
Local $gui,$COLOR_BLACK = 0xFFFF00 ,$wdt = 800, $hdt = 600

$gui = GUICreate("", $hdt, $wdt, -1, -1, $WS_POPUP)
GUICtrlCreatePic("Pics\main.jpg",-1,-1,$hdt,$wdt)

GUISetState(@SW_SHOW)

Func Play()
$Images = Random(1,10,1)
Sleep(200)
SplashImageOn("","Pics\" & $Images & ".jpg",580,85,667,819,$DLG_NOTITLE)

EndFunc

Do
If _IsPressed("36") Then
While _IsPressed("36")
WEnd
Play()
EndIf

Until GUIGetMsg() = $GUI_EVENT_CLOSE

I´m doing like that but that way just shows randon images in the end , is there a way to control wath image shows in the end or to control wath images to show?

Edited by kayser2008
Link to comment
Share on other sites

This should work like you want:

#include <array.au3>
#include <AutoItConstants.au3>
#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>


HotKeySet("{5}", "RandomPlay")

Local $gui, $wdt = 800, $hdt = 600

$gui = GUICreate("", $hdt, $wdt, -1, -1, $WS_POPUP)
GUICtrlCreatePic("Pics\main.jpg", -1, -1, $hdt, $wdt)

GUISetState(@SW_SHOW)

Global $aImages[30]

;populate array with ImageNo.
For $i = 0 To 29
    $aImages[$i] = $i + 1
Next


Global $aWantedLast[] = [24, 12, 1]

Do
    For $i = 0 To UBound($aWantedLast) - 1
        _ArrayShuffle($aImages)
        ;_ArrayDisplay($aImages) ;this is the shuffled array
        ConsoleWrite('Swaped Images: ' & $aImages[UBound($aImages) - 1] & '<==>' & @TAB)
        $iWantedLast = _ArraySearch($aImages, $aWantedLast[$i])
        _ArraySwap($aImages, $iWantedLast, $aImages[UBound($aImages) - 1])
        ;_ArrayDisplay($aImages) ;this is the shuffled array with changed last ImageNo.
        ConsoleWrite($aImages[UBound($aImages) - 1] & @CRLF)
        For $j = 0 To UBound($aImages) - 1
            If _IsPressed("36") Then
                While _IsPressed("36")
                WEnd
                Play($aImages[$j])
            EndIf
        Next
    Next
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func RandomPlay()
    Play(Random(0, UBound($aImages) - 1, 1))
EndFunc   ;==>RandomPlay

Func Play($Images)
    Sleep(200)
    SplashImageOn("", "Pics\" & $Images & ".jpg", 580, 85, 667, 819, $DLG_NOTITLE)
EndFunc   ;==>Play

Please have a look in the help for UBound and the _Array_* functions i used. When you never worked with arrays also

Language Reference

The basics of the AutoIt language:

...

Edited by AutoBert
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...