Need to add a shed load of contacts to Skype for Business - AutoHotKey to the rescue!

A customer had the need to add approx 200 external contacts to a single Skype for Business user where there was no access to the backend database or PowerShell.

To do this I went back in the mists of time and cracked open a copy of AutoHotKey....

.....well, I did once I disabled Windows Defender:

So now I've got it downloaded and installed lets get on with the show:

We have two files:

  • Adds.txt which contains the sipuri's of all people you want to add (these can be people in your organisation and external).
  • ContactsAdd.ahk which is the actual code.

You can download these both from my DropBox (no love for OneDrive now they have curtailed the amount of free space!), but the code is here if you want to play with it by hand.

Note that this is very rough and ready code so probably could be tidied up considerably. Usual warranties apply, test in a lab, not for production use, YMMV, don't eat yellow snow. etc. etc.

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

;start SfB/Lync
run, Lync.exe

;bring SfB to the foregroud - change this if using Lync 2010 or 2013 in "classic" mode
winwaitactive, Skype for Business 

;start a loop and open adds.txt for reading
loop, read, adds.txt
;read the first line of the file and fill a variable called A-LoopReadLine with the file
loop, parse, A_LoopReadLine, %A_Tab%
;send some tabs, spaces, down keys etc to get to "add a contact not in my organisation"
send, {Tab}{Tab}{Tab}{Tab}{Tab}{Space}{Down}{Enter}{Enter}
;send the contents of the variable to SfB
Send, %A_LoopReadLine%
;Hit enter
send, {Enter}
;Move from Contacts tab to next tab....
Send, {Control Down} 2 {control Up}
;....and back again
Send, {Control Down} 1 {control Up}
;Loops round until the end of the file

No comments:

Post a Comment