DefiantGhost Posted July 22, 2013 Share Posted July 22, 2013 This is my first post here, so I will try to learn from the posts I've read to make sure all data is included in my explanation. I am trying to make a GUI that will run several programs and show me when they are running and when they are completed. The script is incomplete, and I have run into several problems, but I feel like I'm making progress. But at this time, I cannot seem to get the labels I'm using to display whether or not the program is running to update unless I click on them. I read several posts about this, and from what I can tell, it should be updating. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Users\abeckett\Documents\AutoMain.kxf $Form1 = GUICreate("AMP Mk II", 615, 411, 192, 124) $MenuItem1 = GUICtrlCreateMenu("&File") $MenuItem5 = GUICtrlCreateMenuItem("Run All Now", $MenuItem1) $MenuItem6 = GUICtrlCreateMenuItem("Exit", $MenuItem1) $MenuItem2 = GUICtrlCreateMenu("&Help") $MenuItem3 = GUICtrlCreateMenuItem("Help", $MenuItem2) $MenuItem4 = GUICtrlCreateMenuItem("About", $MenuItem2) $Button1 = GUICtrlCreateButton("View Log", 472, 56, 75, 25) $Button2 = GUICtrlCreateButton("View Log", 472, 104, 75, 25) $Button3 = GUICtrlCreateButton("View Log", 472, 152, 75, 25) $Button4 = GUICtrlCreateButton("View Log", 472, 200, 75, 25) $Button5 = GUICtrlCreateButton("View Log", 472, 248, 75, 25) $Button6 = GUICtrlCreateButton("View Log", 472, 296, 75, 25) $Group1 = GUICtrlCreateGroup("CCleaner Cleaner", 48, 48, 505, 41) Global $Label1 = GUICtrlCreateLabel("Label1", 72, 64, 84, 17) $Button9 = GUICtrlCreateButton("Run Again", 392, 56, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("CCleaner Registry", 48, 96, 505, 41) $Progress2 = GUICtrlCreateProgress(64, 112, 150, 17) $Button10 = GUICtrlCreateButton("Run Again", 392, 104, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("Malwarebytes", 48, 144, 505, 41) $Progress3 = GUICtrlCreateProgress(64, 160, 150, 17) $Button11 = GUICtrlCreateButton("Run Again", 392, 152, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group4 = GUICtrlCreateGroup("AVG", 48, 192, 505, 41) $Progress4 = GUICtrlCreateProgress(64, 208, 150, 17) $Button12 = GUICtrlCreateButton("Run Again", 392, 200, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group5 = GUICtrlCreateGroup("Windows Update", 48, 240, 505, 41) $Progress5 = GUICtrlCreateProgress(64, 256, 150, 17) $Button13 = GUICtrlCreateButton("Run Again", 392, 248, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group6 = GUICtrlCreateGroup("Check Disk", 48, 288, 505, 41) $Progress6 = GUICtrlCreateProgress(64, 304, 150, 17) $Button14 = GUICtrlCreateButton("Run Again", 392, 296, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button7 = GUICtrlCreateButton("Sumbit Reports", 432, 344, 123, 25) $Button8 = GUICtrlCreateButton("Run PM Now", 432, 16, 123, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button8 Run ( "C:\Preventive Maintenance\Preventive.bat" ) ;Runs all maintenance programs Case $Button7 Run ( ) ;Submits all logs to HQ via Maintenance Email Case $Button1 Run ( "notepad.exe C:\Preventive Maintenance\Logs\CCleanerC.log" ) ;opens the CCleaner's Clean Log Case $Button2 Run ( "notepad.exe C:\Preventive Maintenance\Logs\CCleanerR.log" ) ;opens the CCleaner's Registry Log Case $Button3 Run ( "notepad.exe C:\Preventive Maintenance\Logs\MBAM.log" ) ;opens Malwarebytes' Scan Log Case $Button4 Run ( "notepad.exe C:\Preventive Maintenance\Logs\AVG.log" ) ;opens AVG's Scan Log Case $Button5 Run ( "notepad.exe C:\Preventive Maintenance\Logs\WinUpdate.log" ) ;opens the Windows Update Log Case $Button6 Run ( "notepad.exe C:\Preventive Maintenance\Logs\Chkdsk.log" ) ;opens the Check Disk Log Case $MenuItem6 Exit ;Exit's...Duh Case $MenuItem4 MsgBox(64, "About 'AMP Mk II'", "Hey, I made this!" ) ;About Information Case $MenuItem5 Run ( "C:\Preventive Maintenance\Preventive.bat" ) ;Second way to Run all maintenance programs Case $Button9 Run ( "C:\Preventive Maintenance\CCleanerClean.bat" ) ;Runs CCleaner in "Clean" Mode Case $Button10 Run ( "C:\Preventive Maintenance\CCleanerReg.bat" ) ;Runs CCleaner in "Registry" Mode but still is not silent Case $Button11 Run ( "C:\Preventive Maintenance\MBAMQuick.bat" ) ;Runs MBAM quick scan Case $Button12 Run ( "C:\Preventive Maintenance\AVGUpdate.bat" ) ;Runs AVG Update and Runs a Quick Scan Case $Button13 Run ( "C:\Preventive Maintenance\WinUpdate.bat" ) ;Runs WinUpdate and installs updates, still buggy Case $Button14 Run ( "C:\Preventive Maintenance\Chkdsk.bat" ) ;Runs Chkdsk Case $Label1 If ProcessExists("cmd.exe") Then GUICtrlSetData ( $Label1, "Running" ) GUICtrlRead ( $Group1 ) EndSwitch WEnd As of this code, only the first field has the label in it. You can test it by just opening a cmd window, as it will change if you click on it. I hope to make this update when "example.exe" is running, so that each field will update itself independent of the others. Thanks in advance for any help, I hope I included everything needed. Link to comment Share on other sites More sharing options...
BrewManNH Posted July 23, 2013 Share Posted July 23, 2013 You have the label (there's only one that I can see in that script) set to only update if you click on it. What were you trying to get it to change to, and when did you want it to change? 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 GudeHow 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 comment Share on other sites More sharing options...
Edano Posted July 23, 2013 Share Posted July 23, 2013 welcome to autoit. your program does exactly what you tell it to do. you say: tell me the status when label is clicked. when guigetmsg()=$label 1. if you want it dynamically updated, you should not wait for the msg (click). E. [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
Edano Posted July 23, 2013 Share Posted July 23, 2013 (edited) i didn't change too much to keep it simple: . expandcollapse popup;http://www.autoitscript.com/forum/topic/152854-labels-not-updating-unless-clicked-on/#entry1098200 ;Post #1 ;D:\DOKUME~1\ADMINI~1\LOKALE~1\Temp\SLICER\Avatar\photo-thumb-81230.png ;by DefiantGhost ;Script grabbed by SLICER by Edano here: http://www.autoitscript.com/forum/topic/152402-slicer-autoit-forum-script-grabber/?p=1093575 #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Users\abeckett\Documents\AutoMain.kxf $Form1 = GUICreate("AMP Mk II", 615, 411, 192, 124) $MenuItem1 = GUICtrlCreateMenu("&File") $MenuItem5 = GUICtrlCreateMenuItem("Run All Now", $MenuItem1) $MenuItem6 = GUICtrlCreateMenuItem("Exit", $MenuItem1) $MenuItem2 = GUICtrlCreateMenu("&Help") $MenuItem3 = GUICtrlCreateMenuItem("Help", $MenuItem2) $MenuItem4 = GUICtrlCreateMenuItem("About", $MenuItem2) $Button1 = GUICtrlCreateButton("View Log", 472, 56, 75, 25) $Button2 = GUICtrlCreateButton("View Log", 472, 104, 75, 25) $Button3 = GUICtrlCreateButton("View Log", 472, 152, 75, 25) $Button4 = GUICtrlCreateButton("View Log", 472, 200, 75, 25) $Button5 = GUICtrlCreateButton("View Log", 472, 248, 75, 25) $Button6 = GUICtrlCreateButton("View Log", 472, 296, 75, 25) $Group1 = GUICtrlCreateGroup("CCleaner Cleaner", 48, 48, 505, 41) Global $Label1 = GUICtrlCreateLabel("Label1", 72, 64, 84, 17) $Button9 = GUICtrlCreateButton("Run Again", 392, 56, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("CCleaner Registry", 48, 96, 505, 41) $Progress2 = GUICtrlCreateProgress(64, 112, 150, 17) $Button10 = GUICtrlCreateButton("Run Again", 392, 104, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("Malwarebytes", 48, 144, 505, 41) $Progress3 = GUICtrlCreateProgress(64, 160, 150, 17) $Button11 = GUICtrlCreateButton("Run Again", 392, 152, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group4 = GUICtrlCreateGroup("AVG", 48, 192, 505, 41) $Progress4 = GUICtrlCreateProgress(64, 208, 150, 17) $Button12 = GUICtrlCreateButton("Run Again", 392, 200, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group5 = GUICtrlCreateGroup("Windows Update", 48, 240, 505, 41) $Progress5 = GUICtrlCreateProgress(64, 256, 150, 17) $Button13 = GUICtrlCreateButton("Run Again", 392, 248, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group6 = GUICtrlCreateGroup("Check Disk", 48, 288, 505, 41) $Progress6 = GUICtrlCreateProgress(64, 304, 150, 17) $Button14 = GUICtrlCreateButton("Run Again", 392, 296, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button7 = GUICtrlCreateButton("Sumbit Reports", 432, 344, 123, 25) $Button8 = GUICtrlCreateButton("Run PM Now", 432, 16, 123, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button8 Run ( "C:\Preventive Maintenance\Preventive.bat" ) ;Runs all maintenance programs Case $Button7 Run ( ) ;Submits all logs to HQ via Maintenance Email Case $Button1 Run ( "notepad.exe C:\Preventive Maintenance\Logs\CCleanerC.log" ) ;opens the CCleaner's Clean Log Case $Button2 Run ( "notepad.exe C:\Preventive Maintenance\Logs\CCleanerR.log" ) ;opens the CCleaner's Registry Log Case $Button3 Run ( "notepad.exe C:\Preventive Maintenance\Logs\MBAM.log" ) ;opens Malwarebytes' Scan Log Case $Button4 Run ( "notepad.exe C:\Preventive Maintenance\Logs\AVG.log" ) ;opens AVG's Scan Log Case $Button5 Run ( "notepad.exe C:\Preventive Maintenance\Logs\WinUpdate.log" ) ;opens the Windows Update Log Case $Button6 Run ( "notepad.exe C:\Preventive Maintenance\Logs\Chkdsk.log" ) ;opens the Check Disk Log Case $MenuItem6 Exit ;Exit's...Duh Case $MenuItem4 MsgBox(64, "About 'AMP Mk II'", "Hey, I made this!" ) ;About Information Case $MenuItem5 Run ( "C:\Preventive Maintenance\Preventive.bat" ) ;Second way to Run all maintenance programs Case $Button9 Run ( "C:\Preventive Maintenance\CCleanerClean.bat" ) ;Runs CCleaner in "Clean" Mode Case $Button10 Run ( "C:\Preventive Maintenance\CCleanerReg.bat" ) ;Runs CCleaner in "Registry" Mode but still is not silent Case $Button11 Run ( "C:\Preventive Maintenance\MBAMQuick.bat" ) ;Runs MBAM quick scan Case $Button12 Run ( "C:\Preventive Maintenance\AVGUpdate.bat" ) ;Runs AVG Update and Runs a Quick Scan Case $Button13 Run ( "C:\Preventive Maintenance\WinUpdate.bat" ) ;Runs WinUpdate and installs updates, still buggy Case $Button14 Run ( "C:\Preventive Maintenance\Chkdsk.bat" ) ;Runs Chkdsk Case $Label1 GUICtrlRead ( $Group1 ) EndSwitch If ProcessExists("cmd.exe") Then GUICtrlSetData ( $Label1, "Running" ) WEnd . but this should do what you want E. Edited July 23, 2013 by Edano [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
DefiantGhost Posted July 23, 2013 Author Share Posted July 23, 2013 @Edano That worked perfectly. All I had to do was add a If Not Process Exists to make it change back when it was closed and everything works like I wanted. Thank you! I do notice however, that after making all 6 labels work, the program seems to have slowed down. Should I add a sleep function in the code somewhere to improve response time? Link to comment Share on other sites More sharing options...
Edano Posted July 23, 2013 Share Posted July 23, 2013 i don't think that you would notice any speed difference on only 6 labels. but there could be much done to improve your code. to avoid the flickering of the labels you should think about only updating the labels when there is a change in the process state. think about using a variable for each process that can store the state of the process 1 (running) or 0 (not running) (a "flag"). the you only have to update the label when the status changes. i am sure you find out what i mean cheers E. [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
kylomas Posted July 24, 2013 Share Posted July 24, 2013 defiantghost, There are several program launchers on the forums. You may be interested in looking at them to see how other people have approached the problem. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now