Jump to content
Sign in to follow this  
xilace

Not able to exit GUI?

Recommended Posts

xilace

I'm trying to figure out why the first one works when i have just the one GUI showing a count down progress bar, but when i call that same GUI by clicking the "demo" button on the 2nd set of code it doesnt allow me to click cancel or X out of the countdown progress bar.

Works by its self doing a count down from 60-0, can click Cancel or the red X and it closes.

;Window for descending progress bar
#Region Progressbar Window
$Progresswindow = GUICreate("title", 400, 150)
$Progress1 = GUICtrlCreateProgress(30, 20, 300, 20)
$Label1 = GUICtrlCreateLabel ( "---------------", 30, 50, 15, 30)
$Label2 = GUICtrlCreateLabel ( " seconds left.", 45, 50, 400, 30)
$Cancel = GUICtrlCreateButton("&Cancel", 50, 100, 75, 30, 0)
GUICtrlSetState($Progress1, $GUI_HIDE)
GUICtrlSetState($Label1, $GUI_HIDE)
GUISetState(@SW_SHOW)

$Start_Time = TimerInit()
$Time_To_Wait = 60000 ; milliseconds
GUICtrlSetData($Progress1, 100)
Sleep(500)

GUICtrlSetState($Progress1, $GUI_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Cancel
Exit
EndSwitch
Sleep(10)

$Current_Time_Difference = TimerDiff($Start_Time)
If $Current_Time_Difference > $Time_To_Wait Then
Sleep(750)
Exit
Else
$Percentage = 100 - Round((100/$Time_To_Wait) * $Current_Time_Difference)
GuiCtrlSetData($Label1, String(60 - Round((60/$Time_To_Wait) * $Current_Time_Difference)))
GUICtrlSetData($Progress1, $Percentage)
GUICtrlSetState($Label1, $GUI_SHOW)

EndIf
If $Percentage = 0 Then
MsgBox(0, "testing", "")
EndIf

WEnd
#EndRegion Progressbar Window

When having the same as above be called by clicking the "demo" button, the progress GUI comes up correctly, but you cant close it. Help?

Opt('GUIOnEventMode',True)
;set the default Width, height, X & Y coords
Global $Width = ('510')
Global $Height = ('300')
Global $X = ('611')
Global $Y = ('389')

;sets version number
$version = "1.3"

#Region Main Window
$Main = GUICreate("main window", $width, $Height)
GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit', $Main)
$Start_Main = GUICtrlCreateButton("&Start",40, 230, 75, 30, 0)
GUICtrlSetOnEvent($Start_Main, "_Start")
$Pause_Main = GUICtrlCreateButton("&Pause", 160, 230, 75, 30, 0)
GUICtrlSetOnEvent($Pause_Main, "_Pause")
GUICtrlSetState($Pause_Main, $GUI_DISABLE)
$Close_Main = GUICtrlCreateButton("&Exit", 395, 230, 75, 30, 0)
GUICtrlSetOnEvent($Close_Main, "_Exit")
$Demo_Main = GUICtrlCreateButton("&Demo", 280, 230, 75, 30, 0)
GUICtrlSetOnEvent($Demo_Main, "_Demo")
$List_Main = GUICtrlCreateList("", 40, 40, 430, 160, BitOR($LBS_DISABLENOSCROLL, $LBS_NOSEL))
GUICtrlCreateLabel("Status Messages:", 40, 20 , 200, 20)
$File_Menu = GUICtrlCreateMenu("&File")
$Exit_Item = GUICtrlCreateMenuItem("Exit", $File_Menu)
GUICtrlSetOnEvent($Exit_Item, "_Exit")
$Help_Menu = GUICtrlCreateMenu("&Help")
$About_Item = GUICtrlCreateMenuItem("About", $Help_Menu)
GUICtrlSetOnEvent($About_Item, "_About")
GUISetState(@SW_SHOW)
#EndRegion END Main Window







;Window for descending progress bar
#Region Progressbar Window
$Progresswindow = GUICreate("title", 400, 150)
$Progress1 = GUICtrlCreateProgress(30, 20, 300, 20)
$Label1 = GUICtrlCreateLabel ( "---------------", 30, 50, 15, 30)
$Label2 = GUICtrlCreateLabel ( " seconds remaining", 45, 50, 400, 30)
$Cancel = GUICtrlCreateButton("&Cancel", 50, 100, 75, 30, 0)
GUICtrlSetOnEvent($Cancel, "_Exit")
GUICtrlSetState($Progress1, $GUI_HIDE)
GUICtrlSetState($Label1, $GUI_HIDE)


$Start_Time = TimerInit()
$Time_To_Wait = 60000 ; milliseconds
GUICtrlSetData($Progress1, 100)
Sleep(500)



While 1
$msg = GUIGetMsg()
If $msg = $Exit_Item Or $msg = -3 Or $msg = -1 Then
ExitLoop
EndIf
Sleep(20)
WEnd


Func _Demo()
GUISetState(@SW_SHOW)
GUICtrlSetState($Progress1, $GUI_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Cancel
Exit
EndSwitch
Sleep(10)

$Current_Time_Difference = TimerDiff($Start_Time)
If $Current_Time_Difference > $Time_To_Wait Then
Sleep(750)
Exit
Else
$Percentage = 100 - Round((100/$Time_To_Wait) * $Current_Time_Difference)
GuiCtrlSetData($Label1, String(60 - Round((60/$Time_To_Wait) * $Current_Time_Difference)))
GUICtrlSetData($Progress1, $Percentage)
GUICtrlSetState($Label1, $GUI_SHOW)

EndIf
If $Percentage = 0 Then
MsgBox(0, "testing", "")
EndIf

WEnd
#EndRegion Progressbar Window
EndFunc



Func _Exit()
Exit
EndFunc

Func _Close()
Exit
EndFunc



Func Terminate()
Exit 0
EndFunc

Share this post


Link to post
Share on other sites
careca

Hello, last time that happened to me, was because the code was 'stuck' in a function, meaning it didn't finish what it had to do, so the window didn't close, in a normal, close button clicking way.


Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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  

×