Sign in to follow this  
Followers 0
Annonyreeder

Why won't this GUI (timer) close?

7 posts in this topic

Hey, im pretty new to Autoit but am getting on pretty well, but i cant seem to understand why this Timer GUI window won't shut, when i click the ESC it just freezes both the timer and the first GUI?

Timer code:

func timer()
$Form1 = GUICreate("AForm1", 122, 42, 438, 156)
GUISetOnEvent($GUI_EVENT_CLOSE, "timer_close")
$Label1 = GUICtrlCreateLabel("15:00", 8, 8, 43, 17)
GUISetState()
#EndRegion ### END Koda GUI section ###
$time=TimerInit()
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
   
    $new = TimerDiff ($time)
    $new = (15*60*1000)-$new
    $seconds = Round ($new/1000)
    $newMin = Floor ($seconds/60)
    $newSec = Mod ($seconds, 60)
    If $newSec < 10 Then $newSec = "0"&$newSec
    GUICtrlSetData ($Label1, $newMin&":"&$newSec)
WEnd
endfunc
Func timer_close()
   GUIDelete($Form1)
   endfunc

Incase you need it here is the full script

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
HotKeySet("{ESC}","Quit")
 
  Opt("GUIOnEventMode", 1)
 
 Global $hGUI3, $hGUI2, $hButton2, $Software, $Hardware, $Network, $Reference_Number, $Printer, $Printers, $Referral, $Tarrif, $hButton3 ; Predeclare these variables
 MsgBox("", "Panda", "Made by Ant")
 gui1()
 
 Func gui1()
     $hGUI1 = GUICreate("Panda", 210, 120,-1,-1,-1,$WS_EX_TOPMOST)
     GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close_Main") ; Run this function when the main GUI [X] is clicked
  GUISetBkColor (0x006666, $hGUI1 )
     $Software = GUICtrlCreateButton("Software", 5, 6, 90, 20)
     GUICtrlSetOnEvent(-1, "Software")
  GUICtrlSetBkColor($Software, 0x99FF00)
  $Hardware = GUICtrlCreateButton("Hardware", 5, 24, 90, 20)
     GUICtrlSetOnEvent(-1, "Hardware")
  GUICtrlSetBkColor($Hardware, 0x99FF00)
  $Network = GUICtrlCreateButton("Network", 5, 42, 90, 20)
     GUICtrlSetOnEvent(-1, "Network")
  GUICtrlSetBkColor($Network, 0x99FF00)
  $Reference_Number = GUICtrlCreateButton("Reference Number", 100, 6, 110, 20)
     GUICtrlSetOnEvent(-1, "Reference_Number")
  GUICtrlSetBkColor($Reference_Number, 0x99FF00)
  $Printer = GUICtrlCreateButton("Printer Call", 100, 42, 110, 20)
     GUICtrlSetOnEvent(-1, "Printer")
  GUICtrlSetBkColor($Printer, 0x99FF00)
  $Printers = GUICtrlCreateButton("Printers list", 100, 90, 100, 30)
     GUICtrlSetOnEvent(-1, "Printers")
  GUICtrlSetBkColor($Printers, 0x990099)
  $Referral = GUICtrlCreateButton("Referral call", 100, 24, 110, 20)
     GUICtrlSetOnEvent(-1, "Referral")
  GUICtrlSetBkColor($Referral, 0x99FF00)
  $Tarrif  = GUICtrlCreateButton("Missing Tariffs", 5, 60, 90, 20)
     GUICtrlSetOnEvent(-1, "Tarrif")
  GUICtrlSetBkColor($Tarrif, 0x99FF00)
 
  $Timer  = GUICtrlCreateButton("BreakTime!", 5, 77, 60, 15)
     GUICtrlSetOnEvent(-1, "Timer")
  GUICtrlSetBkColor($Tarrif, 0x99FF00)
 
 
     $hButton2 = GUICtrlCreateButton("Password resets", 1, 90, 100, 30)
     GUICtrlSetOnEvent(-1, "On_Button2")
     GUISetState()
  GUICtrlSetBkColor($hButton2, 0x990099)
  $hButton3 = GUICtrlCreateButton("Links", 100, 60, 110, 20)
     GUICtrlSetOnEvent(-1, "On_Button3")
     GUISetState()
  GUICtrlSetBkColor($hButton3, 0x6666FF)
 
     While 1
         Sleep(10)
     WEnd
 EndFunc   ;==>gui1
 
 Func gui2()
     $hGUI2 = GUICreate("Panda", 200, 200,-1,-1,-1,$WS_EX_TOPMOST)
     GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close_Secondary")
  GUISetBkColor (0x006666, $hGUI2 )
 
   $EID = GUICtrlCreateButton("EID", 70, 10, 60, 30)
     GUICtrlSetOnEvent(-1, "EID")
  GUICtrlSetBkColor($EID, 0x99FF00)
  $Compass = GUICtrlCreateButton("Compass", 10, 10, 60, 30)
     GUICtrlSetOnEvent(-1, "Compass")
  GUICtrlSetBkColor($Compass, 0x99FF00)
  $SapStock = GUICtrlCreateButton("SapStock", 10, 40, 60, 30)
     GUICtrlSetOnEvent(-1, "SapStock")
  GUICtrlSetBkColor($SapStock, 0x99FF00)
  $Reporting = GUICtrlCreateButton("Reporting", 70, 40, 60, 30)
     GUICtrlSetOnEvent(-1, "Reporting")
  GUICtrlSetBkColor($Reporting, 0x99FF00)
  $Citrix = GUICtrlCreateButton("Citrix", 130, 10, 60, 30)
     GUICtrlSetOnEvent(-1, "Citrix")
  GUICtrlSetBkColor($Citrix, 0x99FF00)
  $Draft = GUICtrlCreateButton("Draft 2 currant", 70, 130, 80, 30)
     GUICtrlSetOnEvent(-1, "Draft")
  GUICtrlSetBkColor($Draft, 0xFF6600)
  $Domino = GUICtrlCreateButton("Domino", 10, 70, 60, 30)
     GUICtrlSetOnEvent(-1, "Domino")
  GUICtrlSetBkColor($Domino, 0x00FFFF)
  $workspace = GUICtrlCreateButton("workspace", 10, 130, 60, 30)
     GUICtrlSetOnEvent(-1, "workspace")
  GUICtrlSetBkColor($workspace, 0x00FFFF)
  $repairpass = GUICtrlCreateButton("Repair portal", 70, 70, 70, 30) ;FUNC
     GUICtrlSetOnEvent(-1, "repairpass")
  GUICtrlSetBkColor($repairpass, 0xFF6600)
  $Retail = GUICtrlCreateButton("Retail portal", 10, 100, 60, 30)
     GUICtrlSetOnEvent(-1, "Retail")
  GUICtrlSetBkColor($Retail, 0x00FFFF)
  $learning = GUICtrlCreateButton("learning Zone", 70, 100, 80, 30)
     GUICtrlSetOnEvent(-1, "Retail")
  GUICtrlSetBkColor($learning, 0xFF6600)
  $css = GUICtrlCreateButton("CSS", 130, 40, 60, 30)
     GUICtrlSetOnEvent(-1, "css")
  GUICtrlSetBkColor($css, 0xCC0000)
  $JTI = GUICtrlCreateButton("JTI", 140, 70, 40, 30)
     GUICtrlSetOnEvent(-1, "JTI")
  GUICtrlSetBkColor($JTI, 0xCC0000)
  $beanstore = GUICtrlCreateButton("Beanstore", 70, 160, 60, 30)
     GUICtrlSetOnEvent(-1, "beanstore")
  GUICtrlSetBkColor($beanstore, 0xFF6600)
  $office = GUICtrlCreateButton("OFFICE", 10, 160, 60, 30)
     GUICtrlSetOnEvent(-1, "office")
  GUICtrlSetBkColor($office, 0x00FFFF)
  
 
     GUISetState()
  EndFunc   ;==>gui2
 
 Func On_Close_Main()
     Exit
 EndFunc
 Func Referral()
 GUICtrlSetState($Referral, $GUI_DISABLE)
 sleep(2500)
Send("Store Referral: {Enter} Issue: User has an issue we do not support {Enter} Details: User has been referred to another desk")
sleep(4000)
GUICtrlSetState($Referral, $GUI_ENABLE)
endfunc
 Func On_Close_Secondary()
     GUIDelete($hGUI2)
     GUICtrlSetState($hButton2, $GUI_ENABLE)
  EndFunc
 
  Func On_Close_Third()
 GUIDelete($hGUI3)
  GUICtrlSetState($hButton3, $GUI_ENABLE)
  endfunc
 
 
 Func Software() ;Finished Software
  GUICtrlSetState($Software, $GUI_DISABLE)
  sleep(2500)       
    Send("Software {Enter} Issue: {ENTER} Diagnostics: {ENTER} Application Affected: {ENTER} Error Message: {ENTER} Number of Users Affected: {ENTER} Employee Number: {ENTER} User ID (Logins): {ENTER} {ENTER} Opening times: {ENTER} Monday - Saturday: {ENTER} Sunday:")
   sleep(4000)
   GUICtrlSetState($Software, $GUI_ENABLE)
   EndFunc
  
 Func Tarrif()
 GUICtrlSetState($Tarrif, $GUI_DISABLE)
 sleep(2500)
 Send("Tariff/Handset missing {Enter} Diagnostics: {Enter} {Enter} Application Affected: {Enter} Handset(spec): {Enter} IMEI: {Enter} EAN: {Enter} {Enter} CTN: {Enter} Missing Tariff: {Enter} Colour:")
 sleep(4000)
 GUICtrlSetState($Tarrif, $GUI_ENABLE)
 EndFunc
 
 Func On_Button2() ;Second GUI
     GUICtrlSetState($hButton2, $GUI_DISABLE)
     gui2()
  EndFunc
 
  Func On_Button3()
  GUICtrlSetState($hButton3, $GUI_DISABLE)
     gui3()
  endfunc
 
  Func Hardware() ;Finished Hardware
  GUICtrlSetState($HARDWARE, $GUI_DISABLE)
  sleep(2500)
   Send("Hardware: {Enter} Diagnostics: {Enter} Hardware: {Enter} Make: {Enter} Model: {Enter} Serial/Asset Number: {Enter} Engineer Recommendation: {Enter} Tills in Store{Enter} Store ID: {Enter} Address: {Enter} Post Code: {Enter} Contact Name: {Enter} Contact Number:{Enter}{Enter} Opening times:{Enter} Monday - Saturday:{Enter} Sunday:")
   sleep(7000)
   GUICtrlSetState($HARDWARE, $GUI_ENABLE)
   endfunc
 Func Network()
 GUICtrlSetState($Network, $GUI_DISABLE)
 sleep(2500)
   Send("Network: {Enter} Diagnostics: {Enter} {Enter} Store: {Enter} IP Address:  {Enter} Pinged Response Status: {Enter} Phone Number: {Enter} Contact Name: {Enter} {Enter} BT REF (ORANGE STORE): {Enter} {Enter} Opening times: {Enter} Monday - Saturday: {Enter} Sunday:")
  sleep(4000)
  GUICtrlSetState($Network, $GUI_ENABLE)
  endfunc
  Func Reference_Number()
  GUICtrlSetState($Reference_Number, $GUI_DISABLE)
  sleep(2500)
    Send("Issue: Store are chasing a previous call. {Enter} Details: User has a ref number {Enter} Ref number: XXXXXXXX")
sleep(5000) 
GUICtrlSetState($Reference_Number, $GUI_ENABLE)
EndFunc
Func Printer()
GUICtrlSetState($Printer, $GUI_DISABLE)
sleep(2500)
   Send("Printer requests {Enter} {Enter} Store: {Enter} CN: {Enter} Tfs Ref: {Enter} Model: {Enter} SN: {Enter} Request: {Enter} IP: {Enter} Request sent to Service Controllers")
   sleep(7000)
   GUICtrlSetState($Printer, $GUI_ENABLE)
   endfunc
  
Func Printers() ;PrinterList
   GUICtrlSetState($Printers, $GUI_DISABLE)
  ShellExecute ("[url="http://sites.cafevik.fs.fujitsu.com/sites/01305/EE%20SD%20Document%20Library/Knowledge%20Documents/1st%20Line/Printers/Printer%20I.P%20List.xls"]http://sites.cafevik.fs.fujitsu.com/sites/01305/EE%20SD%20Document%20Library/Knowledge%20Documents/1st%20Line/Printers/Printer%20I.P%20List.xls[/url]")
sleep(4000)
GUICtrlSetState($Printers, $GUI_ENABLE)
endfunc
Func EID()
GUIDelete($hGUI2)
GUICtrlSetState($hButton2, $GUI_ENABLE)
sleep(2500)
send("EID password reset Tmb2 {Enter} Employee number: {Enter} User ID*: {Enter} Password reset and tested ok")
sleep(5000)
endfunc
Func Compass()
GUIDelete($hGUI2)
GUICtrlSetState($hButton2, $GUI_ENABLE)
sleep(2500)
Send("Compass password reset {Enter} User name    : {Enter} Employee       : {Enter} Password reset and tested ok")
sleep(5000)
endfunc
func SapStock()
GUIDelete($hGUI2)
GUICtrlSetState($hButton2, $GUI_ENABLE)
sleep(2500)
send("Sap Stock Password reset {Enter} User name: {Enter} Employee: {Enter} Password reset and tested ok")
sleep(5000)
endfunc
func Reporting()
GUIDelete($hGUI2)
GUICtrlSetState($hButton2, $GUI_ENABLE)
sleep(2500)
send("Sap/Crs reporting Password reset {Enter} User name: {Enter} Employee: {Enter} Password reset and tested ok")
sleep(5000)
endfunc
func Citrix()
GUIDelete($hGUI2)
GUICtrlSetState($hButton2, $GUI_ENABLE)
sleep(2500)
Send("Citrix password reset FOH/BOH {Enter} Name: {Enter} Employee: {Enter} User Name: {Enter} Password reset and tested ok")
sleep(5000)
endfunc
func Draft()
GUIDelete($hGUI2)
GUICtrlSetState($hButton2, $GUI_ENABLE)
sleep(2500)
Send("Draft to current {Enter} handset ID: {Enter} handset ID: {Enter} All handsets now in current")
sleep(5000)
endfunc
func Domino()
GUIDelete($hGUI2)
GUICtrlSetState($hButton2, $GUI_ENABLE)
sleep(2500)
Send("Domino password reset {Enter} User name     : {Enter} Employee       : {Enter} Password reset and tested ok")
sleep(5000)
endfunc
func workspace()
GUIDelete($hGUI2)
GUICtrlSetState($hButton2, $GUI_ENABLE)
sleep(2500)
Send("Workspace password reset {Enter} Users Name: {Enter} Employee: {Enter} Password reset and tested ok")
sleep(5000)
endfunc
func repairpass()
GUIDelete($hGUI2)
GUICtrlSetState($hButton2, $GUI_ENABLE)
sleep(2500)
Send("Repair portal password request {Enter} Users Name: {Enter} Password reset and tested ok")
sleep(5000)
endfunc
func Retail()
GUIDelete($hGUI2)
GUICtrlSetState($hButton2, $GUI_ENABLE)
sleep(2500)
Send("Retail Portal password request {Enter} Users Name: {Enter} Employee: {Enter} Password reset and tested ok")
sleep(5000)
endfunc
func learning()
GUIDelete($hGUI2)
GUICtrlSetState($hButton2, $GUI_ENABLE)
sleep(2500)
Send("E-Learning password reset {Enter} Users name: {Enter} Employee number: {Enter} Password reset and tested ok {Enter} Missing deliver note/Receiver on sap stock {Enter} Delivered on: {Enter} Deliver number: {Enter} Tot ID:")
sleep(5000)
endfunc
func css()
GUIDelete($hGUI2)
GUICtrlSetState($hButton2, $GUI_ENABLE)
sleep(2500)
Send("Css password reset request {Enter} Employee number: {Enter} User ID: {Enter} Password reset and tested ok")
sleep(5000)
endfunc
func JTI()
GUIDelete($hGUI2)
GUICtrlSetState($hButton2, $GUI_ENABLE)
sleep(2500)
Send("JTI password reset request {Enter} Employee number: {Enter} User ID: {Enter} Password reset and tested ok")
sleep(5000)
endfunc
func beanstore()
GUIDelete($hGUI2)
GUICtrlSetState($hButton2, $GUI_ENABLE)
sleep(2500)
Send("BeanStore Pin check {Enter} User Name: {Enter} Employee: {Enter} Account checked and working ok")
sleep(5000)
endfunc

func office()
GUIDelete($hGUI2)
GUICtrlSetState($hButton2, $GUI_ENABLE)
sleep(2500)
Send("‘’The office’’ Via Rap {Enter} Name: {Enter} Employee: {Enter} User Name: {Enter} Password reset and tested ok")
sleep(5000)
endfunc

;LINKS
;
;
;
;
 Func gui3()
  $hGUI3 = GUICreate("Panda", 210, 100,-1,-1,-1,$WS_EX_TOPMOST)
     GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close_Third") ; Run this function when the main GUI [X] is clicked
   GUISetBkColor (0x006666, $hGUI3 )
   GUISetState()
  
   $EID2 = GUICtrlCreateButton("EID", 90, 39, 90, 20)
     GUICtrlSetOnEvent(-1, "EID2")
  GUICtrlSetBkColor($EID2, 0x99FF00)
  
   $Aston = GUICtrlCreateButton("Aston", 90, 1, 90, 20)
   GUICtrlSetOnEvent(-1, "Aston")
  GUICtrlSetBkColor($Aston, 0x99FF00)
 
  $Sword = GUICtrlCreateButton("Sword", 90, 20, 90, 20)
   GUICtrlSetOnEvent(-1, "Sword")
  GUICtrlSetBkColor($Sword, 0x99FF00)
 
  $Learning = GUICtrlCreateButton("Learning zone", 1, 58, 90, 20)
   GUICtrlSetOnEvent(-1, "Learn")
  GUICtrlSetBkColor($Learning, 0x99FF00)
 
  $TFS = GUICtrlCreateButton("TFS", 1, 39, 90, 20)
   GUICtrlSetOnEvent(-1, "TFS")
  GUICtrlSetBkColor($TFS, 0x99FF00)
  
   $SBE = GUICtrlCreateButton("SBE", 1, 20, 90, 20)
   GUICtrlSetOnEvent(-1, "SBE")
  GUICtrlSetBkColor($SBE, 0x99FF00)
 
  $Passwords = GUICtrlCreateButton("Passwords", 1, 1, 90, 20)
   GUICtrlSetOnEvent(-1, "Password")
  GUICtrlSetBkColor($Passwords, 0x99FF00)
 
   endfunc
  
   Func EID2()
   GUIDelete($hGUI3)
  GUICtrlSetState($hButton3, $GUI_ENABLE)
   ShellExecute ("[url="https://apply.eidverifier.net/uru/connect/login/login.faces"]https://apply.eidverifier.net/uru/connect/login/login.faces[/url]")
    sleep(4000)
 endfunc
 
 Func Aston()
    GUIDelete($hGUI3)
  GUICtrlSetState($hButton3, $GUI_ENABLE)
    ShellExecute ("[url="https://aston.orange.co.uk/my.logon.php3"]https://aston.orange.co.uk/my.logon.php3[/url]")
    sleep(4000)
 endfunc
 
 Func Sword()
    GUIDelete($hGUI3)
  GUICtrlSetState($hButton3, $GUI_ENABLE)
    ShellExecute ("[url="http://live.sword.fs.fujitsu.com/sword/getcalls.my_call"]http://live.sword.fs.fujitsu.com/sword/getcalls.my_call[/url]")
    sleep(4000)
 endfunc
 
 Func Learn()
    GUIDelete($hGUI3)
  GUICtrlSetState($hButton3, $GUI_ENABLE)
    ShellExecute ("[url="http://training.everythingeverywhere.com/admin/login/helpdesk.asp"]http://training.everythingeverywhere.com/admin/login/helpdesk.asp[/url]")
    sleep(4000)
 endfunc
 
 Func TFS()
    GUIDelete($hGUI3)
  GUICtrlSetState($hButton3, $GUI_ENABLE)
    ShellExecute ("[url="http://172.30.238.40/CAisd/pdmweb.exe"]http://172.30.238.40/CAisd/pdmweb.exe[/url]")
    sleep(4000)
 endfunc
 
 Func SBE()
    GUIDelete($hGUI3)
  GUICtrlSetState($hButton3, $GUI_ENABLE)
    ShellExecute ("[url="http://support.sbeglobalservice.com/index.php?/ee"]http://support.sbeglobalservice.com/index.php?/ee[/url]")
    sleep(4000)
 endfunc
 
 Func Password()
    GUIDelete($hGUI3)
  GUICtrlSetState($hButton3, $GUI_ENABLE)
    Shellexecute ("C:\Users\reedera\Desktop\Start of day\Passwords.txt")
    sleep(4000)
 endfunc
      
 func timer()
$Form1 = GUICreate("AForm1", 122, 42, 438, 156)
GUISetOnEvent($GUI_EVENT_CLOSE, "timer_close")
$Label1 = GUICtrlCreateLabel("15:00", 8, 8, 43, 17)
GUISetState()
#EndRegion ### END Koda GUI section ###
$time=TimerInit()
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
   
    $new = TimerDiff ($time)
    $new = (15*60*1000)-$new
    $seconds = Round ($new/1000)
    $newMin = Floor ($seconds/60)
    $newSec = Mod ($seconds, 60)
    If $newSec < 10 Then $newSec = "0"&$newSec
    GUICtrlSetData ($Label1, $newMin&":"&$newSec)
WEnd
endfunc
Func timer_close()
   GUIDelete($Form1)
   endfunc

Thanks for any help :)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

When you click on the close button for the timer window, it only deletes the GUI because you can't use BOTH OnEventMode and GUIGetMsg.

Edit: Also, there is too much sleeps so the GUIGetMsg may not be called when you click on the close button or whatever.

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Thanks for fast reply, however i took away the on event and put it in Case Event closed however its the same issue

$time=TimerInit()
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete($Form1)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Please use [autoit][/autoit] tags to post your code :)

Like I said, too much blocking functions, it freezes the GUI.

Edit: I'm too lazy right now to look at your code/run it. I will (maybe)/let someone do it later.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

ugh ive tried so many thing but none of them work :/. what do you mean i have too many blocking functions, none of the sleeps are running while the timer is the funcs in the script don't run at the same time as the timer. :/

Share this post


Link to post
Share on other sites

I gave up on the old timer as i found a snippet from another script that is allot nicer, ive managed to implement it into my script however im unsure how i would add a X/close function to the GUI, I did some experimenting but ended up messing my whole pc up (100 guis were popping up n caused my PC to freeze lol).

I’ve tried adding CloseGUi(timer) at the end of _check but it doesn’t close Ive also tried added case on event close, although the X doesnt appear to close any help appreciate as always :) thanks.

Also at the end of _check it says, "

If $_MinCalc <= 0 And $_SecCalc <= 0 Then
        GUISetBkColor ( 0xFF0000, $_GuiCountDown )
        GUICtrlSetData ( $TimeLabel, "Bye !" )
        Sleep ( 1000 )
         exit

When i replace exit with GUIDelete($_GuiCountDown) although it does close the window when the timer hits 0, it also seems to be stuck in a loop still and i cannot access the original GUI, thanks again for help guys :)

Timer function

func Timer()
 Global $SS_CENTER, $_CompteArebour = 900000, $_Minutes, $_Seconds, $TimeTicks, $TimeLabel, $_GuiCountDown, $hGUI1
$_GuiCountDown = GUICreate ( "CountDown...", 50, 100, @DesktopWidth/2 -250, @DesktopHeight/2 -100, $WS_EX_TOPMOST  )
GUISetBkColor ( 0xFFFF00 )
$TimeLabel = GUICtrlCreateLabel ( "", 5, -5, 450, 180, $SS_CENTER )
GUICtrlSetFont ( -1, 30, 800 )
GUISetState ( )
WinSetOnTop ( $_GuiCountDown, "", 1 )
$TimeTicks = TimerInit ( )
While 1
    _Check ( )
    Sleep ( 200 )
WEnd
 endfunc

_Check func

Func _Check ( )
    Disable()
    $_CompteArebour -= TimerDiff ( $TimeTicks )
    $TimeTicks = TimerInit ( )
    Local $_MinCalc = Int ( $_CompteArebour / ( 60 * 1000 ) ), $_SecCalc = $_CompteArebour - ( $_MinCalc * 60 * 1000 )
    $_SecCalc = Int ( $_SecCalc / 1000 )
    If $_MinCalc <= 0 And $_SecCalc <= 0 Then
        GUISetBkColor ( 0xFF0000, $_GuiCountDown )
        GUICtrlSetData ( $TimeLabel, "Bye !" )
        Sleep ( 1000 )
         exit

Share this post


Link to post
Share on other sites

Annonyreeder,

Why are you using the

sleep...
send...
sleep...

sequences in your functions? The sleeps will cause your script to behave poorly (as pointed out earlier).

Also:

1 - The code that you posted does not run (full script)

2 - $form1 in the Timer() function is not declared. (and using "timer" as a function name is inadvisable)

3 - If this "timer()" function is meant to terminate your app then you are way overcomplicating this.

4 - Your code seems disorganized. Describe what you are trying to do and you may get other/better alternatives (just a thought).

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

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  
Followers 0