Created
October 20, 2023 14:41
-
-
Save tdalon/6181ab7bf62916b7ffcc4d0526c5277b to your computer and use it in GitHub Desktop.
Import Teams meeting background files in Teams New
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Teams_BackgroundImport(srcDir:=""){ | |
; https://techcommunity.microsoft.com/t5/microsoft-teams-public-preview/backgrounds/m-p/3782690 | |
If GetKeyState("Ctrl") { | |
Teamsy_Help("bgi") | |
return | |
} | |
If !Teams_IsNew() | |
{ | |
return | |
} | |
If (srcDir = "") { ; prompt user to select directory | |
srcDir = %A_AppData%\Microsoft\Teams\Backgrounds\Uploads | |
SelectFolder(srcDir,"Select folder from which to import background images:") | |
;FileSelectFolder, srcDir , ,0 , Select folder from which to import background images: | |
If ErrorLevel | |
return | |
} | |
EnvGet, LOCALAPPDATA, LOCALAPPDATA | |
NewBackgroundDir = %LOCALAPPDATA%\Packages\MSTeams_8wekyb3d8bbwe\LocalCache\Microsoft\MSTeams\Backgrounds\Uploads | |
If !FileExist(NewBackgroundDir) | |
FileCreateDir, %NewBackgroundDir% | |
; Generate array of MD5 checksums for background files | |
ArrayCount := 0 | |
MD5Array := [] | |
Loop, Files, %NewBackgroundDir%\* | |
{ | |
If InStr(A_LoopFileName,"_thumb.") | |
Continue | |
ArrayCount += 1 | |
MD5Array[ArrayCount] := HashFile(A_LoopFileFullPath,"MD5") | |
} | |
If !pToken := Gdip_Startup() | |
{ | |
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system | |
return | |
} | |
BgCount := 0 | |
BgCopiedCount :=0 | |
Loop, Files, %srcDir%\* | |
{ | |
; Skip files ending with _thumb. | |
If InStr(A_LoopFileName,"_thumb.") | |
Continue | |
BgCount +=1 | |
; Check if file already exist | |
srcMD5 := HashFile(A_LoopFileFullPath,"MD5") | |
If HasVal(MD5Array,srcMD5) | |
Continue | |
BgCopiedCount +=1 | |
; Generate GUID | |
GUID := CreateGUID() | |
GUID := SubStr(GUID,2,-1) | |
StringLower, GUID, GUID | |
; Create Thumbnails using Gdip | |
pBitmap := Gdip_CreateBitmapFromFile(A_LoopFileFullPath) | |
pThumbnail := Gdip_GetImageThumbnail(pBitmap, 278, 159) | |
RegExMatch(A_LoopFileName,"\.([^\.]*$)",FileExt) | |
FileCopy, %A_LoopFileFullPath%, %NewBackgroundDir%\%GUID%.%FileExt1% | |
; Save Thumbnail | |
DestFile = %NewBackgroundDir%\%GUID%_thumb.%FileExt1% | |
Gdip_SaveBitmapToFile(pThumbnail, DestFile) | |
} | |
TrayTip Backgrounds imported! , %BgCopiedCount%/%BgCount% backgrounds were copied! | |
Run, %NewBackgroundDir% | |
Gdip_DisposeImage(pBitmap) | |
Gdip_DisposeImage(pThumbnail) | |
Gdip_Shutdown(pToken) | |
} ; eofun |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See explanation https://tdalon.blogspot.com/2023/10/teams-import-background.html