Jump to content

How to Change GUI by button (solved)


KANlFUSA
 Share

Recommended Posts

Good day to all pros here : ) 

Please help me, 
* how write this 2 .au3 files below become 1 file?
* how to switch this 2 GUI by button?



;file name form1.au3

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Form1", 888, 583, -1, -1)

$Button1 = GUICtrlCreateButton("Button GUI Form2", 240, 52, 205, 102)
$Button2 = GUICtrlCreateButton("2", 448, 52, 100, 102)
$Button3 = GUICtrlCreateButton("3", 564, 52, 101, 102)
$Button4 = GUICtrlCreateButton("4", 668, 52, 101, 102)
$Button5 = GUICtrlCreateButton("5", 772, 52, 101, 102)
$Button6 = GUICtrlCreateButton("6", 240, 157, 101, 102)
$Button7 = GUICtrlCreateButton("7", 344, 157, 101, 102)
$Button8 = GUICtrlCreateButton("8", 448, 157, 100, 102)
$Button9 = GUICtrlCreateButton("9", 564, 157, 101, 102)
$Button10 = GUICtrlCreateButton("10", 668, 157, 101, 102)
$Button11 = GUICtrlCreateButton("11", 772, 157, 101, 102)
$Button12 = GUICtrlCreateButton("12", 240, 261, 205, 102)
$Button13 = GUICtrlCreateButton("13", 448, 261, 100, 102)
$Button14 = GUICtrlCreateButton("14", 564, 261, 101, 102)
$Button15 = GUICtrlCreateButton("15", 668, 261, 205, 102)
$Button16 = GUICtrlCreateButton("16", 240, 365, 205, 102)
$Button17 = GUICtrlCreateButton("17", 448, 365, 100, 102)
$Button18 = GUICtrlCreateButton("18", 564, 365, 101, 102)
$Button19 = GUICtrlCreateButton("19", 668, 365, 101, 102)
$Button20 = GUICtrlCreateButton("20", 772, 365, 101, 102)


GUISetState(@SW_SHOW)
$Pic1 = GUICtrlCreatePic("form1.bmp", -0, -0,888, 583)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd






;other file name form2.au3

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 392, 623, -1, -1)

$Button1 = GUICtrlCreateButton("Button GUI Form1", 56, 36, 325, 165)

$Button2 = GUICtrlCreateButton("Button2", 72, 208, 145, 73)
$Button3 = GUICtrlCreateButton("Button3", 224, 208, 145, 73)
$Button4 = GUICtrlCreateButton("Button4", 72, 320, 145, 73)
$Button5 = GUICtrlCreateButton("Button5", 224, 320, 145, 73)
$Button6 = GUICtrlCreateButton("Button6", 72, 424, 145, 73)
$Button7 = GUICtrlCreateButton("Button7", 224, 424, 145, 73)
GUISetState(@SW_SHOW)

$Pic1 = GUICtrlCreatePic("form2.bmp", 0, 0, 392, 623)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

 

form1.au3

form2.au3

Edited by KANlFUSA
Link to comment
Share on other sites

  • Moderators

KANIFUSA,

Here you go:

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

$Form1 = GUICreate("Form1", 888, 583, -1, -1)

$Pic1_1 = GUICtrlCreatePic("form1.bmp", -0, -0,888, 583)
GUICtrlSetState($Pic1_1, $GUI_DISABLE)

$Button1_1 = GUICtrlCreateButton("Button GUI Form2", 240, 52, 205, 102)
$Button1_2 = GUICtrlCreateButton("2", 448, 52, 100, 102)
$Button1_3 = GUICtrlCreateButton("3", 564, 52, 101, 102)
$Button1_4 = GUICtrlCreateButton("4", 668, 52, 101, 102)
$Button1_5 = GUICtrlCreateButton("5", 772, 52, 101, 102)
$Button1_6 = GUICtrlCreateButton("6", 240, 157, 101, 102)
$Button1_7 = GUICtrlCreateButton("7", 344, 157, 101, 102)
$Button1_8 = GUICtrlCreateButton("8", 448, 157, 100, 102)
$Button1_9 = GUICtrlCreateButton("9", 564, 157, 101, 102)
$Button1_10 = GUICtrlCreateButton("10", 668, 157, 101, 102)
$Button1_11 = GUICtrlCreateButton("11", 772, 157, 101, 102)
$Button1_12 = GUICtrlCreateButton("12", 240, 261, 205, 102)
$Button1_13 = GUICtrlCreateButton("13", 448, 261, 100, 102)
$Button1_14 = GUICtrlCreateButton("14", 564, 261, 101, 102)
$Button1_15 = GUICtrlCreateButton("15", 668, 261, 205, 102)
$Button1_16 = GUICtrlCreateButton("16", 240, 365, 205, 102)
$Button1_17 = GUICtrlCreateButton("17", 448, 365, 100, 102)
$Button1_18 = GUICtrlCreateButton("18", 564, 365, 101, 102)
$Button1_19 = GUICtrlCreateButton("19", 668, 365, 101, 102)
$Button1_20 = GUICtrlCreateButton("20", 772, 365, 101, 102)

GUISetState(@SW_SHOW)

$Form2 = GUICreate("Form2", 392, 623, -1, -1)

$Pic2_1 = GUICtrlCreatePic("form2.bmp", 0, 0, 392, 623)
GUICtrlSetState($Pic2_1, $GUI_DISABLE)

$Button2_1 = GUICtrlCreateButton("Button GUI Form1", 56, 36, 325, 165)
$Button2_2 = GUICtrlCreateButton("Button2", 72, 208, 145, 73)
$Button2_3 = GUICtrlCreateButton("Button3", 224, 208, 145, 73)
$Button2_4 = GUICtrlCreateButton("Button4", 72, 320, 145, 73)
$Button2_5 = GUICtrlCreateButton("Button5", 224, 320, 145, 73)
$Button2_6 = GUICtrlCreateButton("Button6", 72, 424, 145, 73)
$Button2_7 = GUICtrlCreateButton("Button7", 224, 424, 145, 73)

GUISetState(@SW_HIDE)

While 1
    $aMsg = GUIGetMsg(1)
    Switch $aMsg[1]
        Case $Form1
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $Button1_1
                    GUISetState(@SW_HIDE, $Form1)
                    GUISetState(@SW_SHOW, $Form2)
            EndSwitch

        Case $Form2
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $Button2_1
                    GUISetState(@SW_HIDE, $Form2)
                    GUISetState(@SW_SHOW, $Form1)
            EndSwitch

    EndSwitch

WEnd

You should read the http://www.autoitscript.com/wiki/Managing_Multiple_GUIs tutorial in the Wiki to understand what is going on.

M23

 

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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