Skip to content

Instantly share code, notes, and snippets.

@gitlarryf
Created April 9, 2020 16:57
Show Gist options
  • Save gitlarryf/cb559b10cfedc68b2fd3487056096eb5 to your computer and use it in GitHub Desktop.
Save gitlarryf/cb559b10cfedc68b2fd3487056096eb5 to your computer and use it in GitHub Desktop.
3CX Phone Helper Script
@ECHO OFF
SETLOCAL
SET Version=1.3
SET TCX="%ProgramData%\3CXPhone for Windows\PhoneApp\CallTriggerCmd.exe"
SET Away=242
SET Custom1=244
SET Custom2=241
SET Available=245
SET Exceptions=-1
SET CustomHours=-2
SET OutOfOffice=243
IF /I "%1"=="help" GOTO:Help
IF /I "%1"=="-help" GOTO:Help
IF /I "%1"=="--help" GOTO:Help
IF /I "%1"=="-?" GOTO:Help
IF /I "%1"=="/?" GOTO:Help
IF /I "%1"=="away" GOTO:Away
IF /I "%1"=="push" GOTO:Push
IF /I "%1"=="lunch" GOTO:Lunch
IF /I "%1"=="ready" GOTO:Ready
IF /I "%1"=="logout" GOTO:Logout
IF /I "%1"=="login" GOTO:Login
IF /I "%1"=="queue" Call:Queue 1
IF /I "%1"=="dial" (
echo "Calling %2 %3 %4 %5..."
echo.
Call:Dial %2 %3 %4 %5
goto:End
)
IF /I "%1"=="fix" (
echo Fixing broken 3CX connection...
CALL:Logout
echo Restored 3CX Connection. Logging back in...
CALL:Login
CALL:Ready
CALL:Dial
GOTO:eof
)
IF /I "%1"=="status" (
echo Setting status to %2
echo.
Call:SetStatus %2
goto:End
)
IF /I "%1"=="" GOTO:HELP
:Unknown
echo.
echo "%1" is an unknown or invalid 3CX command!
echo.
goto:End
:End
ENDLOCAL
goto:eof
:Help
echo 3CX Phone System Helper Application
echo v%VERSION% by Larry Frieson
echo.
echo The following commands are supported:
echo.
echo AWAY - Place your phone in "Away" mode, and marks you DND.
echo LUNCH - Places your phone in DND mode, and marks you at Lunch.
echo READY - Places you back in the normal "ready" mode.
echo LOGOUT - Logs you out of the 3CX system, and marks you "Away".
echo LOGIN - Logs you back into the 3CX system, and marks you "ready".
echo QUEUE x - Logs you into queue x.
echo DIAL n - Dials the provided number "n".
echo FIX - Attempts to fix a broken connection between your PC and the 3CX server.
echo.
goto:End
:Away
shift
%TCX% --set-active-profile=%Away% --set-profile-status=%Away%/"AUTO: Away - %1"
:Lunch
%TCX% --set-active-profile=%OutOfOffice% --set-profile-status=%OutOfOffice%/"CallCtrl.cmd: At Lunch"
goto:end
:Ready
%TCX% --set-active-profile=%Available% --set-profile-status=%Available%/"%2"
goto:end
:Logout
Call:Queue 0
%TCX% --set-active-profile=%OutOfOffice%
goto:end
:Login
Call:Queue 1
goto:Ready
:SetStatus
%TCX% --set-profile-status=%OutOfOffice%/%*
goto:End
:Queue
%TCX% --queue=%1
goto:End
:Push
shift
%TCX% --dial="%1%2%3%4%5%6%7%8%9"
echo Pushed "%1%2%3%4%5%6%7%8%9" to dialer buffer.
echo.
goto:End
:Dial
shift
%TCX% --call="%1 %2 %3 %4 %5 %6 %7 %8 %9"
goto:eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment