how to sync text from win11 to mac

I have a win 11 virtual desktop. I am able to remote desktop to it on my mac, but company disable clipbard sync.
disable clipbard, so when I try to sync my copy from win11 to mac, it is very tedious. I would paste it to a file in my onedrive or send it via slack. after repeat this procedure multiple times, I feel this is not very convenient.

solution

I am not able to install AHK on this win11 because company policy, what left for me is power-shell. I wrote a powershell script as such:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Add-Type -AssemblyName System.Windows.Forms

try {
# Get the clipboard content
$clipContent = Get-Clipboard

# Specify the file path in your OneDrive folder
$filePath = $my_onedrive_folder/my_file_in_onedrive

# Append the clipboard content to the file
Add-Content -Path $filePath -Value $clipContent

# Notify the user (optional)
[System.Windows.Forms.MessageBox]::Show("Clipboard content appended to OneDrive file.")
} catch {
# Log the error to a file
$errorMessage = $_.Exception.Message
$errorFilePath = $my_onedrive_folder/document/error_log.txt"
Add-Content -Path $errorFilePath -Value $errorMessage
}

after that, I try to alloate a shortcut for it. as such:
clipboard2

then I can press ctrl+shift+v to paste content to the file in onedrive. then onedrive would sync the text to my mac.

after that, I wrote a small script on my mac:

1
2
#!/bin/bash
tail -F ~/OneDrive\ -\ BP/Documents/1.txt | while read line; do echo "$line" | pbcopy; done

then that make things a little more convenient!