Sign in to follow this  
Followers 0
Pierre40a

A little confused about timing ...

5 posts in this topic

Hello,

While my prog is running, I'd like, let's say every 10 seconds, a message box to be displayed. The thing is, it works but I can't get access to control events. For instance :

; #include <GUIConstants.au3>
#include <Date.au3>
;Create GUI
GUICreate("Timer",120, 50)
GUICtrlCreateLabel("00:00:00", 10,10)
GUISetState()


While 1

  $msg = GUIGetMsg()
    
  Select
     Case $msg = $GUI_EVENT_CLOSE
     Exit
  EndSelect
sleep(10000)
msgbox(4096,"","test")
Wend
;

Will display my msgbox every ten seconds but I can't close the prog ...

What am I doing wrong ?

Thanks for any answer.

Pierre

Share this post


Link to post
Share on other sites



#include <GUIConstants.au3>
#include <Date.au3>
;Create GUI
GUICreate("Timer",120, 50)
GUICtrlCreateLabel("00:00:00", 10,10)
GUISetState()

$begin = TimerInit()
While 1

  $msg = GUIGetMsg()
    
  Select
     Case $msg = $GUI_EVENT_CLOSE
     Exit
    Case Else
    If TimerDiff($begin) >= 10000 Then
        msgbox(4096,"","test")
        $begin = TimerInit()
    EndIf
    EndSelect
Wend


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Hello,

While my prog is running, I'd like, let's say every 10 seconds, a message box to be displayed. The thing is, it works but I can't get access to control events. For instance :

; #include <GUIConstants.au3>
#include <Date.au3>
;Create GUI
GUICreate("Timer",120, 50)
GUICtrlCreateLabel("00:00:00", 10,10)
GUISetState()
While 1

  $msg = GUIGetMsg()
    
  Select
     Case $msg = $GUI_EVENT_CLOSE
     Exit
  EndSelect
sleep(10000)
msgbox(4096,"","test")
Wend
;

Will display my msgbox every ten seconds but I can't close the prog ...

What am I doing wrong ?

Thanks for any answer.

Pierre

You arent doing anything wrong. Your program is doing exactly as you tell it to.

Now if you want the program to display the msgbox every 10 seconds and close when needed (other than when a msgbox is open) then you need to check out Opt("GUIOnEventMode", 1).

Goes something like this.

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;Filename: OnEventModeTemp.au3 (Compiled as OnEventModeTemp.exe)
;Used With: no other files
;Created by: Jarvis J Stubblefield (support "at" vortexrevolutions "dot" com)
;Created on: 05/22/2006
;Modified on: 
;Modified by: 
;Used for: OnEventMode Template for GUI Creation
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** Preprocessor ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1) ;Set GUI to ONEvent Mode.

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** File Installations ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** Registry Information ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** Declare Variables ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Global $wHeight, $wWidth                                                             ;Window Size
Global $m_HWnd, $m_Options, $m_Help, $m_Exit            ;Window Controls

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** Define Variables ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

$wHeight = 300
$wWidth  = 300

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** GUI Creation ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

$m_HWnd     = GUICreate("Rename-Index N Find", $wWidth, $wHeight)
$m_Options  = GUICtrlCreateButton("Options", 5, ($wHeight - 25), 94, 20)
$m_Help     = GUICtrlCreateButton("Help", 103, ($wHeight - 25), 94, 20)
$m_Exit     = GUICtrlCreateButton("Exit", 201, ($wHeight - 25), 94, 20)

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** GUI Set Events ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

GUICtrlSetOnEvent($m_Options, "_CtrlEventHandler")
GUICtrlSetOnEvent($m_Exit, "_CtrlEventHandler")
GUICtrlSetOnEvent($m_Help, "_CtrlEventHandler")

;System Events Handled by One _SysEventHandler()
GUISetOnEvent($GUI_EVENT_CLOSE, "_SysEventHandler", $m_HWnd)
GUISetOnEvent($GUI_EVENT_MINIMIZE, "_SysEventHandler", $m_HWnd)
GUISetOnEvent($GUI_EVENT_RESTORE, "_SysEventHandler", $m_HWnd)
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "_SysEventHandler", $m_HWnd)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_SysEventHandler", $m_HWnd)
GUISetOnEvent($GUI_EVENT_PRIMARYUP, "_SysEventHandler", $m_HWnd)
GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_SysEventHandler", $m_HWnd)
GUISetOnEvent($GUI_EVENT_SECONDARYUP, "_SysEventHandler", $m_HWnd)
GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "_SysEventHandler", $m_HWnd)
GUISetOnEvent($GUI_EVENT_RESIZED, "_SysEventHandler", $m_HWnd)
GUISetOnEvent($GUI_EVENT_DROPPED, "_SysEventHandler", $m_HWnd)

GUISetState(@SW_SHOW, $m_HWnd)

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** Main Program Loop ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

While 1
    Sleep(10000)
        MsgBox(0, "10 Second Warning", "IT HAS BEEN 10 SECONDS!!", 2)
WEnd

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** GUI Event Functions ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Func _CtrlEventHandler()
    Switch @GUI_CtrlId
        Case $m_Exit
            _TerminateApp()
        Case $m_Options
        Case $m_Help
    EndSwitch
EndFunc

Func _SysEventHandler()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            _TerminateApp()
        Case $GUI_EVENT_MINIMIZE
        Case $GUI_EVENT_RESTORE
        Case $GUI_EVENT_MAXIMIZE
        Case $GUI_EVENT_PRIMARYDOWN
        Case $GUI_EVENT_PRIMARYUP
        Case $GUI_EVENT_SECONDARYDOWN
        Case $GUI_EVENT_SECONDARYUP
        Case $GUI_EVENT_MOUSEMOVE
        Case $GUI_EVENT_RESIZED
        Case $GUI_EVENT_DROPPED
    EndSwitch
EndFunc

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** Define Functions ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Func _TerminateApp()
    GUIDelete($m_HWnd)
    
    Exit
EndFunc

I hope the above helps you solve your problem.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
#include <Date.au3>
;Create GUI
GUICreate("Timer",120, 50)
GUICtrlCreateLabel("00:00:00", 10,10)
GUISetState()

$begin = TimerInit()
While 1

  $msg = GUIGetMsg()
    
  Select
     Case $msg = $GUI_EVENT_CLOSE
     Exit
    Case Else
    If TimerDiff($begin) >= 10000 Then
        msgbox(4096,"","test")
        $begin = TimerInit()
    EndIf
    EndSelect
Wend
Beat me to it, and nice method btw. I just got into the whole OnEvent mode so that was my first thought :).

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

Beat me to it, and nice method btw. I just got into the whole OnEvent mode so that was my first thought :).

JS

REALLY COOL !!! :(:D:oops:

Thanks so much !

Regards

Pierre

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