Can't use three-finger middle-click in remote desktop

I have a HP laptop. I configured 3-finger tap to simulate a middle click, and it works fine locally on the laptop. However, when I connect to my desktop using Remote Desktop and I try to use the 3-finger tap in the remote session, it instead opens a side panel titled "Project" saying "We can't change the display topology during a remote connection".

The remote computer is a desktop (no touchpad). Both computers are running Windows 10.

How can I get the middle-click functionality in the remote session?


tl;dr: Try using the AutoHotkey script at the end.

I'm on a Lenovo ThinkPad T570, your mileage may vary.

I opened AutoHotkey to see what happens when I touch the touchpad with three fingers. This is what happens on the client side:

VK  SC  Type    Up/Dn   Elapsed Key     
----------------------------------------
5B  05B a   d   6.61    LWin            
A2  01D a   d   0.00    LControl        
A0  02A a   d   0.00    LShift          
85  06D a   d   0.00    F22             
85  06D a   u   0.00    F22             
A0  02A a   u   0.00    LShift          
A2  01D a   u   0.00    LControl        
5B  05B a   u   0.00    LWin            

A three-finger touch is translated to a Left Win + Left Control + Left Shift + F22 key combination. (The OS recognizes F22 key even if it's not present on any physical keyboard I know of.)

This is what happens on the server side:

VK  SC  Type    Up/Dn   Elapsed Key     
----------------------------------------
5B  15B     d   21.77   LWin            
A2  01D     d   0.00    LControl        
A0  02A     d   0.00    LShift          
A0  02A     u   0.00    LShift          ¹
A2  01D     u   0.00    LControl        ²
85  06D h   d   0.00    F22             
85  06D h   u   0.00    F22             
A0  02A     u   0.00    LShift          
A2  01D     u   0.00    LControl        
5B  15B     u   0.00    LWin            
...                 
5B  15B     d   0.64    LWin            
A2  01D     d   0.00    LControl        
A0  02A     d   0.00    LShift          
A0  02A     u   0.00    LShift          ¹
85  06D h   d   0.00    F22             
85  06D h   u   0.00    F22             
A0  02A     u   0.00    LShift          
A2  01D     u   0.00    LControl        
5B  15B     u   0.00    LWin            

As you can see, the ficticious Shift is always released¹ before presssing F22, and the Ctrl key is sometimes released² before pressing the F22.

Running the following AutoHotkey script on the Remote Desktop server translates the relevant key combinations to a Middle Mouse Button click:

#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.

<#F22::MButton  ; Left Win + F22
<#<^F22::MButton  ; Left Win + Left Ctrl + F22

You may want to try adding key combinations including Left Shift (<+) if this doesn't work reliably for you.