Jump to content

Recommended Posts

Hello all I am trying to make a little GUI with a couple buttons on it that will allow someone to exit or continue on and run the little shell command I want. I am having trouble with the OK button currently in the code below it starts the program just fine and runs it but the GUI stays open in the background and doesn't close after the program finishes. Not sure what I am missing. I copied the example out of the help file and tried to modify it to what I am doing. Any help is greatly appreciated.

#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode
$mainwindow = GUICreate("System File Checker", 265, 100)
GUICtrlCreateLabel("You may need your Operating System cd or dvd." & @CRLF & "To continue click OK... or you can close this box.", 25, 10)
$okbutton = GUICtrlCreateButton("OK", 80,50, 100)
GUICtrlSetOnEvent($okbutton, "OKButton")
While 1
  Sleep(1000)  ; Idle around
Func OKButton()
    ;MsgBox(0, "GUI Event", "You Pressed OK")
Func CLOSEClicked()
Link to post
Share on other sites

If the ShellExecuteWait won't work correctly with this program, you could use

While ProcessExists("sfc.exe")

this will pause the script until that program isn't running any more.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to post
Share on other sites

When you are expecting it to finish, look in taskmanager or similar to see if the process is still running.



What BrewManNH said, but use ShellExecute.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to post
Share on other sites

Yes it was still running. I added the While Process Exists and changed it to shellexecute I think that has it sorted. Is there anyway in which you could have the ok box minimize to like the systray or similar? I worry that if someone can see it there they will try to click it again and get multiple instances of the sfc.exe running. Thank you both for your help and direction its great that you take time out of your days to help people like me. ;)

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...