;Виктор Горелов music888@rambler.ru
;денис aka Outsider outsidepro@rambler.ru
;CopyRight 2009

Include "HjGlobal.jsh" ; default HJ global variables
include "hjconst.jsh"
Include "qip.jsm"
Include "Smile.JSS"
use "QipApi.jsb"

Const
LowGraphic="graphic 283",
sent="->--------------------------------------",
received="-<--------------------------------------"

Globals
String sGlobalNumberICQ,
String sGlobalQuipHistoryPath,
handle hRealWindow,
handle hTreePanell,
handle hCurrentWindow,
int CurrentPane,
string cClass,
string gClient ,
string gText,
string VashNomerICQ,
int DialogSentPanell,
string QuipTextBuffer,
string ToolTipNewText 

Script SayMsgByIndex (int index)
;2
var
int VirtualSay,
string AllText,
string temp,
string text,
string Sentreceived,
int a

if CurrentPane==2 then
if index == 0  then
let index=1
let VirtualSay=1
else
SayInteger (index)
EndIf
let AllText=StringReverse (GetTextOfFileEx ())
While Index > 0 
let text=""
let temp=""
let a=0
While a!=-1 
if StringLength (AllText) > 0 then
let temp=StringLeft (AllText, 40)
if StringCompare (temp, sent, 0) == 0 || StringCompare (temp, received, 0) == 0 then
let a=-1
let AllText=stringChopLeft (AllText, 40)
if StringCompare (temp, sent, 0) == 0 then
let Sentreceived="Отправлено, "
elif StringCompare (temp, received, 0) == 0 then
let Sentreceived="Получено, "
EndIf
else
let text=FormatString ("%1%2", text, StringLeft (AllText, 1))
let AllText=stringChopLeft (AllText, 1)
EndIf
else
SayString ("текст кончился")
return
EndIf
EndWhile
let Index=Index-1
EndWhile
let text=StringReverse (text)
let text=stringChopLeft (text, 1+StringLength (StringSegment (text, ")", 1)))

Say (Sentreceived+text, OT_SELECT)
if IsSameScript () then
Delay (2)
Pause ()
UserBufferClear ()
if IsSameScript () == 2 then
UserBufferDeactivate ()
TypeString (FormatString ("%1%2%3", "\n", text))
return
elif IsSameScript () == 1 && VirtualSay == 0 then
UserBufferClear ()
SayFormattedMessage (OT_USER_BUFFER, FormatString ("%1%2%3", text, "\n", msgExit))
EndIf
EndIf
EndIf
EndScript

Script SayTrayNewMessage ()
TrayNewMessage (1)
EndScript

String Function TrayNewMessage (int say)
var
int n,
    string strTip,
    string message

let n= SysTrayGetItemCount ()

while n>0
   Let strTip = SysTrayGetItemToolTip (n)
if StringSegment (strTip, " ", 3) == "Сообщение" then
    let message= message+ LIST_ITEM_SEPARATOR + StringSegment (strTip, "От", 3)
EndIf
    let n=n-1
EndWhile
if ( 0 == StringLength (message) ) then
let message=msgNoNewMessages
else
let message=FormatString ("%1%2", msgMessageFrom, message)
endIf
if say then
Say (message, OT_SELECT)
else
return message
EndIf
EndFunction

String Function GetLangData (string LangParam, string LangKey)
Var
String Path,
String Current,
String Result

Let Path = GetAppFilePath ()
Let Current = StringSegment (Path, "\\", StringSegmentCount (Path, "\\"))

Let Path = StringLeft (Path, StringLength (Current))
Let Result = Path
Let Path = Path+"\\LI\\current.cfg"
Let Current = GetTextOfFile (Path)
Let Current = StringSegment(Current, "\r\n", 1)

Let Path =  Result+"\\LI\\"+Current+"\\lang.ini"
Let Result = IniReadString (LangParam, LangKey, "<UNKNOWN>", Path)
Return result
EndFunction


Script MoveToListFind ()
;7
SetFocus (FindWindow (hRealWindow, "TListView", ""))
EndScript

Script SentAndMinimise ()
;2
{Control+Enter}
Pause ()
PostMessage (GetAppMainWindow (GetCurrentWindow ()), 274, 61472, 0)
EndScript

Script MoveToDialogPanell ()
SpeechOff ()
SetFocus (FindWindow (hRealWindow, "TInfBitBtn", ""))
{UpArrow}
SpeechOn ()
EndScript

Script Autorise ()
FindButonAutorise (msgAutorise)
EndScript

Script NoAutorise ()
FindButonAutorise (msgNoAutorise)
EndScript

Int Function FindButonAutorise (string ButonName)
var
handle hand

let hand=FindWindow (GetRealWindow (GetCurrentWindow ()), "TPageControlEx", "")
if hand then
let hand=FindWindow (hand, "TButton", ButonName)
if hand then
Say (GetWindowName (hand), OT_SELECT)
if IsWindowVisible (hand) then
SaveCursor ()
MoveToWindow (hand)
LeftMouseButton ()
RestoreCursor ()
else
Say (msgNoButonVisible, OT_ERROR)
EndIf
else
Say (msgNotAutorise, OT_ERROR)
EndIf
EndIf
EndFunction

Script LowButonSettings ()
LowButonGraphic (0,"graphic 283","graphic 283",1)
EndScript

Script LowButonFind ()
LowButonGraphic (1,"graphic 276","graphic 641",1)
EndScript

Script LowButonPolis ()
if IsSameScript () == 1 then
LowButonGraphic (2, "", "",1)
EndIf
LowButonGraphic (2, "", "",0)
EndScript

Script LowButonStatusPicture ()
Say (msgStatusPicture, OT_SELECT)
if IsSameScript () == 1 then
LowButonGraphic (3, "", "",1)
return
EndIf
LowButonGraphic (3, "", "",0)
EndScript

Int Function LowButonGraphic (int sdvig, string graphic1, string graphic2, int click)
var
string c

if CurrentPane == 1 then
if cClass == "TVirtualDrawTree" then
SaveCursor ()
JAWSCursor ()
SetJCFOption (OPT_INCLUDE_GRAPHICS, 2)
if sdvig < 5 then
MoveTo (GetWindowLeft (hTreePanell), GetWindowTop (hTreePanell))
FindGraphic (hTreePanell, LowGraphic, S_TOP, S_RESTRICTED)
;SayString (GetWindowClass (hTreePanell))
While sdvig > 0
NextWord ()
;SayWord ()
let sdvig=sdvig-1
EndWhile
else
Moveto (GetWindowRight (hTreePanell), GetWindowBottom (hTreePanell))
PriorWord ()
EndIf
Pause ()
let c=GetCharacter () 
if c == graphic1 || c == graphic2 || c then
if click == 0 then
SayWord ()
elif click == 1 then
LeftMouseButton ()
EndIf
;else
;SayString ("непопали")
EndIf
SetJCFOption (OPT_INCLUDE_GRAPHICS, 1)
RestoreCursor ()
EndIf
EndIf
EndFunction

Int Function VirtualViewMessages ()
var
string text

If UserBufferIsActive () then
UserBufferDeactivate ()
Say (msgRefresh,  OT_USER_REQUESTED_INFORMATION)
EndIf

let text=GetTextOfFileEx ()
SpeechOff ()
SayFormattedMessage (OT_USER_BUFFER, text+msgExit)
Pause ()
Delay (5)
JAWSBottomOfFile ()
Pause ()
FindString (GetFocus (), "-----", S_BOTTOM, S_RESTRICTED)
NextLine ()
SpeechOn ()
SayLine ()
EndFunction

String Function GetTextOfFileEx ()
var
handle hand,
string NomerICQ,
string temp,
string text,
string sKontaktPad,
string a

let NomerICQ=GetWindowName (GetFirstChild (GetFirstChild (GetNextWindow (FindWindow (hRealWindow, "TRichView", "")))))
let temp=NomerICQ
let NomerICQ=""
While StringLength (temp) > 0
let a=StringLeft (temp, 1) 
;if a== "0" || a== "1" || a== "2" || a== "3" || a== "4" || a== "5" || a== "6" || a== "7" || a== "8" || a== "9" then
if a>= "0" && a<= "9" then
let NomerICQ=FormatString ("%1%2", NomerICQ, a)
EndIf
let temp=stringChopLeft (temp, 1)
EndWhile
;SayString (NomerICQ)
let sKontaktPad=FormatString ("%1%2%3%4%5%6", stringChopRight (GetAppFilePath (), StringLength (GetAppFileName ())), "Users\\",VashNomerICQ, "\\History\\", NomerICQ, ".txt")
if not FileExists (sKontaktPad) then
let sKontaktPad=FormatString ("%1%2%3%4%5%6", stringChopRight (GetAppFilePath (), StringLength (GetAppFileName ())), "Users\\",sGlobalNumberICQ, "\\History\\", NomerICQ, ".txt")
if not FileExists (sKontaktPad) then
Say (msgErorKontaktPad, OT_ERROR)
return
EndIf
EndIf
let text=GetTextOfFile (sKontaktPad)
if StringLength (text) == 0 then
Say (msgNotMessages, OT_USER_REQUESTED_INFORMATION)
return
EndIf
return text
EndFunction


Script MoveToOtvet ()
var
handle hand

if CurrentPane==2 then
let hand=FindWindow (hRealWindow, "TRichView", "")
SpeechOff ()
SetFocus (hand)
Pause ()
SetFocus (hand)
SpeechOn ()
Say (msgWindowMessages, OT_SELECT)
EndIf
EndScript

Script ClearEditInput ()
if GetWindowClass (GetFocus ()) == "TRichViewEdit" then
{Control+a}
{Delete}
Say (msgInputBoxClear,  OT_USER_REQUESTED_INFORMATION)
EndIf
EndScript

Script SayLenghtMessage ()
var
string Client 

if CurrentPane == 2 then
Let Client = GetWindowName (GetNextWindow (GetFirstChild (GetFirstChild (GetNextWindow (FindWindow (hRealWindow, "TRichView", ""))))))
if Client  == "печатает ..." then
Say (Client , OT_SELECT)
else
PlaySound (GetSharedSettingsDirectory ()+"\\sounds\\ClayPotLid.wav")
EndIf
Say (FormatString ("%1%2", msgTotalSimbols, GetWindowText (GetFirstChild (GetNextWindow (FindWindow (GetNextWindow (GetNextWindow (FindWindow (hRealWindow, "TRichView", ""))), "TRichView", ""))), 0)), OT_USER_REQUESTED_INFORMATION)
EndIf
EndScript


Script F1 ()
if CurrentPane==1 then
HighButon1 ()
elif CurrentPane==2 then
VirtualViewMessages ()
EndIf
EndScript

Script F2 ()
if CurrentPane==1 then
HighButonToggleDisplayStatus ()
elif CurrentPane==2 then
SayFormattedMessage (OT_USER_BUFFER, msgSmiles) 
EndIf
EndScript

Script F3 ()
if CurrentPane==1 then
HighButonSound ()
elif CurrentPane==2 then
EndIf
EndScript


Script F4 ()
if CurrentPane==1 then
HighButonSettings ()
elif CurrentPane==2 then
EndIf
EndScript

Script F5 ()
if CurrentPane==1 then
HighButonDisplayHistori ()
elif CurrentPane==2 then
EndIf
EndScript

Script F6 ()
if CurrentPane==1 then
elif CurrentPane==2 then
EndIf
EndScript

Script F7 ()
if CurrentPane==1 then
HighButonToggleDisplayStatus ()
elif CurrentPane==2 then
EndIf
EndScript

Script F8 ()
if CurrentPane==1 then
elif CurrentPane==2 then
EndIf
EndScript

Script F9 ()
if CurrentPane==1 then
elif CurrentPane==2 then
EndIf
EndScript

Int Function HighButon1 ()
var
handle hand,
string s

let hand=GetNextWindow (GetNextWindow (FindWindow (GetAppMainWindow (GetFocus ()), "TPanel", "")))
if hand then
SaveCursor ()
SpeechOff ()
MoveClick (hand,6,12,0)
Pause ()
SetJCFOption (OPT_INCLUDE_GRAPHICS, 2)
JAWSCursor ()
MoveTo (GetWindowLeft (hand)+5,GetWindowTop (hand)+11)
	
let s=GetCharacter ()
SpeechOn ()
if s=="graphic 919" then
Say (msgKontaktsDisplay, OT_USER_REQUESTED_INFORMATION)
elif s=="graphic 416" then
Say (msgKontaksHide, OT_USER_REQUESTED_INFORMATION)
EndIf
SetFocus (FindWindow (GetAppMainWindow (GetCurrentWindow ()), "TVirtualDrawTree", ""))
;SayString (s)
SetJCFOption (OPT_INCLUDE_GRAPHICS, 1)
RestoreCursor ()
EndIf
EndFunction

Int Function HighButonToggleDisplayStatus ()
var
handle hand,
string s

let hand=GetNextWindow (GetNextWindow (FindWindow (GetAppMainWindow (GetFocus ()), "TPanel", "")))
if hand then
SaveCursor ()
SpeechOff ()
MoveClick (hand,25,12,0)
Pause ()
SetJCFOption (OPT_INCLUDE_GRAPHICS, 2)
JAWSCursor ()
MoveTo (GetWindowLeft (hand)+24,GetWindowTop (hand)+11)
	
let s=GetCharacter ()
SpeechOn ()
if s=="graphic 720" then
IniWriteInteger ("Parameters", "Groops", 1,"Qip.ini")
Say (msgGroops, OT_USER_REQUESTED_INFORMATION)
elif s=="graphic 552" then
IniWriteInteger ("Parameters", "Groops", 0,"Qip.ini")
Say (msgOnLine, OT_USER_REQUESTED_INFORMATION)
EndIf
SetFocus (FindWindow (GetAppMainWindow (GetCurrentWindow ()), "TVirtualDrawTree", ""))
;SayString (s)
SetJCFOption (OPT_INCLUDE_GRAPHICS, 1)

RestoreCursor ()
EndIf
EndFunction

Int Function HighButonSound ()
var
handle hand,
string s

let hand=GetNextWindow (GetNextWindow (FindWindow (GetAppMainWindow (GetFocus ()), "TPanel", "")))
if hand then
SaveCursor ()
SpeechOff ()
MoveClick (hand,43,11,0)
Pause ()
SetJCFOption (OPT_INCLUDE_GRAPHICS, 2)
JAWSCursor ()
MoveTo (GetWindowLeft (hand)+43,GetWindowTop (hand)+11)
	
let s=GetCharacter ()
SpeechOn ()
if s=="graphic 697" then
Say (msgSoundOn, OT_USER_REQUESTED_INFORMATION)
elif s=="graphic 281" then
Say (msgSoundOff, OT_USER_REQUESTED_INFORMATION)
EndIf
SetFocus (FindWindow (GetAppMainWindow (GetCurrentWindow ()), "TVirtualDrawTree", ""))
;SayString (s)
SetJCFOption (OPT_INCLUDE_GRAPHICS, 1)

RestoreCursor ()
EndIf
EndFunction

Int Function HighButonSettings ()
var
handle hand,
string s

let hand=GetNextWindow (GetNextWindow (FindWindow (GetAppMainWindow (GetFocus ()), "TPanel", "")))
if hand then
Say (msgPrivateList, OT_USER_REQUESTED_INFORMATION)
SaveCursor ()
MoveClick (hand,63,11,0)
RestoreCursor ()
EndIf
EndFunction

Int Function HighButonDisplayHistori ()
var
handle hand,
string s

let hand=GetNextWindow (GetNextWindow (FindWindow (GetAppMainWindow (GetFocus ()), "TPanel", "")))
if hand then
SaveCursor ()
JAWSCursor ()
MoveClick (hand,83,11,0)
Say (msgHistory,OT_SELECT)
RestoreCursor ()
EndIf
EndFunction

Script NextKontakt ()
TypeCurrentScriptKey ()
SayKontaktName (1)
EndScript

Script PriorKontakt ()
TypeCurrentScriptKey ()
SayKontaktName (1)
EndScript

String Function SayKontaktName (int say)
var
handle hand,
string s,
string msg

if GetWindowClass (GetRealWindow (GetFocus ())) == "TMsgForm" then

if say< 2 then
let msg=msg2_1
else
let msg=msg2_2
EndIf
SpeechOff ()
Pause ()
Delay (2)
SpeechOn ()
let s=FormatString ("%1%2%3", msg, GetWindowName (FindWindow (GetAppMainWindow (GetFocus ()),"TPageControlEx","")),"\n")
if  say  then
Say (s,OT_USER_REQUESTED_INFORMATION)
else
return s
EndIf
EndIf
EndFunction

Script SayStatusEx ()
var
string s

if CurrentPane == 2 then
let s=FormatString ("%1%2", SayKontaktName (0), SayPanelInfo (0,0))
if IsSameScript () == 1 then
UserBufferClear ()
UserBufferAddText (s)
UserBufferActivate ()
EndIf
Say (s, OT_STATUS)
PerformScript SayLenghtMessage()
EndIf
EndScript

String Function SayPanelInfo (int iOrder, int say)
Var
String Fullname,
String UIN,
String Email,
String client,
handle hand,
String s

let hand=GetFirstChild (GetFirstChild (GetNextWindow (FindWindow (hRealWindow, "TRichView", ""))))
Let Fullname = GetWindowName (GetNextWindow (GetNextWindow (GetNextWindow (hand))))
If stringIsBlank (Fullname) then
Let Fullname=msgDoNot
EndIf
Let UIN = GetWindowName (hand)
If StringIsBlank (UIN) then
Let UIN=msgDoNot
EndIf
Let Email = GetWindowName (GetNextWindow (GetNextWindow (hand)))
If StringIsBlank (Email) then
Let Email=msgDoNot
EndIf
Let Client = GetWindowName (GetNextWindow (hand))
If StringIsBlank (client) then
Let Client=msgDoNot
EndIf
; Далее определяем что мы хотим сказать. Какую инфу говорить мы определяем сами, передавая ее значение в функцию через интегер:  0 - все, 1 - имя и фамилия, 2 - ICQ-номер, 3 - E-Mail, 4 - Клиент. 0 говорит с преффиксами - в сообщениях видно, остальные только текст.
If iOrder==0 then
let s=FormatString ("Имя: %1\n ICQ-UIN SN: %2\n E-mail: %3\n клиент контакта: %4", Fullname, UIN, Email, Client)
if say then
Say (s, OT_STATUS)
else
return s
EndIf
ElIf iOrder==1 then
Say (Fullname, OT_STATUS)
ElIf iOrder==2 then
Say (UIN, OT_STATUS)
ElIf iOrder==3 then
Say (Email, OT_STATUS)
ElIf iOrder==4 then
Say (Client, OT_STATUS)
EndIf
EndFunction

Script SayCurrentLine ()
;SayInteger (CurrentPane)
if  MenusActive () || IsVirtualPCCursor () then
return SayLine ()
EndIf
if IsPCCursor () then
if CurrentPane == 1 then
if cClass == "TVirtualDrawTree" then
return SayCharacterEx ()
EndIf
EndIf
if CurrentPane == 2 then
if StringCompare (cClass, "TPanel",0) == 0 then
SayCharacterEx ()
return
EndIf
EndIf
if CurrentPane == 5 then
if cClass == "TComboBox" then
Say (GetWindowText (GetPriorWindow (GetFocus ()), 0),OT_SELECT)
return
EndIf
EndIf
EndIf
SayLine ()
EndScript

Script SayNextLine ()
var
string s,
int a

if  MenusActive () || !CurrentPane then return TypeCurrentScriptKey ()
EndIf
If UserBufferIsActive () || not IsPCCursor () then
NextLine ()
SayLine ()
return
EndIf
;SayInteger (CurrentPane )
if IsPCCursor () then
;~
if CurrentPane == 1 then
if cClass== "TVirtualDrawTree" then
SpeechOff ()
{DownArrow}
Pause ()
if GetTreeViewLevel () == 0 then
if IniReadInteger ("Parameters", "Groops", 1,"Qip.ini") then
let s=msgGroop
EndIf
EndIf
SpeechOn ()
Say (s, OT_SELECT)
SayTreeViewItem ()
return
EndIf
if cClass == "TComboBox" then
NextLine ()
return
EndIf
EndIf
;~
if CurrentPane == 2 then
if StringCompare (cClass, "TInfBitBtn",0) == 0 || StringCompare (cClass, "TPanel",0) == 0 then
NextLine ()
return
EndIf

if StringCompare (cClass, "TRichView",0) == 0 then
SpeechOff ()
let s=GetLine ()
While s==GetLine ()&& a< 10
NextLine ()
let a=a+1
EndWhile
if a==10 then
JAWSCursor ()
RouteJAWSToPc ()
NextLine ()
if StringCompare (GetWindowClass (GetFocus ()), "TRichView",0) == 0 then
{Home}
LeftMouseButton ()
Delay (1)
LeftMouseButton ()
else
;PriorLine ()
SpeechOn ()
Say (
"край"
, OT_USER_REQUESTED_INFORMATION)

EndIf
;Pause ()
EndIf
 SpeechOn ()
PCCursor ()
SayLine ()
return
EndIf
EndIf
;статус в сети, или ваша статус картинка~
if CurrentPane == 5 then
if cClass == "TComboBox" then
SpeechOff ()
NextLine ()
Pause ()
if  cClass == "TEdit" then
ShiftTabKey ()
EndIf
Pause ()
SpeechOn ()
Say (GetWindowText (GetPriorWindow (GetCurrentWindow ()),0), OT_SELECT)
return
EndIf
EndIf
if CurrentPane == 6 then
if cClass == "TListBox" || cClass == "TRadioButton" then
NextLine ()
return
EndIf
if cClass == "TListView" then
SpeechOff ()
NextLine ()
Pause ()
SetFocus (FindWindow (GetAppMainWindow (GetFocus ()), "TListView", ""))
Pause ()
SpeechOn ()
SayLine ()
return
EndIf
EndIf

;результаты поиска
if CurrentPane == 7 then
if cClass == "TComboBox" then
NextLine ()
return
EndIf
EndIf

EndIf

NextLine ()
SayLine ()
EndScript

Script SayPriorLine ()
var
string s,
int a	

if  MenusActive () || !CurrentPane then
return TypeCurrentScriptKey ()
EndIf
if UserBufferIsActive () || not IsPCCursor () then
PriorLine ()
SayLine ()
return
EndIf
if IsPCCursor () then
;~
if CurrentPane == 1 then
if cClass== "TVirtualDrawTree" then
SpeechOff ()
;PriorLine ()
{UpArrow}
Pause ()
if GetTreeViewLevel () == 0 then
if IniReadInteger ("Parameters", "Groops", 1,"Qip.ini") then
let s=msgGroop
EndIf
;PostMessage (GetAppMainWindow (GetCurrentWindow ()), 274, 61488, 0)
;else
;RouteJAWSToPc ()
;LeftMouseButton ()
EndIf
SpeechOn ()
;Say (FormatString ("%1%2", s, GetLine ()), OT_SELECT)
Say (s, OT_SELECT)
SayTreeViewItem ()
return
EndIf
if cClass == "TComboBox" then
PriorLine ()
return
EndIf
EndIf

;~
if CurrentPane == 2 then
if StringCompare (cClass, "TInfBitBtn",0) == 0 || StringCompare (cClass, "TPanel",0) == 0 then
PriorLine ()
return
EndIf

if StringCompare (GetWindowClass (GetFocus ()), "TRichView",0) == 0 then
SpeechOff ()
let s=GetLine ()
While s==GetLine ()&& a< 10
PriorLine ()
let a=a+1
EndWhile
if a==10 then
JAWSCursor ()
RouteJAWSToPc ()
PriorLine ()
if StringCompare (GetWindowClass (GetFocus ()), "TRichView",0) == 0 then
{Home}
LeftMouseButton ()
Delay (1)
LeftMouseButton ()
else
SpeechOn ()
SayString ("край")
EndIf
PCCursor ()
EndIf
SpeechOn ()
SayLine ()
return
EndIf
EndIf
;~
if CurrentPane == 5 then
if cClass == "TComboBox" then
SpeechOff ()
PriorLine ()
Pause ()
if  cClass == "TEdit" then
ShiftTabKey ()
EndIf
Pause ()
SpeechOn ()
Say (GetWindowText (GetPriorWindow (GetCurrentWindow ()),0), OT_SELECT)
return
EndIf
EndIf
if CurrentPane == 6 then
if cClass == "TListBox" || cClass == "TRadioButton" then
PriorLine ()
return
EndIf
if cClass == "TListView" then
SpeechOff ()
PriorLine ()
Pause ()
SetFocus (FindWindow (GetAppMainWindow (GetFocus ()), "TListView", ""))
Pause ()
SpeechOn ()
SayLine ()
return
EndIf
EndIf
if CurrentPane == 7 then
if cClass == "TComboBox" then
PriorLine ()
return
EndIf
EndIf

EndIf
PriorLine ()
SayLine ()
EndScript

Script SayNextCharacter ()
if UserBufferIsActive ()|| IsJAWSCursor () then
NextCharacter ()
elif CurrentPane == 2 && StringCompare (cClass, "TPanel",0) == 0 then
let DialogSentPanell=DialogSentPanell+1
if DialogSentPanell == 7 then
let DialogSentPanell=1
EndIf
else
TypeCurrentScriptKey ()
EndIf
SayCharacterEx ()
EndScript

Script SayPriorCharacter ()
if UserBufferIsActive ()|| IsJAWSCursor () then
PriorCharacter ()
elif CurrentPane == 2 && StringCompare (cClass, "TPanel",0) == 0 then
let DialogSentPanell=DialogSentPanell-1
if DialogSentPanell < 1 then
let DialogSentPanell=6
EndIf
else
TypeCurrentScriptKey ()
EndIf
SayCharacterEx ()
EndScript

Int Function SayCharacterEx ()
var
int a
if IsPCCursor () then
if StringCompare (cClass, "TPageControlEx",0) == 0 then
if CurrentPane == 2 then
SayKontaktName (0)
Pause ()
SetFocus (FindWindow (GetRealWindow (GetCurrentWindow ()), "TPageControlEx", ""))
EndIf
return
EndIf

if CurrentPane == 1 then
if cClass == "TPageControlEx" then
return
EndIf
if cClass == "TVirtualDrawTree" then
SayTreeViewItem ()
;SayTreeViewLevel (0)
return
EndIf
elif CurrentPane == 2 then
if StringCompare (cClass, "TPanel",0) == 0 then
SayInteger (DialogSentPanell)
SetJCFOption (OPT_INCLUDE_GRAPHICS, 2)
SaveCursor ()
JAWSCursor ()
MoveToWindow (hCurrentWindow)
SetRestriction (RestrictWindow)
JAWSTopOfFile ()
;MoveTo (GetWindowLeft (hCurrentWindow), GetWindowTop (hCurrentWindow))
let a=DialogSentPanell-1
While a>0
NextWord ()
let a=a-1
EndWhile
SayWord ()
RestoreCursor ()
SetJCFOption (OPT_INCLUDE_GRAPHICS, 1)
return
EndIf
if cClass == "TInfBitBtn" then
SayObjectActiveItem ()
return
EndIf
;результаты поиска
EndIf
EndIf
SayCharacter ()
EndFunction

Script ToggleStatus ()
LowButonGraphic (4, "", "", 1)
EndScript

Script ToggleStatusVisible ()
LowButonGraphic (5, "", "", IsSameScript ())
EndScript

Script HotKeyHelp ()
var
string message

UserBufferClear ()
if CurrentPane== 1 then
let message=msgHelp1
elif CurrentPane== 2 then
let message=msgHelp2
elif CurrentPane== 7 then
let message=msgHelp7
EndIf
SayFormattedMessage (OT_USER_BUFFER, FormatString ("%2%3%4%1%1%5%1%6%1%7", "\n", msgHeader, " ", message, msgHelpGlobalHotKeysDefault, msgAbout, msgExid))
EndScript

Int Function InsertSmile (string Smile, string SmileName)
if GetWindowClass (GetFocus ()) == "TRichViewEdit" then
TypeString (smile)
 Say (SmileName, 22)
EndIf
EndFunction

Script ShiftTab ()
if CurrentPane == 6 then

if cClass == "THotKey" then
SetFocus (FindWindow (GetAppMainWindow (GetFocus ()), "TListView", ""))
return
EndIf
EndIf
ShiftTabKey ()
EndScript

Void Function FocusChangedEvent (handle FocusWindow, handle PrevWindow)
var
string class,
string temp,
string a

let hCurrentWindow=FocusWindow
let hRealWindow=GetRealWindow (FocusWindow)
let class=GetWindowClass (hRealWindow)
let cClass=GetWindowClass (FocusWindow)
if ;CurrentPane!= 2 || 
GetWindowClass (PrevWindow)!= "TMainForm" ||  
class != "TMainForm" then
let gText=""
EndIf
let CurrentPane=0

;дерево контактов~
if class == "TMainForm" then
let CurrentPane=1
MaxTree(hRealWindow)
if GetWindowClass (FocusWindow) == "TVirtualDrawTree" then
let hTreePanell=GetLastWindow (GetFirstChild (GetAppMainWindow (GetFocus ())))
EndIf
;диалог переписки
elif class == "TMsgForm" then
;SimulateKey ("Shift")
let CurrentPane=2
if StringCompare (cClass, "TPanel",0) == 0 then
Say (msgPanellX, OT_SELECT)
EndIf

let VashNomerICQ=GetWindowName (GetRealWindow (GetFocus ()))
let temp=VashNomerICQ
let VashNomerICQ=""
While StringLength (temp) > 0
let a=StringLeft (temp, 1) 
if a>= "0" && a<= "9" then
let VashNomerICQ=FormatString ("%1%2", VashNomerICQ, a)
EndIf
let temp=stringChopLeft (temp, 1)
EndWhile
;SayString (VashNomerICQ)

;история переписки
elif class == "THistForm" then
let CurrentPane=3

;приватные списки
elif class == "TPrivForm" then
let CurrentPane=4

;ваша статус-картинка
elif class == "TCusForm" then
let CurrentPane=5
if cClass == "TComboBox" then
Say (GetWindowText (GetPriorWindow (FocusWindow), 0),OT_SELECT)
EndIf
;панель настроек~
elif class == "TPrefForm" then
let CurrentPane=6
;поиск
elif class == "TAddForm" then
let CurrentPane=7
EndIf
FocusChangedEvent (FocusWindow, PrevWindow)
 EndFunction

Void Function KeyPressedEvent (int nKey, string strKeyName, int nIsBrailleKey, int nIsScriptKey)
if nKey == 28 then
;if CurrentPane==1 then
;SayString (cClass )
;if cClass == "TVirtualDrawTree" then
;RouteJAWSToPc ()
;LeftMouseButton ()
;LeftMouseButton ()
;SayActiveCursor ()
;return
;EndIf
;return
;EndIf
if CurrentPane == 2 then
;SayCharacterEx ()
if StringCompare (cClass, "TPanel",0) == 0 then
LeftMouseButton ()
Pause ()
if DialogSentPanell == 5 || DialogSentPanell == 6 then
SayCharacterEx ()
EndIf
EndIf
return
EndIf
if UserBufferIsActive () then
EnterKey ()
UserBufferDeactivate ()
return
EndIf
EndIf
EndFunction

Void Function TooltipEvent (handle hWnd, string strText)
;HelpBalloonEvent ()
SayString ("тултип")

let strLastTooltip = strText
Let gStrLastTipFromEvent = strText
Let ghwndToolTip = hWnd
SayString (strText)
SayInteger (ghwndToolTip )
SayFormattedMessage (ot_tool_tip, strLastToolTip)
EndFunction

void function HelpBalloonEvent(handle hwnd, string sText)
SayString ("Windows XP Help Balloons")
; Windows XP Help Balloons
;MSN messenger contacts signing in:
if IsMSNSignInAlert(hWnd) then
    return
endif
;For repeat speaking of tips, and storage foh clicking:
Let ghwndToolTip = hWnd
Let gStrLastTipFromEvent = sText
Say(sText,ot_help_balloon)
endFunction


Script Test1 ()
SayString (QuipTextBuffer)
ScheduleFunction ("HelpBalloonEvent", 0)
ScheduleFunction ("TooltipEvent",0)
EndScript

/*
WindowCreatedEvent 
*/
Void Function NewTextEvent (handle hwnd, string buffer, int nAttributes, int nTextColor, int nBackgroundColor, int nEcho, string sFrameName)
var
handle hand,
string Client ,
string text

if CurrentPane == 1 && GetWindowClass (hwnd) == "TRichView" then
SayString (buffer)
return
EndIf

let text=TrayNewMessage (0)
if text == "Сообщение От" && StringCompare (ToolTipNewText, text, 0) then
SayString (text)
let ToolTipNewText =text
elif text != "Сообщение От" then
let ToolTipNewText =""
EndIf

if CurrentPane == 1 then
let QuipTextBuffer=buffer
;SayInteger (hwnd)
;SayString (buffer)
;CopyToClipboard (buffer)

;SayInteger (nAttributes)
;SayInteger (nTextColor)
;SayInteger (nBackgroundColor)
;SayInteger (nEcho)
;SayString (sFrameName)
EndIf

;if CurrentPane == 2 then
if GetWindowClass (hRealWindow) == "TMsgForm" then
Let Client = GetWindowName (GetNextWindow (GetFirstChild (GetFirstChild (GetNextWindow (FindWindow (hRealWindow, "TRichView", ""))))))
if Client  != gClient then
if Client  == "печатает ..." then
Say (Client , OT_SELECT)
elif gClient  == "печатает ..." then
Say ("закончил", OT_SELECT)
EndIf
EndIf
let gClient =Client 
let hand=FindWindow (hRealWindow, "TRichView", "")
let text=GetWindowText (hand, 0)
;SayString (text)
if text != gText && !StringIsBlank (text) && !StringIsBlank (gText) then
PerformScript SayMsgByIndex (0)
EndIf
let gText=text
EndIf
EndFunction

Void Function AutoStartEvent ()
var
    int n,
    string strTip,
    string message

let n= SysTrayGetItemCount ()

while n > 0
   Let strTip = SysTrayGetItemToolTip (n)

if strTip == "[qip]" then
let sGlobalNumberICQ=StringSegment (strTip  , "- ", 4)
if sGlobalNumberICQ then
let sGlobalQuipHistoryPath=FormatString ("%1%2%3%4%5%6", stringChopRight (GetAppFilePath (), StringLength (GetAppFileName ())), "Users\\", sGlobalNumberICQ, "\\History\\")
EndIf
EndIf
let n=n-1
EndWhile
if CurrentPane == 2 then
SayKontaktName (2)
EndIf
;SayInteger (CurrentPane)
;getJCFOption (OT_DIALOG_NAME))


EndFunction

Void Function AutoFinishEvent ()
EndFunction


Script SayTulTip ()
var
handle hand,
int flag,
string str

if CurrentPane==1 && GetTreeViewLevel () == 1 then
let flag=IsSameScript ()
;SaveCursor ()
JAWSCursor ()
RouteJAWSToPc ()
JAWSEnd ()
;SayWord ()
;RestoreCursor ()
PCCursor ()
Pause ()
Delay (5)

let hand=GetFirstWindow (GetAppMainWindow (GetFocus ()))
While hand
if GetWindowClass (hand) == "TVirtualTreeHintWindow" then
let str=GetWindowText (hand, 0)
SaveCursor ()
JAWSCursor ()
JAWSTopOfFile ()
RestoreCursor ()
if flag then
UserBufferClear ()
SayFormattedMessage (OT_USER_BUFFER, FormatString ("%1%2%3", str, "\n", msgExit))
else
SayString (str)
EndIf
return
EndIf
let hand=GetNextWindow (hand)
EndWhile
Say (msgNotFound, OT_Error)
EndIf
EndScript


