Created
November 6, 2012 02:58
-
-
Save fengxx/4022279 to your computer and use it in GitHub Desktop.
Office communicator/Lync auto reply
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <IE.au3> | |
#include <File.au3> | |
Dim $IMClassName="[CLASS:IMWindowClass]" | |
Dim $myLog="c:\temp\ocrobot.log" | |
Dim $oSp = ObjCreate("SAPI.SpVoice") | |
Func MyExit() | |
Exit 0 | |
EndFunc | |
HotKeySet("!{ESC}", "MyExit") ;alt+ESC | |
Dim $pos = MouseGetPos() | |
Dim $newpos, $oIE, $oBody | |
;event loop | |
While True | |
; Sleep for 10 seconds | |
Sleep(10000) | |
;check if mouse moved | |
$newpos = MouseGetPos() | |
If Not ($newpos[0] = $pos[0] AND $newpos[1] = $pos[1]) Then | |
_FileWriteLog($myLog, "User is active at x:" & $newpos[0] & " y:" & $newpos[1]) ; Write to the logfile passing the filepath | |
;user is active | |
Sleep(3*60*1000);wait 3 minutes | |
$pos=$newpos | |
ContinueLoop | |
EndIf | |
;mouse was note moved, Random coordinates | |
$pos[0]=Random(400,500) | |
$pos[1]=Random(300,400) | |
MouseMove($pos[0],$pos[1], 50) | |
;find active Lync/OC windows | |
$winList = WinList($IMClassName) | |
For $a = 1 to $winList[0][0] | |
; Activate it | |
If WinActivate($winList[$a][0]) <> 0 Then | |
;inner window is IE pages | |
$oIE = _IEAttach ($winList[$a][1],"embedded", 1) | |
$oBody = _IEBodyReadText($oIE) | |
;write chat history for debug | |
$file = FileOpen("c:\temp\current_chat.txt", 9) ; mode 9 is (append + mkdir if necessary) | |
FileWrite($file, $oBody) | |
FileClose($file) | |
;Speak the subject | |
Local $oc_subject = WinGetTitle($winList[$a][0], "") | |
$oSp.Speak($oc_subject) | |
;auto reply | |
Send("hi") | |
Send("{Enter}") | |
Sleep(60000) ;wait message sent | |
SoundPlay("c:\blah\blah.mp3",1) ;play ring tone | |
WinClose($winList[$a][0], "") ;close current chat window | |
Sleep(6000) | |
ENdIf | |
Next | |
WEnd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment