Jump to content

Recommended Posts

Posted (edited)

Good day,

I hope that all is having a great day thus far?

I hope, as always, that I am asking the appropriate questions here?

I have the following script which provides the ability to launch and to exit notepad. However, the GUI "appears" sluggish!

Here is the script:

; -----------------------------------------------
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
; -----------------------------------------------
$Form1 = GUICreate("", 95, 45)
$Button = GUICtrlCreateButton("Launch Me", 10, 10, 75, 25)
GUISetState(@SW_SHOW)
; -----------------------------------------------
While 1
    $nMsg = GUIGetMsg()
    ; -----------------
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button
            _LaunchTAC()
            _form2()
    EndSwitch
WEnd
; -----------------------------------------------
Func _LaunchTAC()
    Local $sSrcAppPath = "C:\Windows\System32\notepad.exe"
    ; -----------------------------------------------
    Run($sSrcAppPath)
    ; -----------------------------------------------
    Sleep(500)
    ; -----------------
    WinMove("[CLASS:Notepad]", "", 150, 250, 250, 250)
EndFunc   ;==>_LaunchTAC
; -----------------------------------------------
Func _form2()
    $Form2 = GUICreate("", 95, 45, 215, 340)
    $Button = GUICtrlCreateButton("Exit Me", 10, 10, 75, 25)
    ; -----------------
    GUISetState(@SW_SHOW)
    ; -----------------
    While 2
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button
                _ExitMe()
                GUIDelete($Form2)
                GUISetState(@SW_ENABLE, $Form1)
                Return
        EndSwitch
    WEnd
EndFunc   ;==>_form2
; -----------------------------------------------
Func _ExitMe()
    Local $sAppTitle = "[CLASS:Notepad]"
    ; -----------------------------------------------
    WinClose($sAppTitle)
EndFunc   ;==>_ExitTac
; -----------------------------------------------

Also, I am not able to execute the first button command a second time!

Any ideas|suggestions would be greatly appreciated.

Edited by mr-es335
  • mr-es335 changed the title to Speed-up GUI Launch and Exit

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   1 member

×
×
  • Create New...