Sign in to follow this  
Followers 0
birkof

Application problem / Ideas

4 posts in this topic

Hello guys,

I'm new here, and I'm glad that i've discover AutoIt. It's very pretty ...

I'm trying to make an application which verify an rss file link for updated items

at a certain definite time. All ok, up to now, but if i want to add an systray item

and to get tray message in the same while one of them doesn't work.

It's a problem from the sleep function. Is there any way to do that, instead of using

sleep function?

I'll post my code below.

; starting script
#include <INet.au3>
#Include <Constants.au3>
#Include <Misc.au3>
#include <String.au3>
#NoTrayIcon

HotKeySet("{ESC}", "_Exit")

; remove default tray icon menu
Opt ("TrayMenuMode", 1)

; no pause when tray icon clicked
Opt ("TrayAutoPause", 0)

; prevent duplicate processes
If _Singleton (@ScriptName, 1) = 0 Then
    MsgBox(0, "Error", "Error: Another instance of this application is already running ...")
    Exit
EndIf

; create menu items for the tray
$TrayColour = TrayCreateItem("Colour")
$TrayLine = TrayCreateItem("")
$TrayAbout = TrayCreateItem("About")
$TrayExit = TrayCreateItem("Exit")

; sets a specified tray icon.
TraySetIcon("Shell32.dll",56)

; sets the tooltip text for the tray icon.
TraySetToolTip("Test application")

; show the tray icon
TraySetState()

; infinite loop for tray menu
While 1
; get tray message
    $msg = TrayGetMsg()
    Select 
        Case $msg < 1
            ContinueLoop
        Case $msg = $TrayExit
            ExitLoop
        Case $msg = $TrayAbout
            MsgBox(0,"About Us","About text")
    EndSelect
; check for updates 
    $check = _check4updates()
    If $check = -1 Then
        Sleep(5000)
        ContinueLoop
    EndIf
    Sleep(5000)
    ContinueLoop
;WEnd

_Exit()

; functions
Func _check4updates()
    $Feed = _INetGetSource('http://dev.htbaw.ro/news.xml')
    If @error Or StringLen($Feed) < 60 Then Return -1   
    MsgBox(0,"Updater","Checking for updates ...")
    Return 1
EndFunc

Func _Exit()
    Exit
EndFunc

Regards,

Daniel

Share this post


Link to post
Share on other sites



im afraid i dont understand your question.

you want to have 2 loops running at the same time? then this maybe?

Func _Addlibenable()
    AdlibEnable("_CheckTime", 60000) ; checks time every 1 minute (calls _CheckTime() function )
EndFunc

Func _CheckTime()

;Whatever hire

EndFunc

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

Just add AdlibEnable()

; starting script
#include <INet.au3>
#Include <Constants.au3>
#Include <Misc.au3>
#include <String.au3>
;#NoTrayIcon

HotKeySet("{ESC}", "_Exit")

; remove default tray icon menu
Opt ("TrayMenuMode", 1)

; no pause when tray icon clicked
Opt ("TrayAutoPause", 0)

; prevent duplicate processes
If _Singleton (@ScriptName, 1) = 0 Then
    MsgBox(0, "Error", "Error: Another instance of this application is already running ...")
    Exit
EndIf

; create menu items for the tray
$TrayColour = TrayCreateItem("Colour")
$TrayLine = TrayCreateItem("")
$TrayAbout = TrayCreateItem("About")
$TrayExit = TrayCreateItem("Exit")

; sets a specified tray icon.
TraySetIcon("Shell32.dll",56)

; sets the tooltip text for the tray icon.
TraySetToolTip("Test application")

; show the tray icon
TraySetState()

AdlibEnable("_check4updates", 5000)

; infinite loop for tray menu
While 1
; get tray message
    $msg = TrayGetMsg()
    Select 
        Case $msg = $TrayExit
            ExitLoop
        Case $msg = $TrayAbout
            MsgBox(0,"About Us","About text")
    EndSelect
WEnd

; functions
Func _check4updates()
    ToolTip("Please wait, getting source...")
    $Feed = _INetGetSource('http://dev.htbaw.ro/news.xml')
    ToolTip("")
    If @error Or StringLen($Feed) < 60 Then Return -1   
    MsgBox(0,"Updater","Checking for updates ...")
    Return 1
EndFunc

Func _Exit()
    Exit
EndFunc
:)

Share this post


Link to post
Share on other sites

That solved my problem, Yupiiii. Thanks a lot guys.

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