Sign in to follow this  
Followers 0
stoneheart

need help with GUI notification message

4 posts in this topic

Simply I need help to create GUI Message run in the first of script that I already did it, all I need to create GUI with “OK” button when I click it run the script

For example

Create GUI and not message box coz I will change the font and set background with OK” button when I click it run notepade.exe and type blah blah blah….

I use it for software automation installations and I need the GUI to run in the beginning and then run the installation, I made the installations scripts but I didn’t work with a GUI so I can’t do it.

Thank you for help

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

For example

Create GUI and not message box coz I will change the font and set background with OK” button when I click it run notepade.exe and type blah blah blah….

Do you mean: create a GUI with a set background, nice font and an ok button,?

Do you mean: run Notepad.exe and type blah blah blah when you click ok?

Please try and separate your sentences, it's difficult to understand what you are asking. I suggest you look at the examples in the AutoIt3 folder in program files:

C:\Program Files\AutoIt3\Examples\GUI\Simple
Edited by czardas

Share this post


Link to post
Share on other sites

Thanks czardas for your reply

but i already check it but am new with AutoIt so I just need the code that’s when I click on it close the GUI and run the script

i dont get it from the simple

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

You should take some of the shorter examples and try to modify them to see what results you get. Read what it says in the help file about each part of the code and try to get a feel for how it works. Strip it down and try to rebuild it. I will give an example of how this can be done. The following example is taken from the examples folder. => msgbox_messageloop.au3

BEFORE

; A simple custom messagebox that uses the MessageLoop mode

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()
    Local $YesID, $NoID, $ExitID, $msg

    GUICreate("Custom Msgbox", 210, 80)

    GUICtrlCreateLabel("Please click a button!", 10, 10)
    $YesID = GUICtrlCreateButton("Yes", 10, 50, 50, 20)
    $NoID = GUICtrlCreateButton("No", 80, 50, 50, 20)
    $ExitID = GUICtrlCreateButton("Exit", 150, 50, 50, 20)

    GUISetState()  ; display the GUI

    Do
        $msg = GUIGetMsg()

        Select
            Case $msg = $YesID
                MsgBox(0, "You clicked on", "Yes")
            Case $msg = $NoID
                MsgBox(0, "You clicked on", "No")
            Case $msg = $ExitID
                MsgBox(0, "You clicked on", "Exit")
            Case $msg = $GUI_EVENT_CLOSE
                MsgBox(0, "You clicked on", "Close")
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE Or $msg = $ExitID
EndFunc   ;==>_Main

AFTER

#include <GUIConstantsEx.au3>

_Main() ; It is convenient to be able to call a function which runs/opens the GUI

MsgBox(0, "After clicking the yes button.","The script will now run.")
; Your script goes here.

Func _Main()
    Local $myGUI, $YesID, $NoID, $msg ; Declares the variables used in this function.

    $myGUI = GUICreate("Run Script?", 210, 80) ; Creates the GUI

    ; Modifying the numbers within the brackets below changes the size and position of the label or buttons.
    GUICtrlCreateLabel("Do you want to run the script?", 10, 10) ; Alter the text to suit your purposes.
    $YesID = GUICtrlCreateButton("Yup", 10, 50, 50, 20)
    $NoID = GUICtrlCreateButton("Nah", 80, 50, 50, 20)
    ; $ExitID button has been removed.
    ; Notice that I also had to remove all references to that button.

    GUISetState()  ; displays the GUI

    While 1 ; Loop around and keep repeating the tests below.
        $msg = GUIGetMsg() ; Gets the last button clicked
        Select ; Selects an action to do if a button is clicked.
            Case $msg = $YesID
                ExitLoop ; Stop looping around ( does not exit the program )
            Case $msg = $NoID
                Exit ; Exit the program
            Case $msg = $GUI_EVENT_CLOSE
                Exit
        EndSelect
    Wend
    GUIDelete($myGUI) ; Delete the GUI before running the script.
EndFunc

You will notice several differences in the second example. I have removed a button and modified the script to make it work the way I want it to work. Although it doesn't look perfect yet, you can see the method of rebuilding by comparing the two examples. I have also added some comments to try to guide you through. I hope you find it useful.

Edited by czardas

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0