Sign in to follow this  
Followers 0
niceguy75

Need help in writing simple GUI script

10 posts in this topic

#1 ·  Posted (edited)

I am new when it comes to writing autoit script but then also I am trying to write a GUI which can open a dialogue box with two buttons ("Yes" and "No"), if I hit "Yes" dialogue box closes and script starts the installation of Intel® HD Graphic Driver and wait till the installation finishes and then execute the next command (I have series of commands before and after this GUI script), and if hit "No" the dialogue box closes and start executing next command in the script. Till now I could only manage to write this:

#include <GUIConstantsEx.au3>
Example()Func Example()
    Local $Button_1, $Button_2, $msg
    GUICreate("Windows 7 Ultimate SP1", 300, 100) ; will create a dialog box that when displayed is centered
GUICtrlCreateLabel("Do you wish to install Intel(R) HD Graphic Driver?", 10, 10)
    Opt("GUICoordMode", -1)
    $Button_1 = GUICtrlCreateButton("Yes", 60, 60, 60)
    $Button_2 = GUICtrlCreateButton("No", 190, 60, 60)  

    GUISetState() ; will display an  dialog box with 2 button.
    

   ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_1
    Runwait('C:WindowsIntel.exe') ; Will start driver installation
    ExitLoop
   Case $msg = $Button_2
                MsgBox(0, 'Windows 7 Ultimate SP1', 'System will reboot now') ; Will demonstrate Button 2 being pressed
    ExitLoop
        EndSelect
    WEnd
EndFunc   ;==>Example

Now the problem is................ if I use run command it will start the installation and then start executing next command; and if I use runwait command the GUI window would be open till the installation finishes. But I want GUI window to close and start installation of driver, and I also like my script to wait till the installation finishes before executing next command. And after finishing the installation it start executing next command.

Similarly when I hit "No" the dialogue box closes and start executing next command. ( I guess this one I have already achieved)

Please help me guys.

Edited by niceguy75

Share this post


Link to post
Share on other sites



Have you tried: GUISetState(@SW_HIDE) before the runwait command?


Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Share this post


Link to post
Share on other sites

Try this:

#include <GUIConstantsEx.au3>
Example()

Func Example()
    Local $Button_1, $Button_2, $msg
    GUICreate("Windows 7 Ultimate SP1", 300, 100) ; will create a dialog box that when displayed is centered
    GUICtrlCreateLabel("Do you wish to install Intel® HD Graphic Driver?", 10, 10)
    Opt("GUICoordMode", -1)
    $Button_1 = GUICtrlCreateButton("Yes", 60, 60, 60)
    $Button_2 = GUICtrlCreateButton("No", 190, 60, 60)

    GUISetState() ; will display an  dialog box with 2 button.


   ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_1
                $pid = Run('C:WindowsIntel.exe') ; Will start driver installation
                Wait4End($pid)
                MsgBox(0, "Test", "Done.")
                ExitLoop
            Case $msg = $Button_2
                MsgBox(0, 'Windows 7 Ultimate SP1', 'System will reboot now') ; Will demonstrate Button 2 being pressed
                ExitLoop
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Wait4End($pid)
    Do
    Until Not ProcessExists($pid) * Sleep(100)
EndFunc

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks mate, I would test it and will post the result soon.

Edit: Though I have not tried it with the OS but I have changed the "Driver.exe" with the "notepad.exe" and found that the dialogue box is still open (till the notepad is open) and I want it to be closed when "Yes" button is clicked and it also start the driver installation or displays a msg that OS installing the driver using "TRAYTIP("::Windows 7 Ultimate SP1::", "Windows is installing Intel® HD Graphic Driver", 30)" command.

Edited by niceguy75

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Here try this:

#include <GUIConstantsEx.au3>
Example()
Func Example()
    Local $Button_1, $Button_2, $msg, $Gui
    $Gui = GUICreate("Windows 7 Ultimate SP1", 300, 100) ; will create a dialog box that when displayed is centered
    GUICtrlCreateLabel("Do you wish to install Intel® HD Graphic Driver?", 10, 10)
    Opt("GUICoordMode", -1)
    $Button_1 = GUICtrlCreateButton("Yes", 60, 60, 60)
    $Button_2 = GUICtrlCreateButton("No", 190, 60, 60)
    GUISetState() ; will display an  dialog box with 2 button.

   ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_1
                GUIDelete($Gui)
    $pid = Run('notepad.exe') ; Will start driver installation
                Wait4End($pid)
                MsgBox(0, "Test", "Done.")
                ExitLoop
            Case $msg = $Button_2
                MsgBox(0, 'Windows 7 Ultimate SP1', 'System will reboot now') ; Will demonstrate Button 2 being pressed
                ExitLoop
        EndSelect
    WEnd
EndFunc   ;==>Example
Func Wait4End($pid)
    Do
    Until Not ProcessExists($pid) * Sleep(100)
EndFunc

I just add GUIDelete($Gui) to the code so it deletes the gui before running the installation.

Edited by Aipion

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Here try this:

#include <GUIConstantsEx.au3>
Example()
Func Example()
    Local $Button_1, $Button_2, $msg, $Gui
    $Gui = GUICreate("Windows 7 Ultimate SP1", 300, 100) ; will create a dialog box that when displayed is centered
    GUICtrlCreateLabel("Do you wish to install Intel® HD Graphic Driver?", 10, 10)
    Opt("GUICoordMode", -1)
    $Button_1 = GUICtrlCreateButton("Yes", 60, 60, 60)
    $Button_2 = GUICtrlCreateButton("No", 190, 60, 60)
    GUISetState() ; will display an  dialog box with 2 button.

   ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_1
                GUIDelete($Gui)
    $pid = Run('notepad.exe') ; Will start driver installation
                Wait4End($pid)
                MsgBox(0, "Test", "Done.")
                ExitLoop
            Case $msg = $Button_2
                MsgBox(0, 'Windows 7 Ultimate SP1', 'System will reboot now') ; Will demonstrate Button 2 being pressed
                ExitLoop
        EndSelect
    WEnd
EndFunc   ;==>Example
Func Wait4End($pid)
    Do
    Until Not ProcessExists($pid) * Sleep(100)
EndFunc

I just add GUIDelete($Gui) to the code so it deletes the gui before running the installation.

Cool, just one question if I add some commands after "EndFunc" will it execute those commands, once the driver is installed or if I hit "No" in case I don't want to install the driver? Edited by niceguy75

Share this post


Link to post
Share on other sites

Cool, just one question if I add some commands after "EndFunc" will it execute those commands, once the driver is installed or if I hit "No" in case I don't want to install the driver?

yes, they will be executed.

Share this post


Link to post
Share on other sites

yes, they will be executed.

Thank you mate, and thanks to all as well.

Share this post


Link to post
Share on other sites

i like the fancy code you all have. :) here is a much simpler solution...

If MsgBox(4, "Intel® HD Graphic Driver Installation", "Do you want to install the driver for the Intel® HD Graphic Card?") = 6 Then
    MsgBox(0,"","Installation will be begin shortly.")
    ;install the driver here
EndIf
;carry on code

Share this post


Link to post
Share on other sites

i like the fancy code you all have. :) here is a much simpler solution...

If MsgBox(4, "Intel® HD Graphic Driver Installation", "Do you want to install the driver for the Intel® HD Graphic Card?") = 6 Then
    MsgBox(0,"","Installation will be begin shortly.")
    ;install the driver here
EndIf
;carry on code

Wow, nice little script, I have edited your script and made this one to try with notepad, and it worked perfectly.

If MsgBox(4, "::Windows 7 Ultimate SP1::", "Do you want to install the driver for the Intel® HD Graphic Card?") = 6 Then
TRAYTIP("::Windows 7 Ultimate SP1::", "Windows is installing Intel® HD Graphic Driver", 30)
Runwait("C:\Windows\System32\notepad.exe", @WindowsDir, @SW_SHOW)
EndIf

Thanks mate.

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