Color1 := "cFFFF00" ; Yellow
Color2 := "cFFCC00" ; Peach
Color3 := "cFF9900" ; Orange
Color4 := "cFF6600" ; Dark Orange
Color5 := "cFF3300" ; Light Red
Color6 := "cFF0000" ; Red
Color7 := "cCC0000" ; Dark red
Color8 := "cCC00FF" ; Light Purple
Color9 := "c9900CC" ; Dark Purple
Color10 := "c996600" ; Tan
Color11 := "c9999FF" ; Light Blue
Color12 := "c99CC00" ; Lime Green
Color13 := "c99FFFF" ; Light Sky Blue
Color14 := "c00CCFF" ; Deep Sky Blue
Color15 := "c0099FF" ; Blue Sky
Color16 := "c009900" ; Green
Color17 := "c006600" ; Dark green
Color18 := "c0000FF" ; Blue
Color19 := "c660000" ; Marroon
Color20 := "c000000" ; Black
Color21 := "cFFFFFF" ; White
Color22 := "cFF66FF" ; Pink
; Example: Tab control:
SetTitleMatchMode 2
SetTitleMatchMode Slow
SetDefaultMouseSpeed, 1 ;0=instant 100=slowest
#SingleInstance , force
FileCreateDir , H:\FL-CPTP-FS3\AHK Reflections\AHKs\Custom Speed Dials
LeaderFile = H:\FL-CPTP-FS3\AHK Reflections\AHKs\Custom Speed Dials\Custom Speed Dials - Leaders.txt
AgentFile = H:\FL-CPTP-FS3\AHK Reflections\AHKs\Custom Speed Dials\Custom Speed Dials - Agents.txt
InternalFile = H:\FL-CPTP-FS3\AHK Reflections\AHKs\Custom Speed Dials\Custom Speed Dials - Internal.txt
ExternalFile = H:\FL-CPTP-FS3\AHK Reflections\AHKs\Custom Speed Dials\Custom Speed Dials - External.txt
;__________________________________________________________________________
Gui, Add, Tab2, w200 h300 vTab AltSubmit, Agent|Leader|External||Internal
Gui, Color, %Color19%
CreateTab("Agent", Tab, "Phone")
CreateTab("Leader", Tab, "Phone")
CreateTab("External", Tab, "Phone")
CreateTab("Internal", Tab, "Phone")
Gui, Tab
; Subsequently-added controls will not belong to the tab control.
Gui, Add, Button, xm, Exit
; -------GUI Position: Upper right corner-------
Gui, Show
WinGetPos , X , Y , W , H , A
xPos := A_ScreenWidth - W
GuiControl, Move, Button17, % "x" W-45 ; Move the Exit button to the right margin
Gui , Show , x%xPos% y0
Return
;__________________________________________________________________________
;__________________________________________________________________________
ButtonDialLeader: ; Dial Leader
Gui, Submit, NoHide
Dial("Leader", "Phone")
Return
ButtonDialAgent: ; Dial Agent
Gui, Submit, NoHide
Dial("Agent", "Phone")
Return
ButtonDeleteLeader: ; Delete Leader
ButtonDeleteAgent: ; Delete Agent
DeleteEntry("Phone")
Return
ButtonAddNewLeader: ; Add Leader
ButtonAddNewAgent: ; Add Agent
AddEntry("Phone")
Return
ButtonUpdateLeader: ; Update Leader
ButtonUpdateAgent: ; Update Agent
UpdateEntry("Phone")
Return
;__________________________________________________________________________
;__________________________________________________________________________
ButtonDialInternal: ; Dial Internal
Gui, Submit, NoHide
Dial("Internal", "Phone")
Return
ButtonDialExternal: ; Dial External
Gui, Submit, NoHide
Dial("External", "Phone")
Return
ButtonDeleteInternal: ; Delete Internal
ButtonDeleteExternal: ; Delete External
DeleteEntry("Phone")
Return
ButtonAddNewInternal: ; Add Internal
ButtonAddNewExternal: ; Add External
AddEntry("Phone")
Return
ButtonUpdateInternal: ; Delete Internal
ButtonUpdateExternal: ; Delete External
UpdateEntry("Phone")
Return
;__________________________________________________________________________
;__________________________________________________________________________
SortList(type){
global
File := %type%File
FileRead, current, %File%
If NOT ErrorLevel
{
FileDelete %File%
Sort current
FileAppend, %current%, %File%
}
Return
}
;__________________________________________________________________________
;__________________________________________________________________________
AddEntry(mode){
global
MySubmit()
File := %type%File
Entries := NumOf%type%Entries
newName := new%type%Name
newNumber := new%type%Number
If NOT Entries
FileDelete %File%
FileAppend, `n%newName% %newNumber%, %File% ; Add new entry to the file
SortList(type) ; Sort the file
NumOf%type%Entries += 1 ; Increase counter
GetList(type, Tab, mode) ; Get the newly sorted list
Loop %Entries% ; Determine the new position of the new entry
{
currentName := %type%Name%A_Index%
If newName = %currentName%
EntryNum = %A_Index%
}
GuiControl, Choose, ComboBox%Tab%, %EntryNum% ; Select the new entry
Return
}
;__________________________________________________________________________
;__________________________________________________________________________
DeleteEntry(mode){
global
MySubmit()
File := %type%File
Entries := NumOf%type%Entries
FileDelete %File%
Loop %Entries%
{
If %type%Box = %A_Index% ; Selected Entry, delete by not appending
Continue
currentName := %type%Name%A_Index%
currentNumber := %type%Number%A_Index%
FileAppend, %currentName% %currentNumber%, %File%
If Entries > %A_Index% ; do not create a new line after last entry
FileAppend, `n, %File%
}
If Entries ; If no entries existed do not decrement. (avoid negative numbers)
Entries -= 1
If Entries ; If any entries exist, sort them
SortList(type)
If NOT Entries ; There are no more entries
{
If mode = Employee
FileAppend, No %type%s a######, %File%
If mode = Phone
FileAppend, No %type%s ###-###-####, %File%
}
NumOf%type%Entries = %Entries%
GetList(type, Tab, mode)
Return
}
;__________________________________________________________________________
;__________________________________________________________________________
UpdateEntry(mode){
global
MySubmit()
EntryNum := %type%box
DeleteEntry(mode)
AddEntry(mode)
GuiControl, Choose, ComboBox%Tab%, %EntryNum%
Return
}
;__________________________________________________________________________
;__________________________________________________________________________
CreateTab(name, number, mode){
global
GetList(name, number, mode)
Total := NumOf%name%Entries
Gui, Tab, %name%
Gui, Add, Text, %Color21% , %Total% Total %name% Entries
Gui, Add, DropDownList, v%name%Box gShowNameAndNum AltSubmit w150, %List%
Gui, Add, Button, , Dial %name%
Gui, Add, Button, y+20, Delete %name%
Gui, Add, Edit, vNew%name%Name w180, %name% Name
Gui, Add, Edit, vNew%name%Number w180, %name% Number
Gui, Add, Button, , Add New %name%
Gui, Add, Button, , Update %name%
Gui, Add, Text, %Color1% x140 y280 w60 h20 , Wells Fargo
Return
}
;__________________________________________________________________________
;__________________________________________________________________________
ShowNameAndNum:
MySubmit()
DisplayNameAndNum(type, number)
Return
;__________________________________________________________________________
;__________________________________________________________________________
DisplayNameAndNum(type, number){
global
editNum := number * 2
editName := editNum - 1
Box := %type%Box ; Ex AgentBox
Name := %type%Name%Box% ; Ex AgentName%AgentBox%
Number := %type%Number%Box% ; Ex AgentNumber%AgentBox%
GuiControl, , Edit%editName%, %Name%
GuiControl, , Edit%editNum% , %Number%
Return
}
;__________________________________________________________________________
;__________________________________________________________________________
MySubmit(){ ; Need to get tab name and number by modifying AltSubmit
global ; Store name and number in global variables
; Remove the AltSubmit property to get the tab Name
GuiControl, -AltSubmit, SysTabControl321
Gui, Submit, NoHide
type := Tab
; Activate the AltSubmit property to get the tab Number
GuiControl, +AltSubmit, SysTabControl321
Gui, Submit, NoHide
number := Tab
Return
}
;__________________________________________________________________________
;__________________________________________________________________________
GetList(type, tabNumber, mode){
global
Local Entries = 0
Local CurrentEntry = 1
File := %type%File
Tabs := %type%Tabs
GetAmount = 7
TrimAmount = 8
If mode = Phone
{
GetAmount = 12
TrimAmount = 13
}
; Get the Names and Numbers
Loop
{
FileReadLine, current, %File%, %A_Index%
If ErrorLevel
break
StringRight, %type%Number%CurrentEntry%, current, %GetAmount%
StringTrimRight, %type%Name%CurrentEntry%, current, %TrimAmount%
Name := %type%Name%CurrentEntry%
If NOT StrLen(Name) ; Name length is 0, string is empty
Continue ; Do not add empty strings to the list
If NOT Entries ; Entries = 0 means this is first entry
List = %Name%
Else
List = %List%|%Name%
Entries += 1 ; Increment local Entries counter
CurrentEntry += 1
}
If Name = No %type%s ; Ex, "No Agents"
Entries = 0 ; Do no count "No Agents" as an entry
NumOf%type%Entries := Entries ; Update global Entries counter with new total
%type%List = List ; Update global List with newly built list
; Update controls to reflect new information
GuiControl, , Static%tabNumber%, %Entries% Total %type% Entries
GuiControl, , ComboBox%tabNumber%, |
GuiControl, , ComboBox%tabNumber%, %List%
Return
}
;__________________________________________________________________________
;__________________________________________________________________________
Dial(type, mode = "Phone"){
Global
found = 0
; Check mode, adjust click position accordingly
If mode = Employee
{
DialPadX = 190
DialPadY = 40
}
If mode = Phone
{
DialPadX = 40
DialPadY = 40
}
IfWinNotExist CIV SoftPhone
{
MsgBox CIV not found. Please sign in to CIV and try again.
Return
}
Else WinActivate ; Oasis found, activate
Sleep 490 ; Allow time for Window to draw
WinGetTitle , FullTitle , A ; Current state is unknown, but held in the title
If FullTitle contains CIV SoftPhone - aftercallwork ; CIV SoftPhone - aftercallwork
{
WinWait, CIV SoftPhone - aftercallwork
MouseClick, left, 69, 14
Sleep, 100
MouseClick, left, 18, 43
Sleep , 100
Send , {TAB 8}
Send , ^a
Sleep , 100
Box := %type%Box ; Ex AgentBox
PhoneNumber := %type%Number%Box% ; Ex AgentNumber%AgentBox%
String := PhoneNumber
StringLeft, OutputVar1, String, 7 ; Stores the string "First 7 digits of String" in OutputVar1.
StringRight, OutputVar2, String, 4 ; Stores the string "Last 4 digits of String" in OutputVar2.
String := OutputVar1
StringLeft, OutputVar3, String, 3 ; Stores the string "First 3 digits of String" in OutputVar3.
StringRight, OutputVar4, String, 3 ; Stores the string "Last 3 digits of String" in OutputVar4.
SendInput 91%OutputVar3%%OutputVar4%%OutputVar2%
Send , {TAB}
Send , {ENTER}
Sleep, 100
}
If FullTitle contains CIV SoftPhone - busy aftercallwork ; CIV SoftPhone - busy aftercallwork
{
WinWait, CIV SoftPhone - busy aftercallwork
MouseClick, left, 69, 14
Sleep, 100
MouseClick, left, 18, 43
Sleep , 100
Send , {TAB 6}
send , {ENTER}
Sleep , 200
MouseClick, left, 18, 43
Sleep , 100
Send , {TAB 9}
Sleep , 100
Send , ^a
Sleep , 100
Box := %type%Box ; Ex AgentBox
PhoneNumber := %type%Number%Box% ; Ex AgentNumber%AgentBox%
String := PhoneNumber
StringLeft, OutputVar1, String, 7 ; Stores the string "First 7 digits of String" in OutputVar1.
StringRight, OutputVar2, String, 4 ; Stores the string "Last 4 digits of String" in OutputVar2.
String := OutputVar1
StringLeft, OutputVar3, String, 3 ; Stores the string "First 3 digits of String" in OutputVar3.
StringRight, OutputVar4, String, 3 ; Stores the string "Last 3 digits of String" in OutputVar4.
SendInput 91%OutputVar3%%OutputVar4%%OutputVar2%
Send , {TAB}
Send , {ENTER}
}
If FullTitle contains CIV SoftPhone - notready ; CIV SoftPhone - notready
{
WinWait, CIV SoftPhone - notready
MouseClick, left, 69, 14
Sleep, 100
MouseClick, left, 18, 43
Sleep , 100
Send , {TAB 7}
Sleep, 100
PhoneNumber := %type%Number%Box% ; Ex AgentNumber%AgentBox%
String := PhoneNumber
StringLeft, OutputVar1, String, 7 ; Stores the string "First 7 digits of String" in OutputVar1.
StringRight, OutputVar2, String, 4 ; Stores the string "Last 4 digits of String" in OutputVar2.
String := OutputVar1
StringLeft, OutputVar3, String, 3 ; Stores the string "First 3 digits of String" in OutputVar3.
StringRight, OutputVar4, String, 3 ; Stores the string "Last 3 digits of String" in OutputVar4.
SendInput 91%OutputVar3%%OutputVar4%%OutputVar2%
MouseClick, left, 263, 330
Sleep, 100
}
If FullTitle contains CIV SoftPhone - busy notready ; busy notready
{
WinWait, CIV SoftPhone - busy notready
MouseClick, left, 69, 14
Sleep, 100
MouseClick, left, 18, 43
Sleep , 100
Send , {TAB 5}
send , {ENTER}
Sleep , 200
MouseClick, left, 18, 43
Sleep , 100
Send , {TAB 8}
Sleep , 100
Send , ^a
Sleep , 100
Box := %type%Box ; Ex AgentBox
PhoneNumber := %type%Number%Box% ; Ex AgentNumber%AgentBox%
String := PhoneNumber
StringLeft, OutputVar1, String, 7 ; Stores the string "First 7 digits of String" in OutputVar1.
StringRight, OutputVar2, String, 4 ; Stores the string "Last 4 digits of String" in OutputVar2.
String := OutputVar1
StringLeft, OutputVar3, String, 3 ; Stores the string "First 3 digits of String" in OutputVar3.
StringRight, OutputVar4, String, 3 ; Stores the string "Last 3 digits of String" in OutputVar4.
SendInput 91%OutputVar3%%OutputVar4%%OutputVar2%
Send , {TAB}
Send , {ENTER}
}
If FullTitle contains CIV SoftPhone - ready ; CIV SoftPhone - ready
{
WinWait, CIV SoftPhone - ready
MouseClick, left, 69, 14
MouseClick, left, 13, 58
Sleep, 100
sleep , 100
Send , {TAB 7}
Sleep , 100
Send , ^a
Sleep , 100
Box := %type%Box ; Ex AgentBox
PhoneNumber := %type%Number%Box% ; Ex AgentNumber%AgentBox%
String := PhoneNumber
StringLeft, OutputVar1, String, 7 ; Stores the string "First 7 digits of String" in OutputVar1.
StringRight, OutputVar2, String, 4 ; Stores the string "Last 4 digits of String" in OutputVar2.
String := OutputVar1
StringLeft, OutputVar3, String, 3 ; Stores the string "First 3 digits of String" in OutputVar3.
StringRight, OutputVar4, String, 3 ; Stores the string "Last 3 digits of String" in OutputVar4.
SendInput 91%OutputVar3%%OutputVar4%%OutputVar2%
MouseClick, left, 263, 330
Sleep, 100
}
If FullTitle contains CIV SoftPhone - busy ready ; CIV SoftPhone - busy ready
{
WinWait, CIV SoftPhone - busy ready
MouseClick, left, 69, 14
MouseClick, left, 13, 58
Sleep, 100
Send , {TAB 5}
Send , {ENTER}
Sleep , 100
MouseClick, left, 18, 43
Sleep , 100
Send , {TAB 8}
Sleep , 100
Send , ^a
Sleep , 100
Box := %type%Box ; Ex AgentBox
PhoneNumber := %type%Number%Box% ; Ex AgentNumber%AgentBox%
String := PhoneNumber
StringLeft, OutputVar1, String, 7 ; Stores the string "First 7 digits of String" in OutputVar1.
StringRight, OutputVar2, String, 4 ; Stores the string "Last 4 digits of String" in OutputVar2.
String := OutputVar1
StringLeft, OutputVar3, String, 3 ; Stores the string "First 3 digits of String" in OutputVar3.
StringRight, OutputVar4, String, 3 ; Stores the string "Last 3 digits of String" in OutputVar4.
SendInput 91%OutputVar3%%OutputVar4%%OutputVar2%
Send , {TAB}
Send , {ENTER}
}
If FullTitle contains CIV SoftPhone - Held ; CIV SoftPhone - Held
{
WinWait, CIV SoftPhone - Held
MouseClick, left, 69, 14
MouseClick, left, 13, 58
sleep , 100
Send , {TAB 8}
sleep , 100
Send , ^a
Sleep , 100
Box := %type%Box ; Ex AgentBox
PhoneNumber := %type%Number%Box% ; Ex AgentNumber%AgentBox%
String := PhoneNumber
StringLeft, OutputVar1, String, 7 ; Stores the string "First 7 digits of String" in OutputVar1.
StringRight, OutputVar2, String, 4 ; Stores the string "Last 4 digits of String" in OutputVar2.
String := OutputVar1
StringLeft, OutputVar3, String, 3 ; Stores the string "First 3 digits of String" in OutputVar3.
StringRight, OutputVar4, String, 3 ; Stores the string "Last 3 digits of String" in OutputVar4.
SendInput 91%OutputVar3%%OutputVar4%%OutputVar2%
MouseClick, left, 263, 330
Sleep, 100
}
Sleep 200
Box := %type%Box ; Ex AgentBox
PhoneNumber := %type%Number%Box% ; Ex AgentNumber%AgentBox%
SendInput %PhoneNumber%
Send {Enter}
Return
}
;__________________________________________________________________________
;__________________________________________________________________________
ButtonExit:
GuiClose:
GuiEscape:
ExitApp
;__________________________________________________________________________
#include MyClick.ahk
*****************************************************************************************************************
MyClick.ahk
;__________________________________________________________________________
MyClick(X,Y,mode="relative"){
FindMouse(mode) ; Get current position
Click %X%,%Y% ; Click given position
ReturnMouse(mode) ; Return to previous position
Return
}
;__________________________________________________________________________
FindMouse(mode="relative"){
Global
CoordMode, Mouse, Screen
MouseGetPos, OldX, OldY ; Get screen position
CoordMode, Mouse, %mode%
Return
}
;__________________________________________________________________________
ReturnMouse(mode="relative"){
Global
CoordMode, Mouse, Screen
MouseMove %OldX%,%OldY% ; Move to previous screen position
CoordMode, Mouse, %mode%
Return
}