Jump to content

Tray menu and system time check


Recommended Posts

Hi to all :)

I have a simple program in my tray area. So I have a code like this:

While (1)
  $msg = traygetmsg()
  select
    case $msg = $menuOpen
      'open config window
  end select

This program should warn the user if a specific time occurs (like an 'alarm' program do).

So i want to check if a specific system time occurs. This code doesn't work, because the function traygetmsg() STOP the code until the mouse moves over the tray icon...

While (1)
  $msg = traygetmsg()
  ''''''''
  if @HOUR = $myHour And @MIN = $myMin then
    msgbox(0, "Alert", "Alert text")
  end if
  ''''''''
  select
    case $msg = $menuOpen
      'open config window
  end select

How can I WAKE-UP my program? THX

Link to comment
Share on other sites

hi :)

TrayGetMsg() does not stop your script to wait for an event.

According to the help-file, it simply polls the tray to see if any events have occurred. ;)

However, if for some reason you don't want to use TrayGetMsg() check out TrayOnEventMode.

If your script is stopping for some reason you can't figure out, post a working snippet of code that illustrates your problem or post your full code if you cant isolate the problematic code in a working scriptlet.

Hope this clears some things up ;)

-smartee

Link to comment
Share on other sites

No need to mouse moves over the tray icon, try like this...

#include <GUIConstants.au3>

Opt ( "TrayMenuMode", 1 )
Global $myHour = @HOUR, $myMin =  @MIN + 1

$settingsitem = TrayCreateItem ( "Settings" )
TrayCreateItem  ( "" )
$exititem = TrayCreateItem ( "Exit" )
TraySetState ( )
$_Gui = GUICreate ( "settings" )
GUISetState ( @SW_HIDE )

While 1
    $_Tmsg = TrayGetMsg ( )
    Switch $_Tmsg
        Case $settingsitem
            GUISetState ( @SW_SHOW, $_Gui )
        Case $exititem
            Exit
    EndSwitch
    $_Gmsg = GuiGetMsg ( )
    Switch $_Gmsg
        Case $GUI_EVENT_CLOSE
            GUISetState ( @SW_HIDE, $_Gui )
    EndSwitch
    If @HOUR = $myHour And @MIN = $myMin And @SEC < 1 Then MsgBox ( 262144, "Alert", "Alert text", 5 )
    Sleep ( 10 )
WEnd

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...