Jump to content

Gui create with pictures and execute a command at the end.


Fadi
 Share

Go to solution Solved by sudeepjd,

Recommended Posts

Hi,

I'm trying to create a gui with multiple page (using the next button).

On each pages, i want to include a different picture (Png or bmp) and at the last step execute an exe file.

I was trying to use the example  in the link below, but no success.

Any idea? 

 

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListBox.au3>
#include <GDIPlus.au3>

Global $frame[7][7]
Global $step = 1
Global $steps_min = 1
Global $steps_max = 7


_GDIPlus_Startup()
$Form1 = GUICreate("Bla Bla Bla", 641, 481, 382, 192)
$Button1 = GUICtrlCreateButton("Previous", 392, 448, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Cancel", 472, 448, 75, 25, 0)
$Button3 = GUICtrlCreateButton("Next", 552, 448, 75, 25, 0)
Global $hImage1 = _GDIPlus_ImageLoadFromFile("Picture1.bmp")

$Label1 = GUICtrlCreateLabel("", 8, 16, 620, 41, $SS_RIGHT)
GUICtrlSetFont(-1, 24, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label2 = GUICtrlCreateLabel("Test", 8, 56, 615, 25, $SS_RIGHT)
GUICtrlSetFont(-1, 16, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
;Start creating frames
$offset_x = 8
$offset_y = 109
; Draw PNG image
Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form1)
_GDIPlus_GraphicsDrawImage($hGraphic, $hImage1, 300, 300)

;Frame 1
$frame[1][0] = 1
$frame[1][1] = GUICtrlCreateLabel("Step1", $offset_x, $offset_y, 625, 321)


;Frame 2
$frame[2][0] = 1
$frame[2][1] = GUICtrlCreateLabel("Step2", $offset_x + 8, $offset_y , 350, 100)

;Frame 3
$frame[3][0] = 1
$frame[3][1] = GUICtrlCreateLabel("Step3", $offset_x + 8, $offset_y , 350, 100)


ShellExecute("File.exe")


 

 

Link to comment
Share on other sites

  • Solution

It may be easier to use a GUICtrlCreatePic and then use GUICtrlSetImage to change the pictures for each of the pages? Then once you reach the end, you can execute the file.

If you are looping over a series of images, put the image paths into an Array and loop over the array on each click of the button until you reach then end and then execute the file. Something along the lines of the below code.

#include <GUIConstantsEx.au3>

AutoItSetOption("GUIOnEventMode", 1)

Global $imgArr = ["image_1.jpg", "image_2.jpg", "image_3.jpg", "image_4.jpg"]
Global $pos = 0

$g_hBase = GUICreate("Test UI", 500, 520, -1, -1, -1, -1)
$pic = GUICtrlCreatePic(@ScriptDir & "\resources\images\" & $imgArr[$pos], 5, 10, 500, 436)
$btnBack = GUICtrlCreateButton("<< Move Back", 10, 470, 100, 30)
$btnFront = GUICtrlCreateButton("Move Forward >>", 120, 470, 100, 30)

GUISetOnEvent($GUI_EVENT_CLOSE , "_Exit")
GUICtrlSetOnEvent($btnBack, "changeImg")
GUICtrlSetOnEvent($btnFront, "changeImg")

GUISetState(@SW_SHOW)

While 1
    Sleep(100)
Wend

Func _Exit()
    Exit
EndFunc

Func changeImg()
    If @GUI_CtrlId = $btnBack Then
        $pos = $pos-1
        If $pos=-1 Then $pos = 0
    ElseIf @GUI_CtrlId = $btnFront Then
        $pos = $pos+1
        If $pos>Ubound($imgArr)-1 Then $pos = Ubound($imgArr)-1
    EndIf   
    
    GUICtrlSetImage($pic, @ScriptDir & "\resources\images\" &  $imgArr[$pos]) 
    
    If $pos=Ubound($imgArr)-1 Then
        GUICtrlSetData($btnFront, "Execute File")
    Else
        GUICtrlSetData($btnFront, "Move Front >>")
    EndIf
        
EndFunc

 

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...