Jump to content

Displaying Images FullScreen


nick21
 Share

Recommended Posts

All I want to do is display a image Fullscreen. I tried making a GUI and displaying the image in that, it worked but with a series of images to show it messes up.

Ok here is the code I am using right now.

;Include constants
#include <GUIConstants.au3>
FileInstall("C:\ascreen.bmp", @TempDir & "\ascreen.bmp")
FileInstall("C:\bcreen.bmp", @TempDir & "\bscreen.bmp")
FileInstall("C:\cscreen.bmp", @TempDir & "\cscreen.bmp")
FileInstall("C:\dscreen.bmp", @TempDir & "\dscreen.bmp")
;Initialize variables
Global $GUIWidth
Global $GUIHeight
$GUIWidth = @DESKTOPWIDTH +3
$GUIHeight = @DesktopHeight

;Create window
GUICreate("Name", $GUIWidth, $GUIHeight)
;Show window/Make the window visible
GUISetState(@SW_SHOW)




While 1
  ;After every loop check if the user clicked something in the GUI window
   $msg = GUIGetMsg()

   Select
   
     ;Check if user clicked on the close button
      Case $msg = $GUI_EVENT_CLOSE
        ;Destroy the GUI including the controls
         
        ;Exit the script
         Exit
   EndSelect

    
GUICtrlCreatePic(@TEMPDIR &"\ascreen.bmp",0,0,@DesktopWidth,@DesktopHeight)
sleep(1000)
GUICtrlCreatePic(@TEMPDIR &"\bscreen.bmp",0,0,@DesktopWidth,@DesktopHeight)
sleep(1000)
GUICtrlCreatePic(@TEMPDIR &"\cscreen.bmp",0,0,@DesktopWidth,@DesktopHeight)
sleep(1000)
GUICtrlCreatePic(@TEMPDIR &"\dscreen.bmp",0,0,@DesktopWidth,@DesktopHeight)
sleep(1000)



WEnd

The code works but does not display the images in order, gets all weird and funky.

If you know a simple code to do it without the need of a GUI that would be great.

Any help would be great thanks.

Thanks

nick21

Link to comment
Share on other sites

#include <Constants.au3>
#include <GUIConstants.au3>
#include <WinAPI.au3>

FileInstall("C:\ascreen.bmp", @TempDir & "\ascreen.bmp")
FileInstall("C:\bcreen.bmp", @TempDir & "\bscreen.bmp")
FileInstall("C:\cscreen.bmp", @TempDir & "\cscreen.bmp")
FileInstall("C:\dscreen.bmp", @TempDir & "\dscreen.bmp")
;Initialize variables
Global $hGUI, $Pic, $aBmp[4], $iCounter, $GUIWidth, $GUIHeight

$GUIWidth = @DESKTOPWIDTH +3
$GUIHeight = @DesktopHeight
$iCounter = 0

$aBmp[0] = _WinAPI_LoadImage(0, @TempDir & "\ascreen.bmp", $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
$aBmp[1] = _WinAPI_LoadImage(0, @TempDir & "\bscreen.bmp", $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
$aBmp[2] = _WinAPI_LoadImage(0, @TempDir & "\cscreen.bmp", $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
$aBmp[3] = _WinAPI_LoadImage(0, @TempDir & "\dscreen.bmp", $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)

;Create window
$hGUI = GUICreate("Name", $GUIWidth, $GUIHeight)
$Pic = GUICtrlCreatePic("", 0, 0, $GUIWidth, $GUIHeight)

AdlibEnable("_ShowBitmap", 1000)
_ShowBitmap()

;Show window/Make the window visible
GUISetState()

While 1
    Switch GUIGetMsg()
   
        ;Check if user clicked on the close button
        Case $GUI_EVENT_CLOSE
            ; Stop the Adlib function
            AdlibDisable()
            
            ;Destroy the GUI including the controls
            GUIDelete()
            
            ; Clean up
            For $i = 0 To UBound($aBmp)-1
                _WinAPI_DeleteObject($aBmp[$i])
            Next
         
            ;Exit the script
            Exit
   EndSwitch
WEnd

Func _ShowBitmap()
    GUICtrlSendMsg($Pic, 0x0172, 0, $aBmp[$iCounter])
    
    $iCounter += 1
    If $iCounter > UBound($aBmp)-1 Then $iCounter = 0
EndFunc

If the image format is not bitmap or not supported by _WinAPI_LoadImage function, you can use Yashied's Icons.au3 library

Link to comment
Share on other sites

Hi,

Maybe you can try creating just 1 the Pic control and use GUICtrlSetImage() in your While loop.

As it is your constantly creating a new pic control and your never destroying the Pic control.

So your just layering new pic control over and over on top of another, after a short period of time the script will bug out..

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

FileInstall("C:\ascreen.bmp", @TempDir & "\ascreen.bmp")
FileInstall("C:\bscreen.bmp", @TempDir & "\bscreen.bmp")
FileInstall("C:\cscreen.bmp", @TempDir & "\cscreen.bmp")
FileInstall("C:\dscreen.bmp", @TempDir & "\dscreen.bmp")

Global $aPic[4] = [@TempDir & "\ascreen.bmp", @TempDir & "\bscreen.bmp", @TempDir & "\cscreen.bmp", @TempDir & "\dscreen.bmp"]
Global $GUIWidth = @DesktopWidth, $GUIHeight = @DesktopHeight
Global $hGui, $iPic, $msg
Global $begin = TimerInit(), $i = 0


$hGui = GUICreate("", $GUIWidth, $GUIHeight, 0, 0, $WS_POPUP)
$iPic = GUICtrlCreatePic($aPic[0], 0, 0, $GUIWidth, $GUIHeight)
GUISetState(@SW_SHOW, $hGui)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            If TimerDiff($begin) > 1000 Then
                $begin = TimerInit()
                If $i > 3 Then $i = 0
                GUICtrlSetImage($iPic, $aPic[$i])
                $i += 1
            EndIf
    EndSwitch
WEnd

Cheers

Edited by smashly
Link to comment
Share on other sites

@nick21: You've got some better options now, but if you just wanted to fix your original problem, it comes from layering multiple Pic controls on top of each other. Just create one control and change the image in it:

Global $ctrlPic = GUICtrlCreatePic(@TEMPDIR &"\ascreen.bmp",0,0,@DesktopWidth,@DesktopHeight)
sleep(1000)
GUICtrlSetImage($ctrlPic, @TEMPDIR & "\bscreen.bmp")

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...