Jump to content

Recommended Posts

Posted (edited)

Good day,

I need a means of being to "reposition" a window [WinMove] based upon the the value located in an array.

The Array "read" an .ini file entitled: SceneData.ini
• This .ini file contains the following data:

[Scene Data]
Line1=Start
Line12=====Presets====
Line13=Preset 001

The initial position of the window is: 725, 210
The subsequent position of the window is to be: 900, 365

When the value "Preset 001" has been reached, this is where the windows is to be reposition.

Here are the two scripts:
 

Spoiler
; CombinedF12
; -----------------------------------------------
Func ReadIniFile()
    ; -----------------------------------------------
    Local $sFilePath = "E:\Desktop\Working\Assets\IniData\SceneData.ini"
    Local $aArray = IniReadSection($sFilePath, "Scene Data")
    ; -----------------------------------------------
    Opt("GUIOnEventMode", 0) ; when in $hMsgForm - disable <<<<<<<<<<<<<<<
    Local $hMsgForm = GUICreate("ReadIniFile", 390, 90, 725, 115, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont($iFontSize, $iFontWt, $GUI_FONTNORMAL, $sFontName)
    ; -----------------------------------------------
    Local $idLabel1 = GUICtrlCreateLabel("", 5, 5, 379, 45, $SS_SUNKEN)
    ; ---------------------
    Local $idBtnContinue = GUICtrlCreateButton("Continue", 100, 55, 85, 25, $BS_DEFPUSHBUTTON)
    Local $idBtnCancel = GUICtrlCreateButton("Cancel", 200, 55, 85, 25)
    ; -----------------------------------------------
    GUISetState(@SW_SHOW, $hMsgForm)
    ; -----------------------------------------------
    Local $nMsg, $idx = 1
    GUICtrlSetData($idLabel1, "To copy [" & $aArray[$idx][1] & "]...select [Continue]..." & @CRLF & "Select [Cancel] to exit...")
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $idBtnCancel
                ExitLoop
            Case $idBtnContinue
                ClipPut($aArray[$idx][1])
                UpdateScenes()
                ; ---------------------
                $idx += 1
                If $idx > $aArray[0][0] Then
                    ExitLoop ; The end of the SceneData.ini data file has been reached!
                EndIf
                GUICtrlSetData($idLabel1, "To copy [" & $aArray[$idx][1] & "]...select [Continue]..." & @CRLF & "Select [Cancel] to exit...")
        EndSwitch
    WEnd
    ; -----------------------------------------------
    GUIDelete($hMsgForm)
    ; -----------------------------------------------
    Opt("GUIOnEventMode", 1) ; when out of $hMsgForm - enable <<<<<<<<<<<<<<<
EndFunc   ;==>ReadIniFile
; -----------------------------------------------
Func UpdateScenes()
    Local $hWnd = "[CLASS:SAC_SCENEPROPERTIES]"
    ; -----------------------------------------------
    Sleep(100)
    WinMove($hWnd, "", 725, 210) ; The Scene Properties window is displayed and is then moved.
EndFunc   ;==>UpdateScenes
; -----------------------------------------------
Spoiler
; CombinedF10
; -----------------------------------------------
Func EnableF10View()
    Local $hWnd = "[CLASS:SAC_SCENEPROPERTIES]"
    ; -----------------------------------------------
;~  My "suggestion!?!"...
;~  If SceneData.ini = "Preset 001" Then
;~      Sleep(100)
;~      WinMove($hWnd, "", 900, 365) ; The Scene Properties window is displayed and is then moved.
;~  EndIf
EndFunc   ;==>EnableF10View
; -----------------------------------------------

 

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

Thank you all for your time!

 

Edited by mr-es335
Posted (edited)

I would approach it this way.

; CombinedF12
; -----------------------------------------------
Func ReadIniFile()
    ; -----------------------------------------------
    Local $sFilePath = "E:\Desktop\Working\Assets\IniData\SceneData.ini"
    Local $aArray = IniReadSection($sFilePath, "Scene Data")
    ; -----------------------------------------------
    Opt("GUIOnEventMode", 0) ; when in $hMsgForm - disable <<<<<<<<<<<<<<<
    Local $hMsgForm = GUICreate("ReadIniFile", 390, 90, 725, 115, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont($iFontSize, $iFontWt, $GUI_FONTNORMAL, $sFontName)
    ; -----------------------------------------------
    Local $idLabel1 = GUICtrlCreateLabel("", 5, 5, 379, 45, $SS_SUNKEN)
    ; ---------------------
    Local $idBtnContinue = GUICtrlCreateButton("Continue", 100, 55, 85, 25, $BS_DEFPUSHBUTTON)
    Local $idBtnCancel = GUICtrlCreateButton("Cancel", 200, 55, 85, 25)
    ; -----------------------------------------------
    GUISetState(@SW_SHOW, $hMsgForm)
    ; -----------------------------------------------
    Local $nMsg, $idx = 1
    GUICtrlSetData($idLabel1, "To copy [" & $aArray[$idx][1] & "]...select [Continue]..." & @CRLF & "Select [Cancel] to exit...")
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $idBtnCancel
                ExitLoop
            Case $idBtnContinue
                ClipPut($aArray[$idx][1])
                ; ---------------------
                If $idx > 12 Then
                    UpdateScenes(900, 365)
                Else
                    UpdateScenes(725, 210)
                EndIf
                ; ---------------------
                $idx += 1
                If $idx > $aArray[0][0] Then
                    ExitLoop ; The end of the SceneData.ini data file has been reached!
                EndIf
                GUICtrlSetData($idLabel1, "To copy [" & $aArray[$idx][1] & "]...select [Continue]..." & @CRLF & "Select [Cancel] to exit...")
        EndSwitch
    WEnd
    ; -----------------------------------------------
    GUIDelete($hMsgForm)
    ; -----------------------------------------------
    Opt("GUIOnEventMode", 1) ; when out of $hMsgForm - enable <<<<<<<<<<<<<<<
EndFunc   ;==>ReadIniFile
; -----------------------------------------------
Func UpdateScenes($iX, $iY)
;~     Local $hWnd = "[CLASS:SAC_SCENEPROPERTIES]"
    Local $hWnd = WinGetHandle("[CLASS:SAC_SCENEPROPERTIES]")
    ; -----------------------------------------------
    If $hWnd Then
        Sleep(100)
        WinMove($hWnd, "", $iX, $iY) ; The Scene Properties window is displayed and is then moved.
    EndIf
EndFunc   ;==>UpdateScenes
; -----------------------------------------------

 

Edited by ioa747

I know that I know nothing

Posted (edited)

ioa747,

Very, very "interesting"...to say the least!!

Also, as a very, very VERY, interesting "side-effect" of your offering...

1) ...within the ReadIniFile() function I was able to execute a Send("{F10}") command
• This eliminates the need for a dedicated "Enable [F10]" button!!
2) ...within the ReadIniFile() function I was also able to execute a Send("{F12}") command
• This eliminates the need for a dedicated "Return to [F12] View" button!!
• This button text is the "flip-side" of the "Enable [F10]".
• [Click_Me]

3) This offering also makes it possible to completely eliminate one entire script...the "CombinedF10] script!!! Well done!!!

Please peruse the following - and critique [...especially my implementation of "If...Then-ElseIf..."]...this being my first "real" attempt at doing so...

Spoiler
; ReadIniFileD
; -----------------------------------------------
#RequireAdmin
; -----------------------------------------------
#include <AutoItConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
; -----------------------------------------------
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
; -----------------------------------------------
Global $Form1, $mForm1Button
Global $iWidth = 735, $iHeight = 48, $ixpos = -1, $iypos = -1, $iOpt = 1, $sFontName = "Corbel Bold", $iFontSize = 16, $iFontWt = 800
; -----------------------------------------------
Forms()
; -----------------------------------------------
Func Forms()
    $iFontSize = 14
    ; -----------------------------------------------
    $Form1 = GUICreate("EnableHotKey", 150, 25, 725, 86, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont($iFontSize, $iFontWt, $GUI_FONTNORMAL, $sFontName)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseForm")
    ; ---------------------
    $mForm1Button = GUICtrlCreateButton(" Enable Hotkey", 0, 0, 150, 25)
    GUICtrlSetOnEvent($mForm1Button, "_ColRow")
    ; -----------------------------------------------
    GUISetState(@SW_SHOW, $Form1)
    ; -----------------------------------------------
    While 1
        Sleep(10)
    WEnd
EndFunc   ;==>Forms
; -----------------------------------------------
Func _ColRow()
    Switch @GUI_CtrlId
        Case $mForm1Button
            ToggleNUMPADSUB()
    EndSwitch
EndFunc   ;==>_ColRow
; -----------------------------------------------
Func _CloseForm()
    Switch @GUI_WinHandle
        Case $Form1
            Exit
    EndSwitch
EndFunc   ;==>_CloseForm
; -----------------------------------------------
Func ToggleNUMPADSUB()
    Local Static $bEnabled = True
    Local $aGuiPos = WinGetPos($Form1)
    If $bEnabled Then
        HotKeySet("{NUMPADSUB}", "ReadIniFile")
        GUICtrlSetData($mForm1Button, "Disable Hotkey")
    Else
        WinClose($Form1)
    EndIf
    $bEnabled = Not $bEnabled
EndFunc   ;==>ToggleNUMPADSUB
; -----------------------------------------------
Func ReadIniFile()
    $iFontSize = 14
    ; -----------------------------------------------
    Local $sFilePath = "C:\TestMe\Assets\SceneData.ini"
    Local $aArray = IniReadSection($sFilePath, "Scene Data")
    ; -----------------------------------------------
    Opt("GUIOnEventMode", 0) ; when in $hMsgForm - disable <<<<<<<<<<<<<<<
    Local $hMsgForm = GUICreate("ReadIniFile", 390, 90, 725, 115, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont($iFontSize, $iFontWt, $GUI_FONTNORMAL, $sFontName)
    ; -----------------------------------------------
    Local $idLabel1 = GUICtrlCreateLabel("", 5, 5, 379, 45, $SS_SUNKEN)
    ; ---------------------
    Local $idBtnContinue = GUICtrlCreateButton("Continue", 100, 55, 85, 25, $BS_DEFPUSHBUTTON)
    Local $idBtnCancel = GUICtrlCreateButton("Cancel", 200, 55, 85, 25)
    ; -----------------------------------------------
    GUISetState(@SW_SHOW, $hMsgForm)
    ; -----------------------------------------------
    Local $nMsg, $idx = 1
    GUICtrlSetData($idLabel1, "To copy [" & $aArray[$idx][1] & "]...select [Continue]..." & @CRLF & "Select [Cancel] to exit...")
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $idBtnCancel
                ExitLoop
            Case $idBtnContinue
                ClipPut($aArray[$idx][1])
                ConsoleWrite("$idx= " & $idx & @CRLF)
                ; ---------------------
                If $idx = 1 Then
                    UpdateScenesF12View(725, 210)
                ElseIf $idx = 2 Then
                    UpdateScenesF12View(725, 210)
                ElseIf $idx = 3 Then
                    EnableF10View()
                    UpdateScenesF10View(900, 320)
                ElseIf $idx > 3 Then
                    EnableF12View()
                EndIf
                ; ---------------------
                $idx += 1
                If $idx > $aArray[0][0] Then
                    ExitLoop ; The end of the SceneData.ini data file has been reached!
                EndIf
                GUICtrlSetData($idLabel1, "To copy [" & $aArray[$idx][1] & "]...select [Continue]..." & @CRLF & "Select [Cancel] to exit...")
        EndSwitch
    WEnd
    ; -----------------------------------------------
    GUIDelete($hMsgForm)
    ; -----------------------------------------------
    Opt("GUIOnEventMode", 1) ; when out of $hMsgForm - enable <<<<<<<<<<<<<<<
EndFunc   ;==>ReadIniFile
; -----------------------------------------------
Func UpdateScenesF12View($iX, $iY)
    ConsoleWrite("x,y co-ords received=" & $iX & "," & $iY & @CRLF)
    MsgBox($MB_OK, "", "UpdateScenes for [F12] View", 1)
EndFunc   ;==>UpdateScenesF12View
; -----------------------------------------------
Func UpdateScenesF10View($iX, $iY)
    ConsoleWrite("x,y co-ords received=" & $iX & "," & $iY & @CRLF)
    MsgBox($MB_OK, "", "UpdateScenes for [F10] View", 1)
EndFunc   ;==>UpdateScenesF10View
; -----------------------------------------------
Func EnableF10View()
    ConsoleWrite("In the [F10] View!" & @CRLF)
    ; ---------------------
    WinActivate("[CLASS:SAC_MAIN]", "")
    Sleep(100)
    Send("{F10}") ; Select: F10
EndFunc   ;==>EnableF10View
; -----------------------------------------------
Func EnableF12View()
    ConsoleWrite("In the [F12] View...no co-ords required!" & @CRLF)
    ; ---------------------
    WinActivate("[CLASS:SAC_MAIN]", "")
    Sleep(100)
    Send("{F12}") ; Select: F12
EndFunc   ;==>EnableF12View
; -----------------------------------------------

 

3) The only "thing" that I have been unable to do is to exit Form1 - with the "Disable HotKey" button!

Thank you for your time...appreciated!

Edited by mr-es335
Posted (edited)

Hello,

"3) The only "thing" that I have been unable to do is to exit Form1 - with the "Disable HotKey" button!"

Is THIS workable?

Func EnableF12View()
    ConsoleWrite("In the [F12] View...no co-ords required!" & @CRLF)
    ; ---------------------
    WinActivate("[CLASS:SAC_MAIN]", "")
    Sleep(100)
    Send("{F12}") ; Select: F12
    ; -----------------------------------------------
    GUIDelete($Form1)
EndFunc   ;==>EnableF12View
; -----------------------------------------------

Should such statement NOT be placed in the _CloseForm() function? If NOT, what is the purpose then of the _CloseForm() function?

Edited by mr-es335
Posted (edited)
21 minutes ago, mr-es335 said:

The only "thing" that I have been unable to do is to exit Form1 - with the "Disable HotKey" button!"

It works for me.
Only when I'm in ReadIniFile, and the dialog is running, it doesn't work 
(maybe as an idea we can disable it, while the form $hMsgForm is running)

i.e. if you run the script and it says 'Enable Hotkey' and you click it, it becomes 'Disable Hotkey', when you click it, the form doesn't close?

 

Func _ColRow()
    Switch @GUI_CtrlId
        Case $mForm1Button
            ToggleNUMPADSUB()
    EndSwitch
EndFunc   ;==>_ColRow
; -----------------------------------------------
Func _CloseForm()
    Switch @GUI_WinHandle
        Case $Form1
            Exit
;~         Case $mForm1Button
;~             GUICtrlSetState($mForm1Button, $GUI_DISABLE)
    EndSwitch
EndFunc   ;==>_CloseForm
; -----------------------------------------------

the
Case $mForm1Button
GUICtrlSetState($mForm1Button, $GUI_DISABLE)
disable them from the _CloseForm(), they are not needed there
Enough in _ColRow()

Edited by ioa747

I know that I know nothing

Posted (edited)

ioa747,

You stated...
1) "...the Case $mForm1Button GUICtrlSetState($mForm1Button, $GUI_DISABLE) disable them from the _CloseForm(), they are not needed there..." ...Done!
2) "Enough in "
• How is this being resolved in _ColRow()

What of my offering above? It seems to work.

Two other things:
1) Does the If..Then.>Else statements from my offering appear to be OK?
2) I had to add a line to the "SceneData.ini" data file...

[Scene Data]
Line1=Start
Line2=====Presets====
Line3=Preset 001
Line4=

...which produces the following output for the last item int he array...

"To copy []...select [Continue]...
  Select [Cancel] to exit..."

Is there anyway to resolve this?

Edited by mr-es335
Posted (edited)

Do you means in Line4=
which is empty?
What would you like it to say? (when empty line)

Edit:
Or should he not put it on at all and go to the next one?

Edited by ioa747

I know that I know nothing

Posted (edited)

"Or should he not put it on at all and go to the next one? " Yes!

I also discovered that the "$hMsgForm" is NOT existing?!?

Lastly, ";~     Local $hWnd = WinGetHandle("[CLASS:SAC_SCENEPROPERTIES]") ; ⚠ Does not appear to work?!?! ⚠"

Edited by mr-es335
Posted

 

; ReadIniFileD
; -----------------------------------------------
#RequireAdmin
; -----------------------------------------------
#include <AutoItConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
; -----------------------------------------------
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
; -----------------------------------------------
Global $Form1, $mForm1Button
Global $iWidth = 735, $iHeight = 48, $ixpos = -1, $iypos = -1, $iOpt = 1, $sFontName = "Corbel Bold", $iFontSize = 16, $iFontWt = 800
; -----------------------------------------------
Forms()
; -----------------------------------------------
Func Forms()
    $iFontSize = 14
    ; -----------------------------------------------
    $Form1 = GUICreate("EnableHotKey", 150, 25, 725, 86, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont($iFontSize, $iFontWt, $GUI_FONTNORMAL, $sFontName)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseForm")
    ; ---------------------
    $mForm1Button = GUICtrlCreateButton(" Enable Hotkey", 0, 0, 150, 25)
    GUICtrlSetOnEvent($mForm1Button, "_ColRow")
    ; -----------------------------------------------
    GUISetState(@SW_SHOW, $Form1)
    ; -----------------------------------------------
    While 1
        Sleep(10)
    WEnd
EndFunc   ;==>Forms
; -----------------------------------------------
Func _ColRow()
    Switch @GUI_CtrlId
        Case $mForm1Button
            ToggleNUMPADSUB()
    EndSwitch
EndFunc   ;==>_ColRow
; -----------------------------------------------
Func _CloseForm()
    Switch @GUI_WinHandle
        Case $Form1
            Exit
    EndSwitch
EndFunc   ;==>_CloseForm
; -----------------------------------------------
Func ToggleNUMPADSUB()
    Local Static $bEnabled = True
    Local $aGuiPos = WinGetPos($Form1)
    If $bEnabled Then
        HotKeySet("{NUMPADSUB}", "ReadIniFile")
        GUICtrlSetData($mForm1Button, "Disable Hotkey")
    Else
        WinClose($Form1)
    EndIf
    $bEnabled = Not $bEnabled
EndFunc   ;==>ToggleNUMPADSUB
; -----------------------------------------------
Func ReadIniFile()
    $iFontSize = 14
    ; -----------------------------------------------
    Local $sFilePath = @ScriptDir & "\SceneData.ini" ; "C:\TestMe\Assets\SceneData.ini"
    Local $aArray = IniReadSection($sFilePath, "Scene Data")
    ; -----------------------------------------------
    Opt("GUIOnEventMode", 0) ; when in $hMsgForm - disable <<<<<<<<<<<<<<<
    Local $hMsgForm = GUICreate("ReadIniFile", 390, 90, 725, 115, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont($iFontSize, $iFontWt, $GUI_FONTNORMAL, $sFontName)
    ; -----------------------------------------------
    Local $idLabel1 = GUICtrlCreateLabel("", 5, 5, 379, 45, $SS_SUNKEN)
    ; ---------------------
    Local $idBtnContinue = GUICtrlCreateButton("Continue", 100, 55, 85, 25, $BS_DEFPUSHBUTTON)
    Local $idBtnCancel = GUICtrlCreateButton("Cancel", 200, 55, 85, 25)
    ; -----------------------------------------------
    GUISetState(@SW_SHOW, $hMsgForm)
    ; -----------------------------------------------
    Local $nMsg, $idx = 1
    GUICtrlSetData($idLabel1, "To copy [" & $aArray[$idx][1] & "]...select [Continue]..." & @CRLF & "Select [Cancel] to exit...")
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $idBtnCancel
                ExitLoop
            Case $idBtnContinue
                ClipPut($aArray[$idx][1])
                ConsoleWrite("$idx= " & $idx & @CRLF)
                ; ---------------------
                If $idx < 3 Then
                    UpdateScenesF12View(725, 210)
                ElseIf $idx = 3 Then
                    EnableF10View()
                    UpdateScenesF10View(900, 320)
                ElseIf $idx > 3 Then
                    EnableF12View()
                EndIf
                ; ---------------------
                $idx += 1
                If $idx > $aArray[0][0] Then
                    ExitLoop ; The end of the SceneData.ini data file has been reached!
                EndIf

                ; to resolve empty SceneData
                If $aArray[$idx][1] = "" Then
                    $idx += 1
                    If $idx > $aArray[0][0] Then
                        ExitLoop ; The end of the SceneData.ini data file has been reached!
                    EndIf
                EndIf

                GUICtrlSetData($idLabel1, "To copy [" & $aArray[$idx][1] & "]...select [Continue]..." & @CRLF & "Select [Cancel] to exit...")
        EndSwitch
    WEnd
    ; -----------------------------------------------
    GUIDelete($hMsgForm)
    ; -----------------------------------------------
    Opt("GUIOnEventMode", 1) ; when out of $hMsgForm - enable <<<<<<<<<<<<<<<
EndFunc   ;==>ReadIniFile
; -----------------------------------------------
Func UpdateScenesF12View($iX, $iY)
    ConsoleWrite("x,y co-ords received=" & $iX & "," & $iY & @CRLF)
    MsgBox($MB_OK, "", "UpdateScenes for [F12] View", 1)
EndFunc   ;==>UpdateScenesF12View
; -----------------------------------------------
Func UpdateScenesF10View($iX, $iY)
    ConsoleWrite("x,y co-ords received=" & $iX & "," & $iY & @CRLF)
    MsgBox($MB_OK, "", "UpdateScenes for [F10] View", 1)
EndFunc   ;==>UpdateScenesF10View
; -----------------------------------------------
Func EnableF10View()
    ConsoleWrite("In the [F10] View!" & @CRLF)
    ; ---------------------
    Local $hWnd = WinActivate("[CLASS:SAC_MAIN]", "")
    If $hWnd Then
        Sleep(100)
        Send("{F10}") ; Select: F10
    Else
        MsgBox($MB_OK, "", "[CLASS:SAC_MAIN] window not found")
    EndIf
EndFunc   ;==>EnableF10View
; -----------------------------------------------
Func EnableF12View()
    ConsoleWrite("In the [F12] View...no co-ords required!" & @CRLF)
    ; ---------------------
    Local $hWnd = WinActivate("[CLASS:SAC_MAIN]", "")
    If $hWnd Then
        Sleep(100)
        Send("{F12}") ; Select: F12
    Else
        MsgBox($MB_OK, "", "[CLASS:SAC_MAIN] window not found")
    EndIf
EndFunc   ;==>EnableF12View
; -----------------------------------------------

 

I know that I know nothing

Posted
38 minutes ago, mr-es335 said:

Local $hWnd = WinGetHandle("[CLASS:SAC_SCENEPROPERTIES]") ; ⚠ Does not appear to work?!?! ⚠"

 I got the data from   here 
check the windows, in the other scenario you have
Local $hWnd = "[CLASS:SAC_SCENEPROPERTIES]"
Local $hWnd = WinActivate("[CLASS:SAC_MAIN]", "")

 

38 minutes ago, mr-es335 said:

I also discovered that the "$hMsgForm" is NOT existing?!?

What do you mean, when you press cancel, the window doesn't close?
It's working for me

Upload the script you are testing.

I know that I know nothing

Posted (edited)

ioa747,

Here is the current script:

Spoiler
; ReadIniFileG
; 10/25/2025 11:59:29
; -----------------------------------------------
#RequireAdmin
; -----------------------------------------------
#include <AutoItConstants.au3>
#include <ButtonConstants.au3>
#include "ExtMsgBox.au3"
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3> ; To REMOVE LATER!!!
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
; -----------------------------------------------
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
; -----------------------------------------------
Global $Form1, $mForm1Button, $hMsgForm
Global $iWidth = 735, $iHeight = 48, $ixpos = -1, $iypos = -1, $iOpt = 1, $sFontName = "Corbel Bold", $iFontSize = 16, $iFontWt = 800
; -----------------------------------------------
Forms()
; -----------------------------------------------
Func Forms()
    $iFontSize = 14
    ; -----------------------------------------------
    $Form1 = GUICreate("EnableHotKey", 150, 25, 725, 86, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont($iFontSize, $iFontWt, $GUI_FONTNORMAL, $sFontName)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseForm")
    ; ---------------------
    $mForm1Button = GUICtrlCreateButton(" Enable Hotkey", 0, 0, 150, 25)
    GUICtrlSetOnEvent($mForm1Button, "_ColRow")
    ; -----------------------------------------------
    GUISetState(@SW_SHOW, $Form1)
    ; -----------------------------------------------
    While 1
        Sleep(10)
    WEnd
EndFunc   ;==>Forms
; -----------------------------------------------
Func _ColRow()
    Switch @GUI_CtrlId
        Case $mForm1Button
            ToggleNUMPADSUB()
    EndSwitch
EndFunc   ;==>_ColRow
; -----------------------------------------------
Func _CloseForm()
    Switch @GUI_WinHandle
        Case $Form1
            Exit
    EndSwitch
EndFunc   ;==>_CloseForm
; -----------------------------------------------
Func ToggleNUMPADSUB()
    Local Static $bEnabled = True
    Local $aGuiPos = WinGetPos($Form1)
    If $bEnabled Then
        HotKeySet("{NUMPADSUB}", "ReadIniFile")
        GUICtrlSetData($mForm1Button, "Disable Hotkey")
    Else
        WinClose($Form1)
    EndIf
    $bEnabled = Not $bEnabled
EndFunc   ;==>ToggleNUMPADSUB
; -----------------------------------------------
Func ReadIniFile()
    $iFontSize = 14
    ; -----------------------------------------------
    Local $sFilePath = "C:\TestMe\Assets\SceneData.ini"
    Local $aArray = IniReadSection($sFilePath, "Scene Data")
    ; -----------------------------------------------
    Opt("GUIOnEventMode", 0) ; when in $hMsgForm - disable <<<<<<<<<<<<<<<
    Local $hMsgForm = GUICreate("ReadIniFile", 390, 90, 725, 115, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont($iFontSize, $iFontWt, $GUI_FONTNORMAL, $sFontName)
    ; -----------------------------------------------
    Local $idLabel1 = GUICtrlCreateLabel("", 5, 5, 379, 45, $SS_SUNKEN)
    ; ---------------------
    Local $idBtnContinue = GUICtrlCreateButton("Continue", 100, 55, 85, 25, $BS_DEFPUSHBUTTON)
    Local $idBtnCancel = GUICtrlCreateButton("Cancel", 200, 55, 85, 25)
    ; -----------------------------------------------
    GUISetState(@SW_SHOW, $hMsgForm)
    ; -----------------------------------------------
    Local $nMsg, $idx = 1
    GUICtrlSetData($idLabel1, "To copy [" & $aArray[$idx][1] & "]...select [Continue]..." & @CRLF & "Select [Cancel] to exit...")
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $idBtnCancel
                ExitLoop
            Case $idBtnContinue
                ClipPut($aArray[$idx][1])
                ConsoleWrite("$idx= " & $idx & @CRLF)
                ; ---------------------
                If $idx = 1 Then
                    UpdateScenes(725, 210)
                ElseIf $idx = 2 Then
                    UpdateScenes(725, 210)
                ElseIf $idx = 3 Then
                    EnableF10View()
                    UpdateScenes(900, 320)
                ElseIf $idx > 3 Then
                    EnableF12View()
                EndIf
                ; ---------------------
                $idx += 1
                If $idx > $aArray[0][0] Then
                    ExitLoop ; The end of the SceneData.ini data file has been reached!
                EndIf
                GUICtrlSetData($idLabel1, "To copy [" & $aArray[$idx][1] & "]...select [Continue]..." & @CRLF & "Select [Cancel] to exit...")
        EndSwitch
    WEnd
    ; -----------------------------------------------
    GUIDelete($hMsgForm)
    ; -----------------------------------------------
    Opt("GUIOnEventMode", 1) ; when out of $hMsgForm - enable <<<<<<<<<<<<<<<
EndFunc   ;==>ReadIniFile
; -----------------------------------------------
Func UpdateScenes($iX, $iY)
;~  Local $hWnd = WinGetHandle("[CLASS:SAC_SCENEPROPERTIES]") ; ⚠ Does not appear to work?!?! ⚠
    Local $hWnd = "[CLASS:SAC_SCENEPROPERTIES]"                  ; Original line
    ; -----------------------------------------------
    WinActivate("[CLASS:SAC_SCENES]", "")
    MouseClick($MOUSE_CLICK_LEFT, 254, 313, 1, 1) ; The Scenes View is selected, x y clicks speed
    Sleep(100)
    MouseClick($MOUSE_CLICK_LEFT, 133, 165, 2, 1) ; The first line of Scenes View is selected. <<[A]>>
    Sleep(100)
    Send("{End}") ; The [End Of List] is selected via the [End] key.
    MouseClick($MOUSE_CLICK_LEFT, 188, 118, 1, 1) ; The [New] button is selected.
    Sleep(100)
    Send("^v") ; The previously copied text from the ReadIniFile procedure is then pasted into the [Enter Scene Name...] dialog.
    Send("{ENTER}") ; [Enter] is selected, for [Ok] - with the [Enter Scene Name...] dialog being summarily exited.
    ; -----------------------------------------------
    If $hWnd Then
        Sleep(100)
        WinMove($hWnd, "", $iX, $iY) ; The Scene Properties window is displayed and is then moved.
    EndIf
    ; -----------------------------------------------
    If $hWnd Then
        Sleep(100)
        MouseMove($iX, $iY, 0) ; The mouse is moved to the Scene Properties window.
;~  MouseMove(1300, 295, 0) ; The mouse is moved to the Scene Properties window.
    EndIf
EndFunc   ;==>UpdateScenes
; -----------------------------------------------
Func EnableF10View()
;~  1) SAC is activated
    WinActivate("[CLASS:SAC_MAIN]", "")
;~  2) Send("{F10}") is invoked
    Sleep(100)
    Send("{F10}") ; Select: F10
    ; -----------------------------------------------
;~  3) The Ampsim plug-in is launched and positioned
    MouseClick($MOUSE_CLICK_LEFT, 147, 626, 2, 0) ; Launch and position Ampsim plug-in
    Sleep(100)
    Local $hWnd = WinWait("[CLASS:Studio_VstPropertyPage]", "")
    WinMove($hWnd, "", 478, 215)
;~  4) The Start scene is launched
    MouseClick($MOUSE_CLICK_LEFT, 142, 170, 2, 0) ; Launch Start
;~  5) The Session_Master Preset Attribute is selected
    Sleep(100)
    MouseClick($MOUSE_CLICK_LEFT, 540, 420, 1, 0) ; Select Session_Master
;~  6) Preset 001 is launched
    Sleep(100)
    MouseClick($MOUSE_CLICK_LEFT, 550, 660, 2, 0) ; Launch Preset 001
    ; -----------------------------------------------
;~  7) The [UpdateScenes()] function is then executed
;~  8) The [Scenes View] window is selected
;~  9) The first line of the [Scenes View] window is launched
;~  10) The [End Of List] is selected via the [End] key
;~  11) The [Scenes View] window [New] button is selected
;~  12) The previously copied text [via the ReadIniData function] is then
;~      pasted into the [Enter Scene Name] dialog
;~  13) [Enter] is selected [for Ok]
;~  14) Selecting [Ok] exits the [Enter Scene Name...] dialog
;~  15) The [Scene Properties] window is displayed
;~  a) The [Scene Properties] window is then positioned
;~  b) The mouse pointer is postioned over the [FOH Mixer] option
    ; -----------------------------------------------
;~  1) The various [Scene Properties] are [manually] selected
;~  2) When completed, [OK] is [manually] selected
;~  3) The [Start] scene is [manually] selected
;~  *  The above process is repeated for a total of 10 times
;~  4) The [UpdateScenes] F10 process is now completed
;~  6) Select: [Enable F12]
;~  7) Upon selecting [Enable F12], the following is executed:
    ; -----------------------------------------------
;~  a) The Ampsim plug-in is exited
;~  b) The [F12] View is invoked
;~  c) The [Enable F12] is exited
;~  d) The UpdateScenes()] function is exited
;~  e) The [Disable HotKey()] function is exited
EndFunc   ;==>EnableF10View
; -----------------------------------------------
Func EnableF12View()
;~ a) The Ampsim plug-in is exited
    Sleep(100)
    MouseClick($MOUSE_CLICK_LEFT, 1190, 226, 1, 0) ; Exit Ampsim
;~ b) The [F12] View is invoked
    WinActivate("[CLASS:SAC_MAIN]", "")
    Sleep(100)
    Send("{F12}") ; Select: F12
;~ c) The [Enable F12] button is exited
;~ d) The [UpdateScenes()] function is exited
;~ e) The [Disable HotKey()] function is exited
    ; -----------------------------------------------
    GUIDelete($Form1)
    MsgBox($MB_OK, "", "GUIDelete($Form1)", 1)
    GUIDelete($hMsgForm)
    MsgBox($MB_OK, "", "GUIDelete($hMsgForm)", 1)
EndFunc   ;==>EnableF12View
; -----------------------------------------------

 

Note: This same script is provided in the ZIP file as note in the PM - along with the required alterations.

Update!
Employing the sample ZIP data:
1) ReadIniFileG: works, but ReadIni is NOT exited!

2) ReadIniFileH: works, ReadIni IS exited, but F12 is NOT invoked, as $idx is never greater that 3!

ElseIf $idx > 3 Then
EnableF12View()

Here is the ReadIniFileH script:

Spoiler
; ReadIniFileH
; Last updated: 10/25/2025 12:16:12
; -----------------------------------------------
#RequireAdmin
; -----------------------------------------------
#include <AutoItConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
; -----------------------------------------------
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
; -----------------------------------------------
Global $Form1, $mForm1Button
Global $iWidth = 735, $iHeight = 48, $ixpos = -1, $iypos = -1, $iOpt = 1, $sFontName = "Corbel Bold", $iFontSize = 16, $iFontWt = 800
; -----------------------------------------------
Forms()
; -----------------------------------------------
Func Forms()
    $iFontSize = 14
    ; -----------------------------------------------
    $Form1 = GUICreate("EnableHotKey", 150, 25, 725, 86, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont($iFontSize, $iFontWt, $GUI_FONTNORMAL, $sFontName)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseForm")
    ; ---------------------
    $mForm1Button = GUICtrlCreateButton(" Enable Hotkey", 0, 0, 150, 25)
    GUICtrlSetOnEvent($mForm1Button, "_ColRow")
    ; -----------------------------------------------
    GUISetState(@SW_SHOW, $Form1)
    ; -----------------------------------------------
    While 1
        Sleep(10)
    WEnd
EndFunc   ;==>Forms
; -----------------------------------------------
Func _ColRow()
    Switch @GUI_CtrlId
        Case $mForm1Button
            ToggleNUMPADSUB()
    EndSwitch
EndFunc   ;==>_ColRow
; -----------------------------------------------
Func _CloseForm()
    Switch @GUI_WinHandle
        Case $Form1
            Exit
    EndSwitch
EndFunc   ;==>_CloseForm
; -----------------------------------------------
Func ToggleNUMPADSUB()
    Local Static $bEnabled = True
    Local $aGuiPos = WinGetPos($Form1)
    If $bEnabled Then
        HotKeySet("{NUMPADSUB}", "ReadIniFile")
        GUICtrlSetData($mForm1Button, "Disable Hotkey")
    Else
        WinClose($Form1)
    EndIf
    $bEnabled = Not $bEnabled
EndFunc   ;==>ToggleNUMPADSUB
; -----------------------------------------------
Func ReadIniFile()
    $iFontSize = 14
    ; -----------------------------------------------
    Local $sFilePath = "C:\TestMe\Assets\SceneData.ini"
    Local $aArray = IniReadSection($sFilePath, "Scene Data")
    ; -----------------------------------------------
    Opt("GUIOnEventMode", 0) ; when in $hMsgForm - disable <<<<<<<<<<<<<<<
    Local $hMsgForm = GUICreate("ReadIniFile", 390, 90, 725, 115, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont($iFontSize, $iFontWt, $GUI_FONTNORMAL, $sFontName)
    ; -----------------------------------------------
    Local $idLabel1 = GUICtrlCreateLabel("", 5, 5, 379, 45, $SS_SUNKEN)
    ; ---------------------
    Local $idBtnContinue = GUICtrlCreateButton("Continue", 100, 55, 85, 25, $BS_DEFPUSHBUTTON)
    Local $idBtnCancel = GUICtrlCreateButton("Cancel", 200, 55, 85, 25)
    ; -----------------------------------------------
    GUISetState(@SW_SHOW, $hMsgForm)
    ; -----------------------------------------------
    Local $nMsg, $idx = 1
    GUICtrlSetData($idLabel1, "To copy [" & $aArray[$idx][1] & "]...select [Continue]..." & @CRLF & "Select [Cancel] to exit...")
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $idBtnCancel
                ExitLoop
            Case $idBtnContinue
                ClipPut($aArray[$idx][1])
                ConsoleWrite("$idx= " & $idx & @CRLF)
                ; ---------------------
                If $idx < 3 Then
                    UpdateScenes(725, 210)
                ElseIf $idx = 3 Then
                    EnableF10View()
                    UpdateScenes(900, 320)
                ElseIf $idx > 3 Then
                    EnableF12View()
                EndIf
                ; ---------------------
                $idx += 1
                If $idx > $aArray[0][0] Then
                    ExitLoop ; The end of the SceneData.ini data file has been reached!
                EndIf
                ; to resolve empty SceneData
                If $aArray[$idx][1] = "" Then
                    $idx += 1
                    If $idx > $aArray[0][0] Then
                        ExitLoop ; The end of the SceneData.ini data file has been reached!
                    EndIf
                EndIf

                GUICtrlSetData($idLabel1, "To copy [" & $aArray[$idx][1] & "]...select [Continue]..." & @CRLF & "Select [Cancel] to exit...")
        EndSwitch
    WEnd
    ; -----------------------------------------------
    GUIDelete($hMsgForm)
    ; -----------------------------------------------
    Opt("GUIOnEventMode", 1) ; when out of $hMsgForm - enable <<<<<<<<<<<<<<<
EndFunc   ;==>ReadIniFile
; -----------------------------------------------
Func UpdateScenes($iX, $iY)
;~  Local $hWnd = WinGetHandle("[CLASS:SAC_SCENEPROPERTIES]") ; ⚠ Does not appear to work?!?! ⚠
    Local $hWnd = "[CLASS:SAC_SCENEPROPERTIES]"                  ; Original line
    ; -----------------------------------------------
    WinActivate("[CLASS:SAC_SCENES]", "")
    MouseClick($MOUSE_CLICK_LEFT, 254, 313, 1, 1) ; The Scenes View is selected, x y clicks speed
    Sleep(100)
    MouseClick($MOUSE_CLICK_LEFT, 133, 165, 2, 1) ; The first line of Scenes View is selected. <<[A]>>
    Sleep(100)
    Send("{End}") ; The [End Of List] is selected via the [End] key.
    MouseClick($MOUSE_CLICK_LEFT, 188, 118, 1, 1) ; The [New] button is selected.
    Sleep(100)
    Send("^v") ; The previously copied text from the ReadIniFile procedure is then pasted into the [Enter Scene Name...] dialog.
    Send("{ENTER}") ; [Enter] is selected, for [Ok] - with the [Enter Scene Name...] dialog being summarily exited.
    ; -----------------------------------------------
    If $hWnd Then
        Sleep(100)
        WinMove($hWnd, "", $iX, $iY) ; The Scene Properties window is displayed and is then moved.
    EndIf
    ; -----------------------------------------------
    If $hWnd Then
        Sleep(100)
;~      MouseMove($iX, $iY, 0) ; The mouse is moved to the Scene Properties window.
;~  MouseMove(1300, 295, 0) ; The mouse is moved to the Scene Properties window.
        MouseMove(1000, 550, 0) ; The mouse is moved to the Scene Properties window.
    EndIf
EndFunc   ;==>UpdateScenes
; -----------------------------------------------
Func EnableF10View()
;~  1) SAC is activated
    WinActivate("[CLASS:SAC_MAIN]", "")
;~  2) Send("{F10}") is invoked
    Sleep(100)
    Send("{F10}") ; Select: F10
    ; -----------------------------------------------
;~  3) The Ampsim plug-in is launched and positioned
    MouseClick($MOUSE_CLICK_LEFT, 147, 626, 2, 0) ; Launch and position Ampsim plug-in
    Sleep(100)
    Local $hWnd = WinWait("[CLASS:FXEQ]", "")
    WinMove($hWnd, "", 478, 215)
;~  4) The Start scene is launched
    MouseClick($MOUSE_CLICK_LEFT, 142, 170, 2, 0) ; Launch Start
;~  5) The Session_Master Preset Attribute is selected
    Sleep(100)
    MouseClick($MOUSE_CLICK_LEFT, 540, 420, 1, 0) ; Select Session_Master
;~  6) Preset 001 is launched
    Sleep(100)
    MouseClick($MOUSE_CLICK_LEFT, 550, 660, 2, 0) ; Launch Preset 001
    ; -----------------------------------------------
;~  7) The [UpdateScenes()] function is then executed
;~  8) The [Scenes View] window is selected
;~  9) The first line of the [Scenes View] window is launched
;~  10) The [End Of List] is selected via the [End] key
;~  11) The [Scenes View] window [New] button is selected
;~  12) The previously copied text [via the ReadIniData function] is then
;~      pasted into the [Enter Scene Name] dialog
;~  13) [Enter] is selected [for Ok]
;~  14) Selecting [Ok] exits the [Enter Scene Name...] dialog
;~  15) The [Scene Properties] window is displayed
;~  a) The [Scene Properties] window is then positioned
;~  b) The mouse pointer is postioned over the [FOH Mixer] option
    ; -----------------------------------------------
;~  1) The various [Scene Properties] are [manually] selected
;~  2) When completed, [OK] is [manually] selected
;~  3) The [Start] scene is [manually] selected
;~  *  The above process is repeated for a total of 10 times
;~  4) The [UpdateScenes] F10 process is now completed
;~  6) Select: [Enable F12]
;~  7) Upon selecting [Enable F12], the following is executed:
    ; -----------------------------------------------
;~  a) The Ampsim plug-in is exited
;~  b) The [F12] View is invoked
;~  c) The [Enable F12] is exited
;~  d) The UpdateScenes()] function is exited
;~  e) The [Disable HotKey()] function is exited
EndFunc   ;==>EnableF10View
; -----------------------------------------------
Func EnableF12View()
;~ a) The Ampsim plug-in is exited
    Sleep(100)
    MouseClick($MOUSE_CLICK_LEFT, 968, 236, 1, 0) ; Exit Ampsim
;~ b) The [F12] View is invoked
    WinActivate("[CLASS:SAC_MAIN]", "")
    Sleep(100)
    Send("{F12}") ; Select: F12
;~ c) The [Enable F12] button is exited
;~ d) The [UpdateScenes()] function is exited
;~ e) The [Disable HotKey()] function is exited
EndFunc   ;==>EnableF12View
; -----------------------------------------------

 

 

Edited by mr-es335
Posted

Good day,

In EnableF10View, $Form1 and $hMsgForm are "hidden".

This offering attempts at rectifying this anomaly via:
1) Lines 124, 125
2) Lines 143, 144
3) Lines 214, 215

Spoiler
; ReadIniFileG1
; Last updated: 10/25/2025 15:40:55
; -----------------------------------------------
#RequireAdmin
; -----------------------------------------------
#include <AutoItConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
; -----------------------------------------------
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
; -----------------------------------------------
Global $Form1, $mForm1Button, $hMsgForm
Global $iWidth = 735, $iHeight = 48, $ixpos = -1, $iypos = -1, $iOpt = 1, $sFontName = "Corbel Bold", $iFontSize = 16, $iFontWt = 800
; -----------------------------------------------
Forms()
; -----------------------------------------------
Func Forms()
    $iFontSize = 14
    ; -----------------------------------------------
    $Form1 = GUICreate("EnableHotKey", 150, 25, 725, 86, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont($iFontSize, $iFontWt, $GUI_FONTNORMAL, $sFontName)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseForm")
    ; ---------------------
    $mForm1Button = GUICtrlCreateButton(" Enable Hotkey", 0, 0, 150, 25)
    GUICtrlSetOnEvent($mForm1Button, "_ColRow")
    ; -----------------------------------------------
    GUISetState(@SW_SHOW, $Form1)
    ; -----------------------------------------------
    While 1
        Sleep(10)
    WEnd
EndFunc   ;==>Forms
; -----------------------------------------------
Func _ColRow()
    Switch @GUI_CtrlId
        Case $mForm1Button
            ToggleNUMPADSUB()
    EndSwitch
EndFunc   ;==>_ColRow
; -----------------------------------------------
Func _CloseForm()
    Switch @GUI_WinHandle
        Case $Form1
            Exit
    EndSwitch
EndFunc   ;==>_CloseForm
; -----------------------------------------------
Func ToggleNUMPADSUB()
    ConsoleWrite("First call= ToggleNUMPADSUB" & @CRLF)
    Local Static $bEnabled = True
    Local $aGuiPos = WinGetPos($Form1)
    ; -----------------------------------------------
    If $bEnabled Then
        HotKeySet("{NUMPADSUB}", "ReadIniFile")
        GUICtrlSetData($mForm1Button, "Disable Hotkey")
    Else
        ConsoleWrite("Else?" & @CRLF)
;~      WinClose($Form1)
        Exit
    EndIf
    ; -----------------------------------------------
    $bEnabled = Not $bEnabled
EndFunc   ;==>ToggleNUMPADSUB
; -----------------------------------------------
Func ReadIniFile()
    ConsoleWrite("Second call= ReadIniFile" & @CRLF)
    $iFontSize = 14
    ; -----------------------------------------------
    Local $sFilePath = "C:\TestMe\Assets\SceneData.ini"
    Local $aArray = IniReadSection($sFilePath, "Scene Data")
    ; -----------------------------------------------
    Opt("GUIOnEventMode", 0) ; when in $hMsgForm - disable <<<<<<<<<<<<<<<
    Local $hMsgForm = GUICreate("ReadIniFile", 390, 90, 725, 115, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont($iFontSize, $iFontWt, $GUI_FONTNORMAL, $sFontName)
    ; -----------------------------------------------
    Local $idLabel1 = GUICtrlCreateLabel("", 5, 5, 379, 45, $SS_SUNKEN)
    ; ---------------------
    Local $idBtnContinue = GUICtrlCreateButton("Continue", 100, 55, 85, 25, $BS_DEFPUSHBUTTON)
    Local $idBtnCancel = GUICtrlCreateButton("Cancel", 200, 55, 85, 25)
    ; -----------------------------------------------
    GUISetState(@SW_SHOW, $hMsgForm)
    ; -----------------------------------------------
    Local $nMsg, $idx = 1
    GUICtrlSetData($idLabel1, "To copy [" & $aArray[$idx][1] & "]...select [Continue]..." & @CRLF & "Select [Cancel] to exit...")
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $idBtnCancel
                ExitLoop
            Case $idBtnContinue
                ClipPut($aArray[$idx][1])
                ConsoleWrite("$idx= " & $idx & @CRLF)
                ; ---------------------
                If $idx = 1 Then
                    UpdateScenes(725, 210)
                ElseIf $idx = 2 Then
                    UpdateScenes(725, 210)
                ElseIf $idx = 3 Then
                    EnableF10View()
                    UpdateScenes(900, 320)
                ElseIf $idx > 3 Then
                    EnableF12View()
                EndIf
                ; ---------------------
                $idx += 1
                If $idx > $aArray[0][0] Then
                    ExitLoop ; The end of the SceneData.ini data file has been reached!
                EndIf
                GUICtrlSetData($idLabel1, "To copy [" & $aArray[$idx][1] & "]...select [Continue]..." & @CRLF & "Select [Cancel] to exit...")
        EndSwitch
    WEnd
    ; ------------------------------------- ----------
    GUIDelete($hMsgForm)
    ; -----------------------------------------------
    Opt("GUIOnEventMode", 1) ; when out of $hMsgForm - enable <<<<<<<<<<<<<<<
EndFunc   ;==>ReadIniFile
; -----------------------------------------------
Func UpdateScenes($iX, $iY)
    ConsoleWrite("Third call= UpdateScenes" & @CRLF)
    Local $hWnd = "[CLASS:SAC_SCENEPROPERTIES]"
    Local $hWndA = "EnableHotKey"
    Local $hWndB = "ReadIniFile"
    ; -----------------------------------------------
    WinActivate("[CLASS:SAC_SCENES]", "")
    MouseClick($MOUSE_CLICK_LEFT, 254, 313, 1, 1) ; The Scenes View is selected, x y clicks speed
    Sleep(100)
    MouseClick($MOUSE_CLICK_LEFT, 133, 165, 2, 1) ; The first line of Scenes View is selected. <<[A]>>
    Sleep(100)
    Send("{End}") ; The [End Of List] is selected via the [End] key.
    MouseClick($MOUSE_CLICK_LEFT, 188, 118, 1, 1) ; The [New] button is selected.
    Sleep(100)
    Send("^v") ; The previously copied text from the ReadIniFile procedure is then pasted into the [Enter Scene Name...] dialog.
    Send("{ENTER}") ; [Enter] is selected, for [Ok] - with the [Enter Scene Name...] dialog being summarily exited.
    ; -----------------------------------------------
    If $hWnd Then
        Sleep(100)
        WinMove($hWnd, "", $iX, $iY) ; The Scene Properties window is displayed and is then moved.
    EndIf
    ; -----------------------------------------------
    WinActivate($hWndA, "")
    WinActivate($hWndB, "")
    ; -----------------------------------------------
    If $hWnd Then
        Sleep(100)
        MouseMove(1000, 550, 0) ; The mouse is moved to the Scene Properties window.
    EndIf
EndFunc   ;==>UpdateScenes
; -----------------------------------------------
Func EnableF10View()
    ConsoleWrite("Fourth call= EnableF10View" & @CRLF)
;~  1) SAC is activated
    WinActivate("[CLASS:SAC_MAIN]", "")
;~  2) Send("{F10}") is invoked
    Sleep(100)
    Send("{F10}") ; Select: F10
    ; -----------------------------------------------
;~  3) The Ampsim plug-in is launched and positioned
    MouseClick($MOUSE_CLICK_LEFT, 147, 626, 2, 0) ; Launch and position Ampsim plug-in
    Sleep(100)
    Local $hWnd = WinWait("[CLASS:FXEQ]", "")
    WinMove($hWnd, "", 478, 215)
;~  4) The Start scene is launched
    MouseClick($MOUSE_CLICK_LEFT, 142, 170, 2, 0) ; Launch Start
;~  5) The Session_Master Preset Attribute is selected
    Sleep(100)
    MouseClick($MOUSE_CLICK_LEFT, 540, 420, 1, 0) ; Select Session_Master
;~  6) Preset 001 is launched
    Sleep(100)
    MouseClick($MOUSE_CLICK_LEFT, 550, 660, 2, 0) ; Launch Preset 001
    ; -----------------------------------------------
;~  7) The [UpdateScenes()] function is then executed
;~  8) The [Scenes View] window is selected
;~  9) The first line of the [Scenes View] window is launched
;~  10) The [End Of List] is selected via the [End] key
;~  11) The [Scenes View] window [New] button is selected
;~  12) The previously copied text [via the ReadIniData function] is then
;~      pasted into the [Enter Scene Name] dialog
;~  13) [Enter] is selected [for Ok]
;~  14) Selecting [Ok] exits the [Enter Scene Name...] dialog
;~  15) The [Scene Properties] window is displayed
;~  a) The [Scene Properties] window is then positioned
;~  b) The mouse pointer is postioned over the [FOH Mixer] option
    ; -----------------------------------------------
;~  1) The various [Scene Properties] are [manually] selected
;~  2) When completed, [OK] is [manually] selected
;~  3) The [Start] scene is [manually] selected
;~  *  The above process is repeated for a total of 10 times
;~  4) The [UpdateScenes] F10 process is now completed
;~  6) Select: [Enable F12]
;~  7) Upon selecting [Enable F12], the following is executed:
    ; -----------------------------------------------
;~  a) The Ampsim plug-in is exited
;~  b) The [F12] View is invoked
;~  c) The [Enable F12] is exited
;~  d) The UpdateScenes()] function is exited
;~  e) The [Disable HotKey()] function is exited
EndFunc   ;==>EnableF10View
; -----------------------------------------------
Func EnableF12View()
    ConsoleWrite("Fifth call= EnableF12View" & @CRLF)
;~ a) The Ampsim plug-in is exited
    Sleep(100)
    MouseClick($MOUSE_CLICK_LEFT, 968, 236, 1, 0) ; Exit Ampsim
;~ b) The [F12] View is invoked
    WinActivate("[CLASS:SAC_MAIN]", "")
    Sleep(100)
    Send("{F12}") ; Select: F12
;~ c) The [Enable F12] button is exited
;~ d) The [UpdateScenes()] function is exited
;~ e) The [Disable HotKey()] function is exited
; -----------------------------------------------
    Local $hWndA = "EnableHotKey"
    WinActivate($hWndA, "")
EndFunc   ;==>EnableF12View
; -----------------------------------------------

 

Is this an acceptable|workable solution?

Posted (edited)

Good day,

As noted...please make note of the "Build #"...
• Minor updates: Build #a [WorkingwMB1a], Major  udpates: Build # [WorkingwMB2], and so on.
• Note: This script does NOT require the application...as MsgBox's are managing those sections.

; WorkingwMB1: Working with MsgBox's
; Adding an Exit button option [$Form2]
; Last updated: 10/26/2025 07:28:50
Spoiler
; WorkingwMB1: Working with MsgBox's
; Adding an Exit button option [$Form2]
; Last updated: 10/26/2025 07:28:50
; -----------------------------------------------
#RequireAdmin
; -----------------------------------------------
#include <AutoItConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3> ; For testing Only!!!
; -----------------------------------------------
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
; -----------------------------------------------
Global $Form1, $mForm1Button1, $hMsgForm
Global $Form2, $mForm2Button1
Global $iWidth = 735, $iHeight = 48, $ixpos = -1, $iypos = -1, $iOpt = 1, $sFontName = "Corbel Bold", $iFontSize = 16, $iFontWt = 800
; -----------------------------------------------
Forms()
; -----------------------------------------------
Func Forms()
    $iFontSize = 14
    ; -----------------------------------------------
    $Form1 = GUICreate("EnableHotKeyA", 150, 25, 725, 86, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont($iFontSize, $iFontWt, $GUI_FONTNORMAL, $sFontName)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseForm")
    ; ---------------------
    $mForm1Button1 = GUICtrlCreateButton(" Enable Hotkey", 0, 0, 150, 25)
    GUICtrlSetOnEvent($mForm1Button1, "_ColRow")
    ; -----------------------------------------------
    $Form2 = GUICreate("EnableHotKeyB", 150, 25, 725, 86, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont($iFontSize, $iFontWt, $GUI_FONTNORMAL, $sFontName)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseForm")
    ; ---------------------
    $mForm2Button1 = GUICtrlCreateButton("   Exit Hotkey", 0, 0, 150, 25)
    GUICtrlSetOnEvent($mForm2Button1, "_ColRow")
    ; -----------------------------------------------
    GUISetState(@SW_SHOW, $Form1)
    ; -----------------------------------------------
    While 1
        Sleep(10)
    WEnd
EndFunc   ;==>Forms
; -----------------------------------------------
Func _ColRow()
    ConsoleWrite("@GUI_CtrlId= " & @GUI_CtrlId & @CRLF)
    Switch @GUI_CtrlId
        Case $mForm1Button1
            ToggleNUMPADSUB()
        Case $mForm2Button1
        ConsoleWrite("The [Exit Hotkey] button has just been selected!" & @CRLF)
            Exit
    EndSwitch
EndFunc   ;==>_ColRow
; -----------------------------------------------
Func _CloseForm()
    Switch @GUI_WinHandle
        Case $Form1
            Exit
        Case $Form2
            Exit
    EndSwitch
EndFunc   ;==>_CloseForm
; -----------------------------------------------
Func ToggleNUMPADSUB()
    ConsoleWrite("1st call= ToggleNUMPADSUB" & @CRLF)
    Local Static $bEnabled = True
    Local $aGuiPos = WinGetPos($Form1)
    ; -----------------------------------------------
    If $bEnabled Then
        HotKeySet("{NUMPADSUB}", "ReadIniFile")
        GUICtrlSetData($mForm1Button1, "Disable Hotkey")
    Else
        ConsoleWrite("Else?" & @CRLF)
;~      WinClose($Form1)
        Exit
    EndIf
    ; -----------------------------------------------
    $bEnabled = Not $bEnabled
EndFunc   ;==>ToggleNUMPADSUB
; -----------------------------------------------
Func ReadIniFile()
    ConsoleWrite("2nd call= ReadIniFile" & @CRLF)
    $iFontSize = 14
    ; -----------------------------------------------
    Local $sFilePath = "C:\TestMe\Assets\SceneData.ini"
    Local $aArray = IniReadSection($sFilePath, "Scene Data")
    ; -----------------------------------------------
    Opt("GUIOnEventMode", 0) ; when in $hMsgForm - disable <<<<<<<<<<<<<<<
    Local $hMsgForm = GUICreate("ReadIniFile", 390, 90, 725, 115, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetFont($iFontSize, $iFontWt, $GUI_FONTNORMAL, $sFontName)
    ; -----------------------------------------------
    Local $idLabel1 = GUICtrlCreateLabel("", 5, 5, 379, 45, $SS_SUNKEN)
    ; ---------------------
    Local $idBtnContinue = GUICtrlCreateButton("Continue", 100, 55, 85, 25, $BS_DEFPUSHBUTTON)
    Local $idBtnCancel = GUICtrlCreateButton("Cancel", 200, 55, 85, 25)
    ; -----------------------------------------------
    GUISetState(@SW_SHOW, $hMsgForm)
    ; -----------------------------------------------
    Local $nMsg, $idx = 1
    GUICtrlSetData($idLabel1, "To copy [" & $aArray[$idx][1] & "]...select [Continue]..." & @CRLF & "Select [Cancel] to exit...")
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $idBtnCancel
                ExitLoop
            Case $idBtnContinue
                ClipPut($aArray[$idx][1])
;~              ConsoleWrite("$idx= " & $idx & @CRLF)
                ConsoleWrite("$idx= " & $aArray[$idx][1] & @CRLF)
                ; ---------------------
                If $idx < 3 Then
                    UpdateScenes(725, 210)
                ElseIf $idx > 2 And $idx < 4 Then
                    EnableF10View()
                    UpdateScenes(900, 320)
                ElseIf $idx = 4 Then
                    EnableF12View()
                EndIf
                ; ---------------------
                $idx += 1
                If $idx > $aArray[0][0] Then
                    ExitLoop ; The end of the SceneData.ini data file has been reached!
                EndIf
                GUICtrlSetData($idLabel1, "To copy [" & $aArray[$idx][1] & "]...select [Continue]..." & @CRLF & "Select [Cancel] to exit...")
        EndSwitch
    WEnd
    ; ------------------------------------- ----------
    GUIDelete($hMsgForm)
    ; -----------------------------------------------
    Opt("GUIOnEventMode", 1) ; when out of $hMsgForm - enable <<<<<<<<<<<<<<<
EndFunc   ;==>ReadIniFile
; -----------------------------------------------
Func UpdateScenes($iX, $iY)
    Local $hWnd = "[CLASS:SAC_SCENEPROPERTIES]"
    Local $hWndA = "EnableHotKey"
    Local $hWndB = "ReadIniFile"
    ; -----------------------------------------------
    WinActivate($hWndA, "")
    WinActivate($hWndB, "")
    ; -----------------------------------------------
    WinActivate($hWnd, "")
    MsgBox($MB_OK, "", "UpdateScenes is being executed...", 2)
EndFunc   ;==>UpdateScenes
; -----------------------------------------------
Func EnableF10View()
;~  1) SAC is activated
    WinActivate("[CLASS:SAC_MAIN]", "")
;~  2) Send("{F10}") is invoked
    Sleep(100)
    Send("{F10}") ; Select: F10
    ; -----------------------------------------------
    MsgBox($MB_OK, "", "Switch to F10 View...via Send({F10})", 2)
EndFunc   ;==>EnableF10View
; -----------------------------------------------
Func EnableF12View()
;~ b) The [F12] View is invoked
    WinActivate("[CLASS:SAC_MAIN]", "")
    Sleep(100)
    Send("{F12}") ; Select: F12
    ; -----------------------------------------------
    MsgBox($MB_OK, "", "Switch to F12 View...via Send({F12})", 2)
    ; -----------------------------------------------
    Local $hWndA = "EnableHotKey"
    WinActivate($hWndA, "")
    GUISetState(@SW_HIDE, $Form1)
    GUISetState(@SW_SHOW, $Form2)
EndFunc   ;==>EnableF12View
; -----------------------------------------------

 

The SceneData.ini file data:

[Scene Data]
Line1=Start
Line2=Fade-In
Line13=Preset 001
Line22=End
Edited by mr-es335

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