Jump to content

Replace MsgBox within a Function with a User Form


Go to solution Solved by mr-es335,

Recommended Posts

Posted

ioa747,

You stated, "What role does this play, since with each entry you become independent? "

Not really following you here, ios747? May I ash what you mean by "becoming independent"?

PS: The .ini file will ALWAYS be in the specified location...thus the hard coding.

Posted
17 hours ago, mr-es335 said:

I determined that the period of time from copy|paste to insertion varied considerably.

I'm referring to the time it takes for each entry.
After finishing one, it moves on to the next, moves on to the next, ...

I know that I know nothing

Posted (edited)

ioa747,

You stated, "After finishing one, it moves on to the next, moves on to the next, ... " ...That is correct!

The data is always the same - though I do implement the script in two different "scenarios" - with each script employing that script's own ".ini" data.

I thought that the following might be interest: [Click_Me]
• The "Disclaimer"at the beginning of the test is required, as I write technical documentation for both companies as mentioned in the text.

Edited by mr-es335
Posted

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

My completed script...[...at least, I do sincerely believe this iteration to be so!?!]

Spoiler
; https://www.autoitscript.com/forum/topic/213269-script-critique-enablehotkey/#findComment-1546695
; From ioa747
; Last completed: 9:01 AM 10/20/2025
; -----------------------------------------------------------
#RequireAdmin
; -----------------------------------------------------------
#include <AutoItConstants.au3>
#include <ButtonConstants.au3>
#include "ExtMsgBox.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, BitOR($WS_EX_TOOLWINDOW, $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()
    ; The ReadIniFile procedure is launched.
    ; Upon selecting [Continue], the first line of the .ini file is read and then copied to the clipboard.
    ; -----------------------------------------------
    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, BitOR($WS_EX_TOOLWINDOW, $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)
    Local $idBtnAbout = GUICtrlCreateLabel("!", 360, 55, 10, 20)
    ; -----------------------------------------------
    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
            Case $idBtnAbout
                AboutMe()
                ; -----------------------------------------------
                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]"
    ; -----------------------------------------------
    ; F Mixer Number Zone[s] is|are [manually] selected
    ; -----------------------------------------------
    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.
    ; -----------------------------------------------
    Sleep(100)
    WinMove($hWnd, "", 725, 210) ; The Scene Properties window is displayed and is then moved.
    ; -----------------------------------------------
    Sleep(100)
    MouseMove(1300, 295, 0) ; The mouse is moved to the Scene Properties window.
    ; -----------------------------------------------
    ; The Scene Properties are [manually] selected.
    ; [OK] is [manually] selected.
    ; The [Start] scene is [manually] selected. BEING TESTED, SEE [A] ABOVE!!!!
EndFunc   ;==>UpdateScenes
; -----------------------------------------------
Func AboutMe()
    Local $sMsg
    ; -----------------------------------------------
    _ExtMsgBoxSet(64, 4, Default, Default, 14, "Corbel Bold")
    $sMsg = "Enable Hotkey Script" & @CRLF & @CRLF
    $sMsg &= "Version 3.3b" & @CRLF & @CRLF
    $sMsg &= "Scripting by Dell Krauchi" & @CRLF
    $sMsg &= "Sentinel Music Studios" & @CRLF & @CRLF
    $sMsg &= "With the sincerest gratitude of ioa747...whose assistance in this project has been incalculable!" & @CRLF & @CRLF
    $sMsg &= "This script was developed specifically for implementation with the Live_Rig." & @CRLF & @CRLF
    $sMsg &= "Last updated: October 20th, 2025" & @CRLF
;~  $sMsg &= "" & @CRLF & @CRLF
    ; -----------------------------------------------
    _ExtMsgBox(64, "Ok", "About!", $sMsg, 0)
EndFunc   ;==>AboutMe
; -----------------------------------------------

 

Thank you for your time...appreciated!

Posted

Have you tried it?
because I think it should be in this order

; from
            Case $idBtnAbout
                AboutMe()
                ; -----------------------------------------------
                GUICtrlSetData($idLabel1, "To copy [" & $aArray[$idx][1] & "]...select [Continue]..." & @CRLF & "Select [Cancel] to exit...")
                
; to

                GUICtrlSetData($idLabel1, "To copy [" & $aArray[$idx][1] & "]...select [Continue]..." & @CRLF & "Select [Cancel] to exit...")
                ; -----------------------------------------------                
            Case $idBtnAbout
                AboutMe()

 

I know that I know nothing

  • Solution
Posted (edited)

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

The following was provided by ioa747 - of which, was the basis from my completed script...many, many thanks!

Spoiler
; https://www.autoitscript.com/forum/messenger/68303/#findComment-147792
; Provided by: ioa747
; -----------------------------------------------
;~ #RequireAdmin
; -----------------------------------------------
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
; -----------------------------------------------
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
; -----------------------------------------------
Global $hForm, $idFormLabel1, $idFormLabel2, $ArrayValue, $iReturnValue
Global $iWidth = 735, $iHeight = 48, $ixpos = -1, $iypos = -1, $iOpt = 1, $sFontName = "Corbel Bold", $iFontSize = 14, $iFontWt = 800
; -----------------------------------------------
_Main()
; -----------------------------------------------
Func _Main()
    $hForm = GUICreate(" ", 130, 20, 730, 120)
    GUISetFont($iFontSize, $iFontWt, $GUI_FONTNORMAL, $sFontName)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseForm")
    ; ---------------------
    $idFormLabel1 = GUICtrlCreateButton("OK", 0, 0, 60, 20)
    GUICtrlSetOnEvent($idFormLabel1, "_ColRow")
    ; ---------------------
    $idFormLabel2 = GUICtrlCreateButton("Cancel", 70, 0, 60, 20)
    GUICtrlSetOnEvent($idFormLabel2, "_ColRow")
    ; -----------------------------------------------
    GUISetState()
    ; -----------------------------------------------
    While 1
        Sleep(1000)
    WEnd
EndFunc   ;==>_Main
; -----------------------------------------------
Func _ColRow()
    Switch @GUI_CtrlId
        Case $idFormLabel1
            OnOK()
        Case $idFormLabel2
            Exit
    EndSwitch
EndFunc   ;==>_ColRow
; -----------------------------------------------
Func _CloseForm()
    Switch @GUI_WinHandle
        Case $hForm
            Exit
    EndSwitch
EndFunc   ;==>_CloseForm
; -----------------------------------------------
Func OnOK()
    Opt("GUIOnEventMode", 0) ; when in $hMsgForm - disable <<<<<<<<<<<<<<<
    Local $hMsgForm = GUICreate("ReadIniFile", 750, 85, -1, -1, $WS_POPUP)
    GUISetFont($iFontSize, $iFontWt, $GUI_FONTNORMAL, $sFontName)
    Local $idLabel_1 = GUICtrlCreateLabel("", 5, 5, 740, 40)
    Local $idBtnContinue = GUICtrlCreateButton("Continue", 280, 55, 85, 25)
    Local $idBtnCancel = GUICtrlCreateButton("Cancel", 375, 55, 85, 25)
    GUISetState(@SW_SHOW, $hMsgForm)

    Local $sFilePath = @ScriptDir & "\SceneData.ini" ; "E:\Desktop\Working\Tests\ReadIni\SceneData.ini"
    Local $aArray = IniReadSection($sFilePath, "Scene Data")

    Run("notepad.exe")
    Local $hNote = WinWaitActive("[CLASS:Notepad]", "", 3)

    Local $nMsg, $idx = 1
    GUICtrlSetData($idLabel_1, $aArray[$idx][1] & @CRLF & "...will be copied to the Clipboard....continue...")
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $idBtnCancel
                ExitLoop

            Case $idBtnContinue
                ClipPut($aArray[$idx][1])

                WinActivate($hNote)
                Send("^v")
                Send("{ENTER}")

                $idx += 1
                If $idx > $aArray[0][0] Then ExitLoop ; It means we have reached the end.
                GUICtrlSetData($idLabel_1, $aArray[$idx][1] & @CRLF & "...will be copied to the Clipboard....continue...")
        EndSwitch
    WEnd

    GUIDelete($hMsgForm)
    Opt("GUIOnEventMode", 1) ; when out of $hMsgForm - enable <<<<<<<<<<<<<<<
EndFunc   ;==>OnOK

 

Note: The Solution belongs to ioa747...and NOT to me!!

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