Jump to content

Little Timer Question


Recommended Posts

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?)

Link to comment
Share on other sites

  • Moderators

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...

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.

Link to comment
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")

??? :)

Link to comment
Share on other sites

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
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...