; Example: Tab control:
Menu, Tray, Icon, %SystemRoot%\system32\SHELL32.dll, 201
SetTitleMatchMode 2
SetTitleMatchMode Slow
SetDefaultMouseSpeed, 1 ;0=instant 100=slowest
#SingleInstance , force
LeaderFile = P:\AHK Reflections\AHKs\Custom Speed Dials\Custom Speed Dials - Leaders.txt
AgentFile = P:\AHK Reflections\AHKs\Custom Speed Dials\Custom Speed Dials - Agents.txt
InternalFile = P:\AHK Reflections\AHKs\Custom Speed Dials\Custom Speed Dials - Internal.txt
ExternalFile = P:\AHK Reflections\AHKs\Custom Speed Dials\Custom Speed Dials - External.txt
;__________________________________________________________________________
Gui, Add, Tab2, w200 h300 vTab AltSubmit, Agent|Leader|External||Internal
Gui, Color, F87431
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, , %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%
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 Oasis Softphone
{
MsgBox Oasis not found. Please sign in to Oasis 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 Logged Out ; If Logged Out, Log in
{
WinMenuSelectItem , Oasis Softphone , Idle , Phone , Login
WinWait , (Idle) Oasis Softphone
Sleep 500
}
If FullTitle contains Active ; If call is active,
{
MyClick(140,200) ; Put call on hold
WinWait , (On Hold) Oasis Softphone
Sleep 500
}
If FullTitle contains Available ; If Available, Go to Idle
{
WinMenuSelectItem , Oasis Softphone , Idle , Phone , ACD State , Idle
WinWait , (Idle) Oasis Softphone
Sleep 500
}
If FullTitle not contains Idle,Wrap,(On Hold)
{
MsgBox %FullTitle%`nCannot dial from this state.`nMust be in Wrap, Idle, or Hold.
Return
}
Loop 10
{
IfWinExist Dial Pad
{
WinActivate
MyClick(DialPadX,DialPadY)
Sleep 210
SendInput {tab}
Break
}
Else
{
MyClick(90,200) ; Open Dial Pad
Sleep 350 ; Wait for Dial Pad
}
}
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