So, I'm playing around with things I can do. I wanted to make this app just do as it does for the most part, but make one function checking if I hit the close button. I wouldn't mind understanding a more simple way to do this, but the point of this is so that I can later on make a GUI app with multiple functions, that have pretty much one "controller" type that does a check of all the buttons, while the rest of the application can work. Maybe to be passed back to whatever function called it, I dont know if I can but, i'm attempting it.
                           
                       
                     
; tests
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
global  $msg, $x, $y
$msg = GUIGetMsg()
$x=500
$y=300
start()
func start()
GuiCreate("test", $x, $y)
GUISetState()
work()
endfunc
Func work()
local $chk1, $chk2, $a, $b, $c
Sleep(100)
while 1
  $c=(Random(25,475))
  $b=(Random(25,275))
  GUICtrlCreateLabel("test" &$a, $c, $b, 25, 25)
  sleep(100)
  monitor()
WEnd
EndFunc
func monitor() ;trying to make this function check if I hit the close button if so close, if not return back to the other function.
local $a, $b, $c
while 1
  Select
   Case $msg = $GUI_EVENT_CLOSE
   GuiDelete()
  EndSelect
  sleep(100)
  work()
wend
EndFunc