Sign in to follow this  
Followers 0
ffunky

Tray update problem

4 posts in this topic

Hey guys, I'm trying to create a simple "What are you doing now?" script that pops up every 15 minutes and then logs what you type in.

The twist is that I'm also trying to implement a function where when you click the tray icon, it forces the script to ask you again, thereby allowing you to add items in between the 15 minute intervals if you want to.

The problem is that when I run the program and it hits the tray, it will pop up the first time I tell it to, but then it gets stuck at a "Sleep" command and won't allow me to interact w/ the icon any longer.

Suggestions please?

Thanks in advance.

Code:

CODE
#include <Constants.au3>

#include <GUIConstants.au3>

Opt("TrayAutoPause",0)

Opt("TrayIconDebug", 1)

Opt("TrayOnEventMode",1)

Opt("TrayMenuMode",1)

$infoitem = TrayCreateItem("Update")

TrayItemSetOnEvent(-1,"ShowInfo")

TrayCreateItem("")

$exititem = TrayCreateItem("Exit")

TrayItemSetOnEvent(-1,"ExitScript")

TraySetState()

GoTime()

Func GoTime()

;-------------Open file for writing-------------

$file = FileOpen("c:\logtime.txt", 1)

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

Else

$bLoop = 1

While $bLoop = 1

$text = InputBox("Time Tracker", "What are YOU doing?")

If @error = 1 Then

Startup()

Else

FileWrite($file, @HOUR & ":" & @MIN & @CRLF)

FileWrite($file, $text)

FileWrite($file, @CRLF & @CRLF)

$bLoop = 0 ; Exit the loop

EndIf

WEnd

FileClose($file)

StartUp()

EndIf

;------------------------------------------------

EndFunc

Func StartUp()

;Sleep(900000) ; 15 minutes

Sleep(10000)

GoTime()

EndFunc

Func ShowInfo()

GoTime()

EndFunc

Func ExitScript()

Exit

EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I think this works as well as the one you were trying to make, I changed a lot of things which I think made it more efficient. Let me know if you have any questions about it.

#include <Constants.au3>
#include <GUIConstants.au3>
Opt("TrayAutoPause",0)
Opt("TrayIconDebug", 1)
Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1)

$infoitem = TrayCreateItem("Update")
TrayItemSetOnEvent(-1,"_Write")
TrayCreateItem("")

$exititem = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"ExitScript")
TraySetState()

$count = 1

While 1 
    Sleep(900000)
    _Write()
WEnd

Func _Write()
    $text = InputBox("Time Tracker", "What are YOU doing?")
    
    If $text = '' then Return
    
    IniWrite('C:\Whatever.ini', @MON & '/' & @MDAY & '/' & @YEAR, 'Time: ' & @HOUR & ":" & @MIN & ':' & @SEC, $text)
EndFunc

Func ExitScript()
Exit
EndFunc

EDIT: Welcome to the forums!

Edited by Piano_Man

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

Thanks for the help! It works great!

I didn't know there was a function for writing specifically to ini files.

Share this post


Link to post
Share on other sites

Thanks for the help! It works great!

I didn't know there was a function for writing specifically to ini files.

Your welcome... I like .ini files because their easier to write to then other files. And easier to read from for that matter too... You can look at the Helpfile > Index > "Ini" and you'll find a few other functions for doing other .ini stuff.

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

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