Jump to content
Sign in to follow this  
satanttin

Need some help with a testing script

Recommended Posts

satanttin

Hello dear scripters,

I was learning how to work with multiple gui's but the problem is when i open a gui and close it my previous gui doesn't work anymore i can't even close it?

here is the code:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
WinSetState ( $form1, "text", @SW_HIDE )
HotKeySet("!a", "show")
HotKeySet("!s", "hide")
HotKeySet("{F1}", "help")


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

Func show()
WinSetState ($Form1, "test", @sw_show)
EndFunc

Func hide()
WinSetState ($Form1, "test", @sw_hide)
EndFunc

Func help()
$Form2 = GUICreate("Form2", 409, 438, 192, 124)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
WinSetState ($Form2, "test", @sw_hide)
WinSetState ($Form1, "test", @SW_SHOW)

EndSwitch
WEnd
EndFunc


EndSwitch
WEnd

hope someone can help me^^

Greetz.

Share this post


Link to post
Share on other sites
water

Did you check the wiki tutorial for multiple GUIs? This should answer your questions


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
satanttin

oh no i didn't will check it right now:)

Share this post


Link to post
Share on other sites
satanttin

still have a problem with useing functions in the gui1 function:(

Share this post


Link to post
Share on other sites
water

This should work:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
WinSetState($Form1, "text", @SW_HIDE)
HotKeySet("!a", "show")
HotKeySet("!s", "hide")
HotKeySet("{F1}", "help")

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

Func show()
    WinSetState($Form1, "test", @SW_SHOW)
EndFunc   ;==>show

Func hide()
    WinSetState($Form1, "test", @SW_HIDE)
EndFunc   ;==>hide

Func help()
    Local $nMsg
    $Form2 = GUICreate("Form2", 409, 438, 192, 124)
    GUISetState(@SW_SHOW)
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($Form2)
                WinSetState($Form1, "test", @SW_SHOW)
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>help


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
satanttin

Thanks for the reply just found few sec ago how it works:P still thanks ^^

here is the code i use now:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>Opt("GUIOnEventMode", 1)

Global $Form2, $email, $Form3

$email = "satanttin@live.nl"

HotKeySet ("{F1}", "help")
HotKeySet ("{F2}", "credits")

guimain()

Func guimain()
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
GUISetOnEvent(-1, "help")
GUISetOnEvent(-1, "credits")
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
GUISetState()

While 1

WEnd
EndFunc

Func guihelp()
$Form2 = GUICreate("Form2", 409, 438, 192, 124)
$Label1 = GUICtrlCreateLabel("Help.", 8, 8, 68, 36)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("If you have questions about this application.", 8, 48, 211, 17)
$Label3 = GUICtrlCreateLabel("Then please send an email to: "&$email, 150, 72, 250, 17)
$Label4 = GUICtrlCreateLabel("F1 = Help", 8, 112, 50, 17)
$Label5 = GUICtrlCreateLabel("F2 = Credits", 8, 136, 60, 17)
GUISetOnEvent($GUI_EVENT_CLOSE, "HelpClose")
GUISetState()

While 1

WEnd
EndFunc

Func guicredits()
$Form3 = GUICreate("Form3", 365, 153, 192, 124)
$Label1 = GUICtrlCreateLabel("Credits:", 120, 0, 114, 41)
GUICtrlSetFont(-1, 25, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Maker: Tijn Tinnenbroek", 112, 72, 120, 17)
$Label3 = GUICtrlCreateLabel("Programs used: Autoit and Koda.", 112, 88, 159, 17)
GUISetOnEvent($GUI_EVENT_CLOSE, "CreditsClose")
GUISetState()
EndFunc

Func Close()
Exit
EndFunc

Func HelpClose()
GUIDelete ($Form2)
EndFunc

Func CreditsClose()
GUIDelete ($Form3)
EndFunc

Func help()
guihelp()
EndFunc

Func credits()
guicredits()
EndFunc

Share this post


Link to post
Share on other sites
water

Now you have two solutions. One in MessageLoop Mode the other in OnEvent Mode ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
satanttin

just think i like on event better cause it's easyer xD

Share this post


Link to post
Share on other sites
water

You can do whatever you like as long as it gives you the desired result ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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  

×