Jump to content

Recommended Posts

Posted (edited)

Good day,
I hope that the day finds you well!

What I require is to have 3 GUI's present, all in differing locations. Or 1 GUI with three different positions? Are either of these two scenarios possible?

GUI #1: GUICtrlCreateMenu("Test Menu")
• GUICreate("!", 100, 23, 1200, 23)
GUI #2: DisplayHotKeyOption()
• $sDisplayHotKeyOption = GUICreate("", 117, 18, 210, 86, $WS_POPUP, $WS_EX_TOPMOST)
GUI #3: LiveGuiLabelA()
• $sLabelA = GUICreate("", 75, 23, 620, 48, $WS_POPUP, $WS_EX_TOPMOST)

Here is the simplified script:

; -----------------------------------------------
#RequireAdmin
; -----------------------------------------------
#include <AutoItConstants.au3>
#include <FileConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
; -----------------------------------------------
Opt("MustDeclareVars", 1)
; -----------------------------------------------
Global $sLabelA, $sLabelB, $sDisplayHotKeyOption, $iMenuPosition
; -----------------------------------------------
Main()
; -----------------------------------------------
Func Main()
    GUICreate("!", 100, 23, 1200, 23)
    WinSetOnTop("!", "", $WINDOWS_ONTOP)
    ; -----------------------------------------------
    Local $mMenu = GUICtrlCreateMenu("Test Menu")
    Local $mEnableDisableName1 = GUICtrlCreateMenuItem("Display HotKey Option", $mMenu)
    Local $mEnableDisableName2 = GUICtrlCreateMenuItem("Launch LiveGuiLabelA", $mMenu)
    ; -----------------------------------------------
    GUISetState(@SW_SHOW)
    ; -----------------------------------------------
    While 1
        Local $idMsg = GUIGetMsg()
        Switch $idMsg
            Case $GUI_EVENT_CLOSE
                Exit
                ; -----------------
            Case $mEnableDisableName1
                DisplayHotKeyLabel()
                DisplayHotKeyOption()
            Case $mEnableDisableName2
                AddF10Label()
                LiveGuiLabelA()
;~              AddF12Label()   ; ⚠ Called by LiveGuiLabelA() ⚠
;~              LiveGuiLabelB() ; ⚠ Called by LiveGuiLabelA() ⚠
;~              ⚠ Need to Return to the Main() Function here!! ⚠
        EndSwitch
    WEnd
EndFunc   ;==>Main
; -----------------------------------------------
Func DisplayHotKeyLabel()
    Local $sMessage = "Displaying HotKey Label..." & @CRLF & @CRLF, $iWidth = 350, $iHeight = 45
    Local $iOpt = 1, $sFontName = "FuturaBQ-DemiBold", $iFontSize = 14
    ; -----------------------------------------------
    SplashTextOn("", $sMessage, $iWidth, $iHeight, -1, -1, $iOpt, $sFontName, $iFontSize)
    Sleep(2000)
    SplashOff()
EndFunc   ;==>AddF10Label
; -----------------------------------------------
Func DisplayHotKeyOption()
    $sDisplayHotKeyOption = GUICreate("", 117, 18, 210, 86, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont(10, 600, 0, "Seqoe UI")
    GUISetBkColor(0x3D3D3D)
    ; -----------------------------------------------
    $iMenuPosition = GUICtrlCreateLabel(" Enable HotKey", 0, 0, 117, 18, $SS_CENTER)
    GUICtrlSetColor(-1, 0xFFFFFF)
    ; -----------------------------------------------
    GUISetState(@SW_SHOW)
    ; -----------------------------------------------
    While 1
        Switch GUIGetMsg()
            Case $iMenuPosition
                Local $bHotKeyEnabled = EnableDisableHotKey()
                If $bHotKeyEnabled = True Then ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>DisplayHotKeyOption
; -----------------------------------------------
Func EnableDisableHotKey()
    Local Static $bHotKeyEnabled = True
    ; -----------------------------------------------
    If $bHotKeyEnabled = True Then
        HotKeySet("{APPSKEY}", "UpdateScenes") ; The script that is to be executed!
        GUICtrlSetData($iMenuPosition, "Disable HotKey")
        $bHotKeyEnabled = False
    Else
        HotKeySet("{APPSKEY}")
        GUICtrlSetData($iMenuPosition, "Enable HotKey")
        GUIDelete($sDisplayHotKeyOption)
        $bHotKeyEnabled = True
    EndIf
    Return $bHotKeyEnabled
EndFunc   ;==>EnableDisableHotKey
; -----------------------------------------------
Func UpdateScenes()
    Local $sMessage = "Updating Scenes..." & @CRLF & @CRLF, $iWidth = 350, $iHeight = 45
    Local $iOpt = 1, $sFontName = "FuturaBQ-DemiBold", $iFontSize = 14
    ; -----------------------------------------------
    SplashTextOn("", $sMessage, $iWidth, $iHeight, -1, -1, $iOpt, $sFontName, $iFontSize)
    Sleep(2000)
    SplashOff()
EndFunc   ;==>UpdateScenes
; -----------------------------------------------
; -----------------------------------------------
Func LiveGuiLabelA()
    $sLabelA = GUICreate("", 75, 23, 620, 48, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont(14, 800, 0, "Calibri")
    GUISetBkColor(0x3D3D3D)
    ; -----------------------------------------------
    Local $sColRow = GUICtrlCreateLabel(" For F10", 0, 0, 75, 23, $SS_CENTER)
    GUICtrlSetColor(-1, 0xFFFFFF)
    ; -----------------------------------------------
    GUISetState(@SW_SHOW)
    ; -----------------------------------------------
    While 1
        Switch GUIGetMsg()
            Case $sColRow
                GUIDelete($sLabelA)
                AddF12Label()
                LiveGuiLabelB()
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>LiveGuiLabelA
; -----------------------------------------------
Func AddF10Label()
    Local $sMessage = "Add F10 Label..." & @CRLF & @CRLF, $iWidth = 350, $iHeight = 45
    Local $iOpt = 1, $sFontName = "FuturaBQ-DemiBold", $iFontSize = 14
    ; -----------------------------------------------
    SplashTextOn("", $sMessage, $iWidth, $iHeight, -1, -1, $iOpt, $sFontName, $iFontSize)
    Sleep(2000)
    SplashOff()
EndFunc   ;==>AddF10Label
; -----------------------------------------------
Func LiveGuiLabelB()
    $sLabelB = GUICreate("", 75, 23, 620, 48, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont(14, 800, 0, "Calibri")
    GUISetBkColor(0x3D3D3D)
    ; -----------------------------------------------
    Local $sColRow = GUICtrlCreateLabel(" For F12", 0, 0, 75, 23, $SS_CENTER)
    GUICtrlSetColor(-1, 0xFFFFFF)
    ; -----------------------------------------------
    GUISetState(@SW_SHOW)
    ; -----------------------------------------------
    While 1
        Switch GUIGetMsg()
            Case $sColRow
                GUIDelete($sLabelB)
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>LiveGuiLabelB
; -----------------------------------------------
Func AddF12Label()
    Local $sMessage = "Add F12 Label..." & @CRLF & @CRLF, $iWidth = 350, $iHeight = 45
    Local $iOpt = 1, $sFontName = "FuturaBQ-DemiBold", $iFontSize = 14
    ; -----------------------------------------------
    SplashTextOn("", $sMessage, $iWidth, $iHeight, -1, -1, $iOpt, $sFontName, $iFontSize)
    Sleep(2000)
    SplashOff()
EndFunc   ;==>AddF12Label
; -----------------------------------------------

As always...any assistance in this matter would be greatly appreciated!

Edited by mr-es335
  • mr-es335 changed the title to Launch 3 Gui's at the same time?!?
Posted (edited)

Jos,

Here is what I have thus far - but not working as expected or as should:

; -----------------------------------------------
#RequireAdmin
; -----------------------------------------------
#include <AutoItConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
; -----------------------------------------------
Opt("GUIOnEventMode", 1)
; -----------------------------------------------
Global $sDisplayHotKeyOption, $iMenuPosition, $sLabelA, $sLabelB
; -----------------------------------------------
Form1()
; -----------------------------------------------
Func Form1()
    Local $Form1 = GUICreate("", 235, 75)
    GUISetFont(14, 800, 0, "Calibri")
    ; -----------------------------------------------
    GUISetOnEvent($GUI_EVENT_CLOSE, "CloseForm1")
    ; -----------------------------------------------
    Local $sCol1Row1 = GUICtrlCreateButton("Display HotKey Label", 10, 10, 215, 25)
    GUICtrlSetOnEvent($sCol1Row1, "DisplayHotKeyOption")
    Local $sCol1Row2 = GUICtrlCreateButton("For F10", 10, 40, 215, 25)
    GUICtrlSetOnEvent($sCol1Row2, "LiveGuiLabelA")
    ; -----------------------------------------------
    GUISetState(@SW_SHOW, $Form1)
    ; -----------------------------------------------
    While 1
        Sleep(10)
    WEnd
EndFunc   ;==>Form1
; -----------------------------------------------
Func CloseForm1()
    Exit
EndFunc   ;==>CloseForm1
; -----------------------------------------------
Func LiveGuiLabelA()
    $sLabelA = GUICreate("", 75, 23, 620, 48, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont(14, 800, 0, "Calibri")
    GUISetBkColor(0x3D3D3D)
    ; -----------------------------------------------
    Local $sColRow = GUICtrlCreateLabel(" For F10", 0, 0, 75, 23, $SS_CENTER)
    GUICtrlSetColor(-1, 0xFFFFFF)
    ; -----------------------------------------------
    GUISetState(@SW_SHOW)
    ; -----------------------------------------------
    While 1
        Switch GUIGetMsg()
            Case $sColRow
                GUIDelete($sLabelA)
                AddF12Label()
                LiveGuiLabelB()
;~              Exit
        EndSwitch
    WEnd
EndFunc   ;==>LiveGuiLabelA
; -----------------------------------------------
Func LiveGuiLabelB()
    $sLabelB = GUICreate("", 75, 23, 620, 48, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont(14, 800, 0, "Calibri")
    GUISetBkColor(0x3D3D3D)
    ; -----------------------------------------------
    Local $sColRow = GUICtrlCreateLabel(" For F12", 0, 0, 75, 23, $SS_CENTER)
    GUICtrlSetColor(-1, 0xFFFFFF)
    ; -----------------------------------------------
    GUISetState(@SW_SHOW)
    ; -----------------------------------------------
    While 1
        Switch GUIGetMsg()
            Case $sColRow
                GUIDelete($sLabelB)
;~              Exit
        EndSwitch
    WEnd
EndFunc   ;==>LiveGuiLabelB
; -----------------------------------------------
Func AddF12Label()
    Local $sMessage = "Add F12 Label..." & @CRLF & @CRLF, $iWidth = 350, $iHeight = 45
    Local $iOpt = 1, $sFontName = "FuturaBQ-DemiBold", $iFontSize = 14
    ; -----------------------------------------------
    SplashTextOn("", $sMessage, $iWidth, $iHeight, -1, -1, $iOpt, $sFontName, $iFontSize)
    Sleep(2000)
    SplashOff()
EndFunc   ;==>AddF12Label
; -----------------------------------------------
Func DisplayHotKeyOption()
    $sDisplayHotKeyOption = GUICreate("", 117, 18, 210, 86, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont(10, 600, 0, "Seqoe UI")
    GUISetBkColor(0x3D3D3D)
    ; -----------------------------------------------
    $iMenuPosition = GUICtrlCreateLabel(" Enable HotKey", 0, 0, 117, 18, $SS_CENTER)
    GUICtrlSetColor(-1, 0xFFFFFF)
    ; -----------------------------------------------
    GUISetState(@SW_SHOW)
    ; -----------------------------------------------
    While 1
        Switch GUIGetMsg()
            Case $iMenuPosition
                Local $bHotKeyEnabled = EnableDisableHotKey()
                If $bHotKeyEnabled = True Then ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>DisplayHotKeyOption
; -----------------------------------------------
Func EnableDisableHotKey()
    Local Static $bHotKeyEnabled = True
    ; -----------------------------------------------
    If $bHotKeyEnabled = True Then
        HotKeySet("{APPSKEY}", "UpdateScenes") ; The script that is to be executed!
        GUICtrlSetData($iMenuPosition, "Disable HotKey")
        $bHotKeyEnabled = False
    Else
        HotKeySet("{APPSKEY}")
        GUICtrlSetData($iMenuPosition, "Enable HotKey")
        GUIDelete($sDisplayHotKeyOption)
        $bHotKeyEnabled = True
    EndIf
    Return $bHotKeyEnabled
EndFunc   ;==>EnableDisableHotKey
; -----------------------------------------------
Func UpdateScenes()
    Local $sMessage = "Updating Scenes..." & @CRLF & @CRLF, $iWidth = 350, $iHeight = 45
    Local $iOpt = 1, $sFontName = "FuturaBQ-DemiBold", $iFontSize = 14
    ; -----------------------------------------------
    SplashTextOn("", $sMessage, $iWidth, $iHeight, -1, -1, $iOpt, $sFontName, $iFontSize)
    Sleep(2000)
    SplashOff()
EndFunc   ;==>UpdateScenes
; -----------------------------------------------

PS: For your interest, I also complied the 3 scripts and called them as usual...works fine.

Edited by mr-es335
Posted

Here is a beginning.

; -----------------------------------------------
;~ #RequireAdmin
; -----------------------------------------------
#include <AutoItConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
; -----------------------------------------------
Opt("GUIOnEventMode", 1)
; -----------------------------------------------
Global $Form1, $sCol1Row1, $sCol1Row2
Global $sDisplayHotKeyOption, $iMenuPosition
Global $sLabelA, $sColRowA
Global $sLabelB, $sColRowB
; -----------------------------------------------
Form1()
; -----------------------------------------------
Func Form1()
    $Form1 = GUICreate("", 235, 75)
    GUISetFont(14, 800, 0, "Calibri")
    ; -----------------------------------------------
    GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseForm")
    ; -----------------------------------------------
    $sCol1Row1 = GUICtrlCreateButton("Display HotKey Label", 10, 10, 215, 25)
    GUICtrlSetOnEvent($sCol1Row1, "DisplayHotKeyOption")
    $sCol1Row2 = GUICtrlCreateButton("For F10", 10, 40, 215, 25)
    GUICtrlSetOnEvent($sCol1Row2, "LiveGuiLabelA")
    ; -----------------------------------------------
    GUISetState(@SW_SHOW, $Form1)
    ; -----------------------------------------------
    While 1
        Sleep(40)
    WEnd
EndFunc   ;==>Form1
; -----------------------------------------------
Func DisplayHotKeyOption()
    $sDisplayHotKeyOption = GUICreate("", 117, 18, 210, 86, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont(10, 600, 0, "Seqoe UI")
    GUISetBkColor(0x3D3D3D)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseForm")
    ; -----------------------------------------------
    $iMenuPosition = GUICtrlCreateLabel(" Enable HotKey", 0, 0, 117, 18, $SS_CENTER)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetOnEvent($iMenuPosition, "EnableDisableHotKey")
    ; -----------------------------------------------
    GUISetState(@SW_SHOW)
    GUICtrlSetState($sCol1Row1, $GUI_DISABLE)
EndFunc   ;==>DisplayHotKeyOption
; -----------------------------------------------
Func LiveGuiLabelA()
    $sLabelA = GUICreate("", 75, 23, 620, 48, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont(14, 800, 0, "Calibri")
    GUISetBkColor(0x3D3D3D)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseForm")
    ; -----------------------------------------------
    $sColRowA = GUICtrlCreateLabel(" For F10", 0, 0, 75, 23, $SS_CENTER)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetOnEvent($sColRowA, "_ColRow")
    ; -----------------------------------------------
    GUISetState(@SW_SHOW)
    GUICtrlSetState($sCol1Row2, $GUI_DISABLE)
EndFunc   ;==>LiveGuiLabelA
; -----------------------------------------------
Func _ColRow()
    ConsoleWrite("@GUI_CtrlId=" & @GUI_CtrlId & @CRLF)
    Switch @GUI_CtrlId
        Case $sColRowA
            WinClose($sLabelA)
            AddF12Label()
            LiveGuiLabelB()
        Case $sColRowB
            WinClose($sLabelB)
    EndSwitch
EndFunc   ;==>_ColRow
; -----------------------------------------------
Func LiveGuiLabelB()
    $sLabelB = GUICreate("", 75, 23, 620, 48, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont(14, 800, 0, "Calibri")
    GUISetBkColor(0x3D3D3D)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseForm")
    ; -----------------------------------------------
    $sColRowB = GUICtrlCreateLabel(" For F12", 0, 0, 75, 23, $SS_CENTER)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetOnEvent($sColRowB, "_ColRow")
    ; -----------------------------------------------
    GUISetState(@SW_SHOW)

EndFunc   ;==>LiveGuiLabelB
; -----------------------------------------------
Func AddF12Label()
    Local $sMessage = "Add F12 Label..." & @CRLF & @CRLF, $iWidth = 350, $iHeight = 45
    Local $iOpt = 1, $sFontName = "FuturaBQ-DemiBold", $iFontSize = 14
    ; -----------------------------------------------
    SplashTextOn("", $sMessage, $iWidth, $iHeight, -1, -1, $iOpt, $sFontName, $iFontSize)
    Sleep(2000)
    SplashOff()
EndFunc   ;==>AddF12Label
; -----------------------------------------------
Func EnableDisableHotKey()
    Local Static $bHotKeyEnabled = True
    ; -----------------------------------------------
    If $bHotKeyEnabled = True Then
        HotKeySet("{APPSKEY}", "UpdateScenes") ; The script that is to be executed!
        GUICtrlSetData($iMenuPosition, "Disable HotKey")
        $bHotKeyEnabled = False
    Else
        WinClose($sDisplayHotKeyOption)
        HotKeySet("{APPSKEY}")
        GUICtrlSetData($iMenuPosition, "Enable HotKey")
        $bHotKeyEnabled = True
    EndIf
    Return $bHotKeyEnabled
EndFunc   ;==>EnableDisableHotKey
; -----------------------------------------------
Func UpdateScenes()
    Local $sMessage = "Updating Scenes..." & @CRLF & @CRLF, $iWidth = 350, $iHeight = 45
    Local $iOpt = 1, $sFontName = "FuturaBQ-DemiBold", $iFontSize = 14
    ; -----------------------------------------------
    SplashTextOn("", $sMessage, $iWidth, $iHeight, -1, -1, $iOpt, $sFontName, $iFontSize)
    Sleep(2000)
    SplashOff()
EndFunc   ;==>UpdateScenes
; -----------------------------------------------
Func _CloseForm()
    Switch @GUI_WinHandle
        Case $Form1
            MsgBox($MB_OK, "GUI Event", "You selected CLOSE in the main window! Exiting...")
            Exit
        Case $sDisplayHotKeyOption
            GUIDelete($sDisplayHotKeyOption)
            GUICtrlSetState($sCol1Row1, $GUI_ENABLE)
        Case $sLabelA, $sLabelB
            GUIDelete(@GUI_WinHandle)
            GUICtrlSetState($sCol1Row2, $GUI_ENABLE)
    EndSwitch
EndFunc   ;==>SpecialEvents
; -----------------------------------------------

 

I know that I know nothing

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...