Jump to content

Need some help with a testing script


Recommended Posts

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.

Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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