[Updated] Auto dial with Microsoft Teams

I’ve released a blog post about auto dialing with Microsoft Teams in 2020. A user has commented that the tool AutoHotkey in Version 2.0 is not working any longer with my script. The script is written for AutoHotkey Version 1.0 and the publisher of the software changed the script language in the latest version. Therefor the user asked if I could write an updated script. For me, enough reasons to write an updated blog post about how to auto dial a phone number with Microsoft Teams.


The first step is still the same as in my first blog post. You need to link the tel:-protocol in your default app configuration of your OS with Microsoft Teams. You can find two options to achieve it here in my blog post.

Step 2: Using AutoHotkey to dial a phone number with Microsoft Teams

First, you need to install the AutoHotkey software in version 2.0. You can download it form the publisher’s website and install it. When you install the software for all users, you need to start the installer as an Administrator of the system.

Auto dial with Microsoft Teams - screenshot of AutoHotkey installation wizard

Next, you need to write the AHK script and it can be done the easiest from the AutoHotkey Dash app. Click on New script and the wizard starts with some questions about the script name and storage location. Also, you can select to start with an empty file or a one liner #Requires v2.0.

Auto dial with Microsoft Teams - screenshot of New scipt wizard in AutoHotkey

When you click on Create, the program will create the file and open the Windows Explorer with the file location. When you click on Edit, the configured editor program will start, and you can begin to write your AHK script directly.

Go to the publisher’s website to learn more about the different program settings or the script language itself.

When you already created the AHK script, you can go the specified file location and open it directly with your preferred editor.

In comparison to my first blog post, I wrote this time a more powerful script. It is using regex to detect some different notations of phone numbers and do a normalization to E.164, which is our supported notation for Microsoft Teams.

Depending on your country code, you need to change it in the script or you can add more normalization rules to it.

; mark the phone number and press Ctrl+3
; Copy phone number to clipboard, normalize it and send it to Microsoft Teams
; normalizing includes

^3::
{

	A_Clipboard := ""
	send "^c"
	Clipwait 
	A_Clipboard := StrReplace(A_Clipboard, "`r`n")

	; Remove spaces
	A_Clipboard := StrReplace(A_Clipboard, A_Space)

	; Removes -, for example "01234 - 123456789" -> "01234123456789"
	A_Clipboard := StrReplace(A_Clipboard, "-")

	; removes () in Phone numbera, for example "(01234)1234567" -> 01234 1234567
	A_Clipboard := RegExReplace(A_Clipboard, "(.*)[(](\d*)[)](.*)","$1$2$3")

	; replace starting 00 by +, for example "0049123456" -> "+49123456"
	A_Clipboard := RegExReplace(A_Clipboard, "^(00)([1-9]\d*$)","+$2")

	; replace starting 0 by +49, for example "0123 123456" -> +49123123456 (please customize Country code)
	A_Clipboard := RegExReplace(A_Clipboard, "^(0)([1-9]\d*$)","+49$2")
	;MsgBox A_Clipboard
	Run "tel:" A_Clipboard
}

To start AutoHotkey with the script, just double click the script file from your Windows Explorer. When you update the script, don’t forget to search the AutoHotkey icon in your tray bar, make a right click on it and select Reload script. Otherwise, the new script version will be loaded only at the next program start.

Auto dial with Microsoft Teams -screenshot of the AutoHotkey tray icon menu

The script will copy the marked text to your clipboard, removes some special characters, replaces a leading null and start Microsoft Teams with the normalized number.

Fortunately, the AutoHotkey script works with the classic Microsoft Teams client, but also with new Microsoft Teams client 2.x

AutoHotkey – publisher website

Leave a Reply

Your email address will not be published. Required fields are marked *