From 9a2b5acecb84ab2d7da92b1c76025bf712f08cd1 Mon Sep 17 00:00:00 2001 From: Thierry Dalon Date: Wed, 22 Nov 2023 20:01:53 +0100 Subject: [PATCH] Update Teams_ClearCache Update Teams_ClearCache Fix Jxon_Load("":true) --- Lib/Jxon.ahk | 3 +- Lib/Outlook.ahk | 1 - Lib/Teams.ahk | 103 ++++++++++++++--------- Lib/Teamsy.ahk | 4 +- docs/_pages/Teams-Shortcuts-Changelog.md | 2 + docs/_pages/Teamsy-Changelog.md | 2 + 6 files changed, 73 insertions(+), 42 deletions(-) diff --git a/Lib/Jxon.ahk b/Lib/Jxon.ahk index 410efa3..f2129a5 100644 --- a/Lib/Jxon.ahk +++ b/Lib/Jxon.ahk @@ -1,4 +1,5 @@ ; From https://github.com/cocobelgica/AutoHotkey-JSON +; Includes fix https://github.com/cocobelgica/AutoHotkey-JSON/issues/11 Jxon_Load(ByRef src, args*) { static q := Chr(34) @@ -117,7 +118,7 @@ Jxon_Load(ByRef src, args*) ; SOMETIMES return strings due to certain optimizations. Since it ; is just 'SOMETIMES', numerify to be consistent w/ v2.0-a else if (val == "true" || val == "false") - val := %value% + 0 + val := %val% + 0 ; TD ; AHK_H has built-in null, can't do 'val := %value%' where value == "null" ; as it would raise an exception in AHK_H(overriding built-in var) else if (val == "null") diff --git a/Lib/Outlook.ahk b/Lib/Outlook.ahk index 89d3bc2..8996a24 100644 --- a/Lib/Outlook.ahk +++ b/Lib/Outlook.ahk @@ -324,7 +324,6 @@ If WinExist("ahk_id " . NewEdgeWinId) { Send ^w ; Close leftover browser window } - ; Click on join button If (autoJoin) { UIA := UIA_Interface() diff --git a/Lib/Teams.ahk b/Lib/Teams.ahk index 97db00e..edd6c24 100644 --- a/Lib/Teams.ahk +++ b/Lib/Teams.ahk @@ -2331,9 +2331,20 @@ Run, %sUrl% ; ------------------------------------------------------------------------------------------------------------------- ; ------------------------------------------------------------------------------------------------------------------- -Teams_ClearCache(){ +Teams_GetCacheDir(IsNew := true) { +; CacheDir := Teams_GetCacheDir() +If IsNew() { + ; %localappdata%\packages\MSTeams_8wekyb3d8bbwe\Localcache\Microsoft\MSTeams + TeamsDir := RegExReplace(A_AppData,"\\[^\\]*$") . "\Local\packages\MSTeams_8wekyb3d8bbwe\Localcache\Microsoft\MSTeams" +} Else { + TeamsDir = %A_AppData%\Microsoft\Teams +} +} ; eofun + + +Teams_ClearCache(){ ; @fun_teams_clearcache@ If GetKeyState("Ctrl") { - Teamsy_Help("cl") + Teamsy_Help("clc") return } @@ -2354,14 +2365,13 @@ Teams_ClearCache(){ ; Delete Folders and Files in Cache Directory If IsNew { ; https://microsoft365pro.co.uk/2023/07/31/teams-real-simple-with-pictures-clear-cache-in-teams-2-1-client/ @Microsoft365Pro - TeamsDir := RegExReplace(A_AppData,"\\[^\\]*$") . "\Local\packages\MSTeams_8wekyb3d8bbwe\Localcache\Microsoft\MSTeams" ; AppData env variable points to Roaming - /* - FileRemoveDir, %TeamsDir%\EBWebView, 1 - FileRemoveDir, %TeamsDir%\Logs, 1 - */ + TeamsDir := RegExReplace(A_AppData,"\\[^\\]*$") . "\Local\packages\MSTeams_8wekyb3d8bbwe\Localcache\Microsoft\MSTeams" ; AppData env variable points to Roaming + FileRecycle, %TeamsDir%\EBWebView + FileRecycle, %TeamsDir%\Logs + FileRecycle, %TeamsDir%\*.dat64 + FileRecycle, %TeamsDir%\*.json } Else { ; Teams Classic ; https://learn.microsoft.com/en-us/microsoftteams/troubleshoot/teams-administration/clear-teams-cache TeamsDir = %A_AppData%\Microsoft\Teams - /* FileRemoveDir, %TeamsDir%\application cache\cache, 1 FileRemoveDir, %TeamsDir%\blob_storage, 1 FileRemoveDir, %TeamsDir%\databases, 1 @@ -2370,26 +2380,20 @@ Teams_ClearCache(){ FileRemoveDir, %TeamsDir%\Indexeddb, 1 FileRemoveDir, %TeamsDir%\Local Storage, 1 FileRemoveDir, %TeamsDir%\tmp, 1 - */ } - - ; TODO do not clear Backgrounds\Uploads - - FileRecycle, %TeamsDir%\* - Teams_GetMainWindow() } ; eofun ; ------------------------------------------------------------------------------------------------------------------- ; ------------------------------------------------------------------------------------------------------------------- -Teams_CleanRestart(){ +Teams_CleanRestart(){ ; @fun_teams_cleanrestart@ If GetKeyState("Ctrl") { sUrl := "https://tdalon.blogspot.com/2021/01/teams-clear-cache.html" Run, "%sUrl%" return } ; Warning all appdata will be deleted -MsgBox, 0x114,Teams Clean Restart, Are you sure you want to delete all Teams Client local application data? +MsgBox, 0x114,Teams Clean Restart, Are you sure you want to delete all Teams Client local application data? (incl. custom Backgrounds) IfMsgBox No return @@ -2402,10 +2406,10 @@ If (ErrorLevel) { While WinExist("ahk_exe " . TeamsExe) Sleep 500 -TeamsDir = %A_AppData%\Microsoft\Teams -FileRemoveDir, %TeamsDir%, 1 - -Teams_GetMainWindow() +TeamsDir = Teams_GetCacheDir(Teams_IsNew()) +;FileRemoveDir, %TeamsDir%, 1 +FileRecycle, %TeamsDir%\* +Teams_GetMainWindow() ; will restart Teams } ; eofun ; ------------------------------------------------------------------------------------------------------------------- @@ -2587,19 +2591,28 @@ Teams_MeetingLeave(mode:="?") { ; @fun_teams_meetingleave@ Els := TeamsEl.FindAllByNameAndType("More options","Button") ; Name More options ; AutomationId changing menuddd for i, El in Els If InStr(El.ClassName,"SplitButton") { ; - ; ClassName =fui-Button rlr4yyk fui-MenuButton fui-SplitButton__menuButton toggleButton ___z3kncc0 f1sbtcvk fwiuce9 fdghr9 f15vdbe4 fwbmr0d f44c6la frrbwxo f1um7c6d f6pwzcr fdl5y0r f1p3nwhy f11589ue f1q5o8ev f1pdflbu fonrgv7 f5k7jbu f1s2uweq fr80ssc f1ukrpxl fecsdlb fhhy8jn fqwlww5 f1bbhs8t f1i3by9 fbb8suj f1sw78cg f1vj5d8e f1udo9fm f1hoz3np - El.Click() ; Click element without moving the mouse - EndEl:=TeamsEl.WaitElementExistByName("End meeting",,,,2000) - If (EndEl) and (mode="e") - GoTo EndMeeting - Else If (mode="?") { - MsgBox, 0x24, End Meeting?,Do you want to End the meeting? - IfMsgBox Yes + ; ClassName =fui-Button rlr4yyk fui-MenuButton fui-SplitButton__menuButton toggleButton ___z3kncc0 f1sbtcvk fwiuce9 fdghr9 f15vdbe4 fwbmr0d f44c6la frrbwxo f1um7c6d f6pwzcr fdl5y0r f1p3nwhy f11589ue f1q5o8ev f1pdflbu fonrgv7 f5k7jbu f1s2uweq fr80ssc f1ukrpxl fecsdlb fhhy8jn fqwlww5 f1bbhs8t f1i3by9 fbb8suj f1sw78cg f1vj5d8e f1udo9fm f1hoz3np + El.Click() ; Click element without moving the mouse + EndEl:=TeamsEl.WaitElementExistByName("End meeting",,,,2000) + If (EndEl) and (mode="e") GoTo EndMeeting - Else { - TeamsEl.FindFirstBy("AutomationId=splitButton-ddd__primaryActionButton").Click() - GoTo Finish - } + Else If (mode="?") { + OnMessage(0x44, "OnLeaveMsgBox") + MsgBox, 0x23, Leave End Meeting,Do you want to End or Leave the meeting? + OnMessage(0x44, "") + IfMsgBox Cancel + { + El.Click() + WinActivate, ahk_id %curWinId% + return + } + + IfMsgBox Yes ; End + GoTo EndMeeting + Else { ; Leave + TeamsEl.FindFirstBy("AutomationId=splitButton-ddd__primaryActionButton").Click() + GoTo Finish + } } } @@ -2607,25 +2620,39 @@ Teams_MeetingLeave(mode:="?") { ; @fun_teams_meetingleave@ return + EndMeeting: EndEl.Click() - EndEl:=TeamsEl.WaitElementExistByNameAndType("End","Button",,3,,2000) ; exact match + EndEl:=TeamsEl.WaitElementExistByNameAndType("End","Button",,3,,2000) ; exact match ; TODO Lang specific EndEl.Click() Finish: + ; Reset FocusAssistant + FocusAssist(-) + + ; Restore previous window + WinActivate, ahk_id %curWinId% + ; Dismiss Call Quality Window El:=TeamsEl.WaitElementExist("AutomationId=cqf-dismiss-button",,,,1000) If El El.Click() - - ; Restore previous window - WinActivate, ahk_id %curWinId% - ; Reset FocusAssistant - FocusAssist(-) + } ; eofun + +OnLeaveMsgBox() { + DetectHiddenWindows, On + Process, Exist + If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) { + ControlSetText Button1, End + ControlSetText Button2, Leave + } +} + + ; ------------------------------------------------------------------------------------------------------------------- Teams_PushToTalk(KeyName:="MButton"){ diff --git a/Lib/Teamsy.ahk b/Lib/Teamsy.ahk index debe510..7802bb7 100644 --- a/Lib/Teamsy.ahk +++ b/Lib/Teamsy.ahk @@ -220,7 +220,7 @@ Case "re","restart": ; restart Case "clean": ; clean restart Teams_CleanRestart() return -Case "clear","cache","cl": ; clear cache +Case "clear","cache","cl","clc": ; clear cache Teams_ClearCache() return Case "nm": ; new meeting @@ -362,7 +362,7 @@ Case "bg": sUrl := "https://tdalon.blogspot.com/2023/11/teams-set-background.html" Case "obg","cbg": sUrl := "https://tdalon.blogspot.com/2021/01/teams-custom-backgrounds.html" -Case "cl": ; clear cache +Case "cl","clc": ; clear cache sUrl := "https://tdalon.blogspot.com/2021/01/teams-clear-cache.html" Case "2": ; second instance sUrl := "https://tdalon.blogspot.com/2020/12/open-multiple-microsoft-teams-instances.html" diff --git a/docs/_pages/Teams-Shortcuts-Changelog.md b/docs/_pages/Teams-Shortcuts-Changelog.md index 74859b3..b407258 100644 --- a/docs/_pages/Teams-Shortcuts-Changelog.md +++ b/docs/_pages/Teams-Shortcuts-Changelog.md @@ -8,6 +8,8 @@ excerpt: "Release notes for Teams Shortcuts PowerTool." Some changes listed here also impact the [Teamsy Launcher](Teamsy-Launcher) features. +* 2023-11-22 + * Improved Teams_MeetingLeave: prompt for End or Leave * 2023-11-03 * [Set meeting background](https://tdalon.blogspot.com/2023/11/teams-set-background.html) * 2023-10-27 diff --git a/docs/_pages/Teamsy-Changelog.md b/docs/_pages/Teamsy-Changelog.md index 2c8f689..2651967 100644 --- a/docs/_pages/Teamsy-Changelog.md +++ b/docs/_pages/Teamsy-Changelog.md @@ -8,6 +8,8 @@ excerpt: "Release notes for Teamsy and Teamsy Launcher PowerTools." See also [Teams Shortcuts Changelog](Teams-Shortcuts-Changelog) for other relevant changes. +* 2023-11-22 + * Improved Teams_MeetingLeave: prompt for End or Leave * 2023-11-20 * Bug Fix Teams Meeting Share Hide Sharing Control Bar * 2023-11-16