Highlight a phrase and click this icon to search it on Swyx-Forum    Highlight a phrase and click this icon to search it within the Swyx Knowledgebase    Highlight a phrase and click this icon to search it using Goolge    Highlight a phrase and click this icon to search it using Wikipedia

Highlight a phrase and click this icon to search it on Swyx-Forum    Highlight a phrase and click this icon to search it within the Swyx Knowledgebase    Highlight a phrase and click this icon to search it using Goolge    Highlight a phrase and click this icon to search it using Wikipedia

List of Blogs
Search Blogs

Blog Archive

Most recent blog entries

 

Most recent blog entries

 

Jun16

Written by:Martin
16.06.2007 10:09 

Microsoft's new WindowsPowershell is not only a great administrative tool, but IMHO a must have for developers, too. I recently used it to try something with the SwyxIt-API. It's very easy with Powershell to investigate how the API work. Here's a short example to get you started:

Get a ClientLineMgr object and see what properties and methods are available:

PS>$clmgr = new-object -com clmgr.clientlinemgr                                                                         
PS>$clmgr | get-member                                                                                                  
TypeName: System.__ComObject#{f8e5536b-4c00-11d3-80bc-00105a653379}                                                  
Name                                     MemberType   Definition                                                        
----                                     ----------   ----------                                                        
ChangePbxPassword                        Method       void ChangePbxPassword (string, string)                           
DispAcknowledgeChatMessage               Method       void DispAcknowledgeChatMessage (uint, string, uint)              
DispConvertNumber                        Method       string DispConvertNumber (uint, string)                           
DispCreateConference                     Method       void DispCreateConference (int)                                   
DispCreateMediastreamingLink             Method       string DispCreateMediastreamingLink ()                            
DispDeleteMediastreamingLink             Method       void DispDeleteMediastreamingLink (string)                        
DispExternalHookStateChanged             Method       void DispExternalHookStateChanged (int, int)                      
DispGetExtension                         Method       string DispGetExtension (int)                                     
DispGetLine                              Method       IDispatch DispGetLine (int)                                       
DispInit                                 Method       int DispInit (string)                                             
DispInitEx                               Method       int DispInitEx (string, string)                                   
DispJoinAllToConference                  Method       void DispJoinAllToConference (int)                                
DispJoinLineToConference                 Method       void DispJoinLineToConference (int)                               
DispPickupCallbackOnBusyNotification     Method       void DispPickupCallbackOnBusyNotification (int)                   
DispPickupGroupNotificationCall          Method       void DispPickupGroupNotificationCall (int)                        
DispPlaySoundFile                        Method       void DispPlaySoundFile (string, int, int)                         
DispPlayToRtp                            Method       void DispPlayToRtp (string, int, uint)                            
DispPostMessage                          Method       void DispPostMessage (uint, uint, uint)                           
DispReadChatMessage                      Method       IDispatch DispReadChatMessage (uint)                              
DispRecordFromRtp                        Method       void DispRecordFromRtp (string, int, int)                         
DispRegisterChatMessageReader            Method       uint DispRegisterChatMessageReader ()                             
DispRegisterMessageTarget                Method       void DispRegisterMessageTarget (int, int)                         
DispRegisterUser                         Method       int DispRegisterUser (string)                                     
DispRejectCallbackOnBusyNotification     Method       void DispRejectCallbackOnBusyNotification ()                      
DispReleaseUser                          Method       void DispReleaseUser (int)                                        
DispRequestCallbackOnBusy                Method       void DispRequestCallbackOnBusy (string, string)                   
DispResolveNumber                        Method       string DispResolveNumber (string)                                 
DispSelectLine                           Method       int DispSelectLine (IDispatch)                                    
DispSelectLineNumber                     Method       int DispSelectLineNumber (int)                                    
DispSendChatMessage                      Method       void DispSendChatMessage (uint, string, string, uint)             
DispSetNumberOfLines                     Method       int DispSetNumberOfLines (int)                                    
DispSimpleDial                           Method       void DispSimpleDial (string)                                      
DispSimpleDialEx                         Method       uint DispSimpleDialEx (string)                                    
DispSimpleDialEx2                        Method       uint DispSimpleDialEx2 (string, int)                              
DispSimpleDialEx3                        Method       uint DispSimpleDialEx3 (string, int, int, string)                 
DispSkinGetActionAreaState               Method       uint DispSkinGetActionAreaState (uint, uint)                      
DispSkinGetInfoDetail                    Method       string DispSkinGetInfoDetail (uint)                               
DispSkinPhoneCommand                     Method       void DispSkinPhoneCommand (uint, uint)                            
DispSpeedDialName                        Method       string DispSpeedDialName (int)                                    
DispSpeedDialNumber                      Method       string DispSpeedDialNumber (int)                                  
DispSpeedDialState                       Method       int DispSpeedDialState (int)                                      
DispStopPlaySoundFile                    Method       void DispStopPlaySoundFile ()                                     
DispStopPlayToRtp                        Method       void DispStopPlayToRtp ()                                         
DispStopRecordFromRtp                    Method       void DispStopRecordFromRtp ()                                     
DispSwitchToLine                         Method       int DispSwitchToLine (IDispatch)                                  
DispSwitchToLineNumber                   Method       int DispSwitchToLineNumber (int)                                  
DispUnRegisterChatMessageReader          Method       void DispUnRegisterChatMessageReader (uint)                       
DispUnRegisterMessageTarget              Method       void DispUnRegisterMessageTarget (int, int)                       
DispVoicemailRemoteInquiry               Method       void DispVoicemailRemoteInquiry ()                                
PlaySoundFileCDS                         Method       void PlaySoundFileCDS (string, int, int, int, int, uint)          
PlaySoundFileDxCDS                       Method       void PlaySoundFileDxCDS (string, int, int, int, int)              
PlaySoundFileDxExCDS                     Method       void PlaySoundFileDxExCDS (string, int, int, int, int, int, in... 
PlayToRtpCDS                             Method       void PlayToRtpCDS (string, int, int, int, uint)                   
RecordFromRtpCDS                         Method       void RecordFromRtpCDS (string, int, int, int, int, int, int)      
RecordSoundFileCDS                       Method       void RecordSoundFileCDS (string, int, int, int, int)              
RegisterUserEx                           Method       void RegisterUserEx (string, string, string, string, int, int,... 
ReleaseUserEx                            Method       void ReleaseUserEx ()                                             
DispAreaCode                             Property     string DispAreaCode () {get}                                      
DispAutoDetectionBackupServer            Property     string DispAutoDetectionBackupServer () {get}                     
DispAutoDetectionEnabled                 Property     int DispAutoDetectionEnabled () {get}                             
DispAutoDetectionPrimaryServer           Property     string DispAutoDetectionPrimaryServer () {get}                    
DispAutoDetectionServerAvailable         Property     int DispAutoDetectionServerAvailable () {get}                     
DispConferenceLine                       Property     IDispatch DispConferenceLine () {get}                             
DispConferenceLineNumber                 Property     int DispConferenceLineNumber () {get}                             
DispConferenceRunning                    Property     int DispConferenceRunning () {get}                                
DispCountryCode                          Property     string DispCountryCode () {get}                                   
DispGetCallbackOnBusyNotifyPeerName      Property     string DispGetCallbackOnBusyNotifyPeerName () {get}               
DispGetCallbackOnBusyNotifyPeerNumber    Property     string DispGetCallbackOnBusyNotifyPeerNumber () {get}             
DispGetCurrentServer                     Property     string DispGetCurrentServer () {get}                              
DispGetCurrentUser                       Property     string DispGetCurrentUser () {get}                                
DispInternationCallPrefix                Property     string DispInternationCallPrefix () {get}                         
DispIsServerUp                           Property     int DispIsServerUp () {get}                                       
DispLongDistanceCallPrefix               Property     string DispLongDistanceCallPrefix () {get}                        
DispMicroEnabled                         Property     int DispMicroEnabled () {get} {set}                               
DispNotificationCallCalledExtension      Property     string DispNotificationCallCalledExtension () {get}               
DispNotificationCallCalledName           Property     string DispNotificationCallCalledName () {get}                    
DispNotificationCallPeerName             Property     string DispNotificationCallPeerName () {get}                      
DispNotificationCallPeerNumber           Property     string DispNotificationCallPeerNumber () {get}                    
DispNotificationCallRedirectedFromName   Property     string DispNotificationCallRedirectedFromName () {get}            
DispNotificationCallRedirectedFromNumber Property     string DispNotificationCallRedirectedFromNumber () {get}          
DispNotificationCallWasRedirected        Property     int DispNotificationCallWasRedirected () {get}                    
DispNumberOfExtensions                   Property     int DispNumberOfExtensions () {get}                               
DispNumberOfLines                        Property     int DispNumberOfLines () {get}                                    
DispNumberOfSpeedDials                   Property     int DispNumberOfSpeedDials () {get}                               
DispPublicAccessPrefix                   Property     string DispPublicAccessPrefix () {get}                            
DispSelectedLine                         Property     IDispatch DispSelectedLine () {get}                               
DispSelectedLineNumber                   Property     int DispSelectedLineNumber () {get}                               
DispSpeakerEnabled                       Property     int DispSpeakerEnabled () {get} {set}

There's a method DispSimpleCall. Let's use it to inititate a call:

PS>$clmgr.DispSimpleDial("0023147770")

That function produces no output, so powershell does not show anything. But SwyxIt! starts the call.

Now get the line currently selected in SwyxIt:

PS>$l = $clmgr.DispSelectedLine                                                                                         
PS>$l                                                                                                                   
DispState                         : 0                                                                                   
DispAcknowledgedDialstring        :                                                                                     
DispPeerNumber                    :                                                                                     
DispPeerName                      :                                                                                     
DispCalledExtension               :                                                                                     
DispCalledName                    :                                                                                     
DispIsDirectCall                  : 0                                                                                   
DispCallWasRedirected             : 0                                                                                   
DispIsGroupCall                   : 0                                                                                   
DispRedirectedFromNumber          :                                                                                     
DispRedirectedFromName            :                                                                                     
DispChargingDetails               :                                                                                     
DispNuberOfConferenceParticipants : 0                                                                                   
DispDiscReason                    : 0                                                                                   
DispConnectionStartTime           : 30.12.1899 00:00:00                                                                 
DispConnectionFinishedTime        : 30.12.1899 00:00:00                                                                 
DispLastCallLcrPrefix             :                                                                                     
DispLastCallExtension             :                                                                                     
DispLastCallChargingDetails       :                                                                                     
DispLastCallPeersPbxUserName      :                                                                                     
DispLastCallPeersNumber           :                                                                                     
DispLastCallStartTime             : 30.12.1899 00:00:00                                                                 
DispLastCallFinishedTime          : 30.12.1899 00:00:00                                                                 
DispGetIncomingExtension          :                                                                                     
DispGetOutgoingExtension          : 400                                                                                 
DispIsOutgoingCall                : 0                                                                                   
DispLastCallIsOutgoingCall        : 0                                                                                   
DispLastCallDiscReason            : 0                                                                                   
DispLastCallWasConnected          : 0                                                                                   
DispCallId                        : 0                                                                                   
DispLastCallId                    : 0                                                                                   
DispCallHistory                   : {}                                                                                  
DispLastCallHistory               : {}                                                                                  
DispReceivedDtmfDigits            :

If you want ot see what methods and properties the line object supports, just use get-member:

PS>$l | get-member                                                                                                      
TypeName: System.__ComObject#{f8e5536c-4c00-11d3-80bc-00105a653379}                                                  
Name                              MemberType   Definition                                                               
----                              ----------   ----------                                                               
DispActivate                      Method       void DispActivate ()                                                     
DispDial                          Method       void DispDial (string)                                                   
DispDirectCall                    Method       void DispDirectCall ()                                                   
DispEnable                        Method       void DispEnable (int)                                                    
DispForwardCall                   Method       void DispForwardCall (string)                                            
DispHold                          Method       void DispHold ()                                                         
DispHookOff                       Method       void DispHookOff ()                                                      
DispHookOffEx                     Method       void DispHookOffEx (string, int, string)                                 
DispHookOn                        Method       void DispHookOn ()                                                       
DispJoinConference                Method       void DispJoinConference (IDispatch)                                      
DispPlaySoundFile                 Method       void DispPlaySoundFile (string, int, int)                                
DispPressHook                     Method       void DispPressHook ()                                                    
DispRecordSoundFile               Method       void DispRecordSoundFile (string, int)                                   
DispRequestCallbackAuto           Method       void DispRequestCallbackAuto ()                                          
DispSetMediastreamingLink         Method       void DispSetMediastreamingLink (string)                                  
DispStartRecording                Method       void DispStartRecording ()                                               
DispStopPlaySoundFile             Method       void DispStopPlaySoundFile ()                                            
DispStopRecording                 Method       void DispStopRecording ()                                                
DispStopRecordSoundFile           Method       void DispStopRecordSoundFile ()                                          
DispTransferCall                  Method       void DispTransferCall (IDispatch)                                        
DispAcknowledgedDialstring        Property     string DispAcknowledgedDialstring () {get}                               
DispCalledExtension               Property     string DispCalledExtension () {get}                                      
DispCalledName                    Property     string DispCalledName () {get}                                           
DispCallHistory                   Property     IDispatch DispCallHistory () {get}                                       
DispCallId                        Property     int DispCallId () {get}                                                  
DispCallWasRedirected             Property     int DispCallWasRedirected () {get}                                       
DispChargingDetails               Property     string DispChargingDetails () {get}                                      
DispConnectionFinishedTime        Property     Date DispConnectionFinishedTime () {get}                                 
DispConnectionStartTime           Property     Date DispConnectionStartTime () {get}                                    
DispDiscReason                    Property     int DispDiscReason () {get}                                              
DispGetIncomingExtension          Property     string DispGetIncomingExtension () {get}                                 
DispGetOutgoingExtension          Property     string DispGetOutgoingExtension () {get}                                 
DispIsDirectCall                  Property     int DispIsDirectCall () {get}                                            
DispIsGroupCall                   Property     int DispIsGroupCall () {get}                                             
DispIsOutgoingCall                Property     int DispIsOutgoingCall () {get}                                          
DispLastCallChargingDetails       Property     string DispLastCallChargingDetails () {get}                              
DispLastCallDiscReason            Property     int DispLastCallDiscReason () {get}                                      
DispLastCallExtension             Property     string DispLastCallExtension () {get}                                    
DispLastCallFinishedTime          Property     Date DispLastCallFinishedTime () {get}                                   
DispLastCallHistory               Property     IDispatch DispLastCallHistory () {get}                                   
DispLastCallId                    Property     int DispLastCallId () {get}                                              
DispLastCallIsOutgoingCall        Property     int DispLastCallIsOutgoingCall () {get}                                  
DispLastCallLcrPrefix             Property     string DispLastCallLcrPrefix () {get}                                    
DispLastCallPeersNumber           Property     string DispLastCallPeersNumber () {get}                                  
DispLastCallPeersPbxUserName      Property     string DispLastCallPeersPbxUserName () {get}                             
DispLastCallStartTime             Property     Date DispLastCallStartTime () {get}                                      
DispLastCallWasConnected          Property     int DispLastCallWasConnected () {get}                                    
DispNuberOfConferenceParticipants Property     int DispNuberOfConferenceParticipants () {get}                           
DispPeerName                      Property     string DispPeerName () {get}                                             
DispPeerNumber                    Property     string DispPeerNumber () {get}                                           
DispReceivedDtmfDigits            Property     string DispReceivedDtmfDigits () {get}                                   
DispRedirectedFromName            Property     string DispRedirectedFromName () {get}                                   
DispRedirectedFromNumber          Property     string DispRedirectedFromNumber () {get}                                 
DispState                         Property     int DispState () {get}

Now hook off, dial a number and look at the line object again

PS>$l.DispHookOff()                                                                                                     
PS>$l.DispDial("202")                                                                                                   
PS>$l                                                                                                                   
DispState                         : 5                                                                                   
DispAcknowledgedDialstring        : 202                                                                                 
DispPeerNumber                    : 202                                                                                 
DispPeerName                      : (call routing) Conference                                                           
DispCalledExtension               :                                                                                     
DispCalledName                    :                                                                                     
DispIsDirectCall                  : 0                                                                                   
DispCallWasRedirected             : 0                                                                                   
DispIsGroupCall                   : 0                                                                                   
DispRedirectedFromNumber          :                                                                                     
DispRedirectedFromName            :                                                                                     
DispChargingDetails               :                                                                                     
DispNuberOfConferenceParticipants : 0                                                                                   
DispDiscReason                    : 0                                                                                   
DispConnectionStartTime           : 30.12.1899 00:00:00                                                                 
DispConnectionFinishedTime        : 30.12.1899 00:00:00                                                                 
DispLastCallLcrPrefix             :                                                                                     
DispLastCallExtension             :                                                                                     
DispLastCallChargingDetails       :                                                                                     
DispLastCallPeersPbxUserName      :                                                                                     
DispLastCallPeersNumber           :                                                                                     
DispLastCallStartTime             : 30.12.1899 00:00:00                                                                 
DispLastCallFinishedTime          : 30.12.1899 00:00:00                                                                 
DispGetIncomingExtension          :                                                                                     
DispGetOutgoingExtension          : 400                                                                                 
DispIsOutgoingCall                : 1                                                                                   
DispLastCallIsOutgoingCall        : 1                                                                                   
DispLastCallDiscReason            : 0                                                                                   
DispLastCallWasConnected          : 0                                                                                   
DispCallId                        : 139                                                                                 
DispLastCallId                    : 0                                                                                   
DispCallHistory                   : {}                                                                                  
DispLastCallHistory               : {}                                                                                  
DispReceivedDtmfDigits            :

Now hook on and display the line properties again:

PS>$l                                                                                                                   
DispState                         : 0                                                                                   
DispAcknowledgedDialstring        :                                                                                     
DispPeerNumber                    :                                                                                     
DispPeerName                      :                                                                                     
DispCalledExtension               :                                                                                     
DispCalledName                    :                                                                                     
DispIsDirectCall                  : 0                                                                                   
DispCallWasRedirected             : 0                                                                                   
DispIsGroupCall                   : 0                                                                                   
DispRedirectedFromNumber          :                                                                                     
DispRedirectedFromName            :                                                                                     
DispChargingDetails               :                                                                                     
DispNuberOfConferenceParticipants : 0                                                                                   
DispDiscReason                    : 0                                                                                   
DispConnectionStartTime           : 30.12.1899 00:00:00                                                                 
DispConnectionFinishedTime        : 30.12.1899 00:00:00                                                                 
DispLastCallLcrPrefix             :                                                                                     
DispLastCallExtension             : 400                                                                                 
DispLastCallChargingDetails       :                                                                                     
DispLastCallPeersPbxUserName      : (call routing) Conference                                                           
DispLastCallPeersNumber           : 202                                                                                 
DispLastCallStartTime             : 16.06.2007 10:57:07                                                                 
DispLastCallFinishedTime          : 16.06.2007 10:57:15                                                                 
DispGetIncomingExtension          :                                                                                     
DispGetOutgoingExtension          : 400                                                                                 
DispIsOutgoingCall                : 0                                                                                   
DispLastCallIsOutgoingCall        : 1                                                                                   
DispLastCallDiscReason            : 0                                                                                   
DispLastCallWasConnected          : 1                                                                                   
DispCallId                        : 0                                                                                   
DispLastCallId                    : 139                                                                                 
DispCallHistory                   : {}                                                                                  
DispLastCallHistory               : {, (call routing) Conference, , }                                                   
DispReceivedDtmfDigits            :

This should get you an idea how easy it is with Powershell to find out how the SwyxIt API works and what the different object properties contain even without consulting the API doc.

 

 

Tags:

 

2 comment(s) so far...

Re: SwyxIt API and Windows Powershell

Do you think it would be possible to use powershell with swyx and poll for a incoming call? When the call come in the script would fire

By Andrew Hall on  17.09.2007 13:29

Re: SwyxIt API and Windows Powershell

I doubt it'll work using the automatic COM wrapper (new-object -com). It should be possible using an interop assembly, but I havn't tried it, yet. I'll let you know when I have more information

By Martin on  17.09.2007 20:38

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment  Cancel 
Blog Help
Sponsors