DigDeep Posted July 3, 2017 Share Posted July 3, 2017 I am running Microsoft's MBSA tool here and wanted the Progressbar to show up only until the time the ProcessExists "mbsacli.exe". Once it closes off, $Bar should also Hide. doing something wrong here... When Button is clicked, process starts but it still goes on even after Process closes. #include <Process.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <ProgressConstants.au3> #include <SendMessage.au3> $Form1 = GUICreate("Progress Test", 325, 121, -1, -1) $Bar = GUICtrlCreateProgress(18, 26, 288, 20, $PBS_MARQUEE) $Run = GUICtrlCreateButton("Run", 120, 72, 75, 25, $SS_CENTER) $LblComplete = GUICtrlCreateLabel("Completed", 16, 32, 294, 17, $SS_CENTER) GUICtrlSetFont($LblComplete, 11, 400, 0, "Arial") GUICtrlSetState($LblComplete, $GUI_HIDE) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Run Do _SendMessage(GUICtrlGetHandle($Bar), $PBM_SETMARQUEE, True, 50) $Pid = Run(@ComSpec & ' /c "C:\Program Files\Microsoft Baseline Security Analyzer 2\MBSACLI" /xmlout /catalog C:\Temp\wsusscn2.cab /unicode /nvc >C:\Temp\Output.xml', "", @SW_HIDE) Until ProcessExists($Pid) ; $Bar should hide now... ; GUICtrlSetState($Bar, $GUI_HIDE) ; $LblComplete should show now... ;GUICtrlSetState($LblComplete, $GUI_SHOW) EndSwitch WEnd Link to comment Share on other sites More sharing options...
InunoTaishou Posted July 10, 2017 Share Posted July 10, 2017 Looks like no one ever responded. Give this a go expandcollapse popup#include <Process.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <ProgressConstants.au3> #include <SendMessage.au3> Global $Pid = Null $Form1 = GUICreate("Progress Test", 325, 121, -1, -1) $Bar = GUICtrlCreateProgress(18, 26, 288, 20, $PBS_MARQUEE) $Run = GUICtrlCreateButton("Run", 120, 72, 75, 25, $SS_CENTER) $LblComplete = GUICtrlCreateLabel("Completed", 16, 32, 294, 17, $SS_CENTER) GUICtrlSetFont($LblComplete, 11, 400, 0, "Arial") GUICtrlSetState($LblComplete, $GUI_HIDE) GUICtrlSetState($Bar, $GUI_HIDE)= GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Run $Pid = Run(@SystemDir & "\notepad.exe") _SendMessage(GUICtrlGetHandle($Bar), $PBM_SETMARQUEE, True, 50) GUICtrlSetState($Bar, $GUI_SHOW) GUICtrlSetState($LblComplete, $GUI_HIDE) Case Else If ($Pid) Then If (Not ProcessExists($Pid)) Then $Pid = Null GUICtrlSetState($Bar, $GUI_HIDE) GUICtrlSetState($LblComplete, $GUI_SHOW) EndIf EndIf EndSwitch WEnd Store the PID In a global variable and throw it in the Else on the Switch. If the process has been started then check to see if it still exists. If it doesn't (Not Process Exists) then set PID back to Null and reset the bar/label Link to comment Share on other sites More sharing options...
larksp Posted July 19, 2017 Share Posted July 19, 2017 there is an extra = on the end of the code that brings up an error encase any one cared GUICtrlSetState($Bar, $GUI_HIDE)= 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