Skip to content

Commit

Permalink
Update Teams_ClearCache
Browse files Browse the repository at this point in the history
Update Teams_ClearCache
Fix Jxon_Load("":true)
  • Loading branch information
Thierry Dalon committed Nov 22, 2023
1 parent 49a9136 commit 9a2b5ac
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 42 deletions.
3 changes: 2 additions & 1 deletion Lib/Jxon.ahk
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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")
Expand Down
1 change: 0 additions & 1 deletion Lib/Outlook.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ If WinExist("ahk_id " . NewEdgeWinId) {
Send ^w ; Close leftover browser window
}


; Click on join button
If (autoJoin) {
UIA := UIA_Interface()
Expand Down
103 changes: 65 additions & 38 deletions Lib/Teams.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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

; -------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -2587,45 +2591,68 @@ 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
}
}
}

TrayTip TeamsShortcuts: ERROR, Leave button UIA Element not found!,,0x2
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"){

Expand Down
4 changes: 2 additions & 2 deletions Lib/Teamsy.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions docs/_pages/Teams-Shortcuts-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docs/_pages/Teamsy-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9a2b5ac

Please sign in to comment.