Sign in to follow this  
Followers 0
XxXFaNtA

Little Timer Question

7 posts in this topic

Hi Everyone :)

I started making a small "Away"-Script for a Chatprogram called XFire.

If someone writes a message to me while i'm dunno...at work...it responses an away-message + the time since i'm away.

The Script looks like this:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; ;

; Away Message Plus ;

; v0.3 ;

; ©by XxXFaNtA '06 ;

; ;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

#include <file.au3>

#include <Date.au3>

Opt("WinDetectHiddenText", 1)

Opt("WinTitleMatchMode", 4)

AdlibEnable("Timer", 50)

Global $Secs, $Mins, $Hour, $Time

$savedir = @DesktopDir &"\Messages.txt"

$timer = TimerInit()

$peter = "00:00:00"

$msg = InputBox("Away Messanger","Put in your Away Message")

;; Deleting the old History

$file = FileOpen($savedir,2)

FileWrite($file,"*** Away Message History ***"& @CRLF)

FileClose($file)

While 1

;; Getting name of the XFire Chatwindow

$handle = WinGetHandle("classname=ChatSkinWnd")

;; Getting the Text out of the Window (oberes Chatfenster)

$text = ControlGetText($handle, "", "RichEdit20W1")

;; unteres chatfenster

$chatfenster = ControlGetText($handle, "", "RichEdit20W2")

;; Searching for Substring ":"

$result = StringInStr($text, ":")

$file = FileOpen($savedir,1)

If $result <> 0 AND NOT $chatfenster = $msg Then

;; $file = FileOpen($savedir,1)

FileWrite($file,$text & @CRLF)

ControlSend($handle, "", "RichEdit20W2", $msg & "(since "& $Peter &"){enter}")

WinKill($handle, "")

;; FileClose($file)

EndIf

FileClose($file)

WEnd

Func Timer()

_TicksToTime(Int(TimerDiff($timer)), $Hour, $Mins, $Secs )

Local $sTime = $Time ; save current time to be able to test and avoid flicker..

$Time = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)

If $sTime <> $Time Then $peter = $Time

EndFunc ;==>Timer

#cs

TO-DO:

- Saving the Persons, so you can call them back (no problem)

- Menü (Exit, About, Some Texts,...)

- 2 Specials:

- Counting howlong someone is afk..Example:

Person1: Hi. Are you there?

Person2(You): Sry, but i'm afk since 3:16 Minutes

(WORKS)

- Counting backwards till the person is back..Example:

Person1: Hi. Are you there?

Person2(You): Sry, but i'm afk (i'll be back in 21:44 Minutes)

-When you Close the Program, a MsbBox should pop up and show

how many people have written a message (hard) OR

how many messages you got (counting the lines ans searching for : )

-

#ce

NOW the Problem is the Timer...

It should start when $msg has a value (so after he filled in the InputBox)...i think i tried as condition for the Function $msg <> "" but that didnt work :mellow:

Can someone help me? :)

(ah and another smal question..how can i download + read a xml-file and search for special info?)

Share this post


Link to post
Share on other sites



I don't have time at the moment to look through your script... but your second question... I made a script to help someone the other day do this here: http://www.autoitscript.com/forum/index.ph...ndpost&p=168994

Maybe you can get the idea... you may need to replace the code tags...


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

My primary Problem is only to start the Func Timer() when the user has put a Value into $msg (atm it starts at the beginning of the Script)

Share this post


Link to post
Share on other sites

Has really noone an idea how to make it, that

Func Timer()

_TicksToTime(Int(TimerDiff($timer)), $Hour, $Mins, $Secs )

Local $sTime = $Time ; save current time to be able to test and avoid flicker..

$Time = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)

If $sTime <> $Time Then $peter = $Time

EndFunc ;==>Timer

only starts after $msg has a value (for example "AFK")

??? :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Has really noone an idea how to make it, that

only starts after $msg has a value (for example "AFK")

??? :)

Try

#include <file.au3>
#include <Date.au3>

Opt("WinDetectHiddenText", 1)
Opt("WinTitleMatchMode", 4)

Global $Secs, $Mins, $Hour, $Time
$savedir = @DesktopDir &"\Messages.txt"
$timer = TimerInit()
$peter = "00:00:00"

$msg = InputBox("Away Messanger","Put in your Away Message")
If $msg = "" Then Exit

Timer()

;; Deleting the old History
$file = FileOpen($savedir,2)
FileWrite($file,"*** Away Message History ***"& @CRLF)
FileClose($file)

While 1
;; Getting name of the XFire Chatwindow
$handle = WinGetHandle("classname=ChatSkinWnd")
;; Getting the Text out of the Window (oberes Chatfenster)
$text = ControlGetText($handle, "", "RichEdit20W1")
;; unteres chatfenster
$chatfenster = ControlGetText($handle, "", "RichEdit20W2")
;; Searching for Substring ":"
$result = StringInStr($text, ":")
$file = FileOpen($savedir,1)

If $result <> 0 AND NOT $chatfenster = $msg Then
;; $file = FileOpen($savedir,1)
FileWrite($file,$text & @CRLF)

ControlSend($handle, "", "RichEdit20W2", $msg & "(since "& $Peter &"){enter}")
WinKill($handle, "")
;; FileClose($file)
EndIf
FileClose($file)
WEnd

Func Timer()
_TicksToTime(Int(TimerDiff($timer)), $Hour, $Mins, $Secs )
Local $sTime = $Time; save current time to be able to test and avoid flicker..
$Time = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
If $sTime <> $Time Then $peter = $Time
EndFunc;==>Timer

#cs
TO-DO:
- Saving the Persons, so you can call them back (no problem)
- Menü (Exit, About, Some Texts,...)
- 2 Specials:
- Counting howlong someone is afk..Example:
Person1: Hi. Are you there?
Person2(You): Sry, but i'm afk since 3:16 Minutes
(WORKS)
- Counting backwards till the person is back..Example:
Person1: Hi. Are you there?
Person2(You): Sry, but i'm afk (i'll be back in 21:44 Minutes)
-When you Close the Program, a MsbBox should pop up and show
how many people have written a message (hard) OR
how many messages you got (counting the lines ans searching for : )
-
#ce
Edited by exodius

Share this post


Link to post
Share on other sites

doesn't work :)

So to get straight what's going on... Your script pulls up an inputbox, and at the point that you put something in it and click "OK", you want it to start the timer, right?

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