Skip to content

Commit

Permalink
fix listbox change
Browse files Browse the repository at this point in the history
  • Loading branch information
Thierry Dalon committed Dec 3, 2023
1 parent 35e59ef commit 84721da
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
25 changes: 16 additions & 9 deletions Lib/ListBox.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
; AutoResize: https://www.autohotkey.com/boards/viewtopic.php?style=17&t=1403
; -------------------------------------------------------------------------------

ListBox(Title := "", Prompt := "", List := "", Select := 0, AlwaysOnTop := True) {
ListBox(Title := "", Prompt := "", List := "", Select := 0, AlwaysOnTop := True,returnIndex := False ) {
; LB := ListBox(Title := "", Prompt := "", List := "", Select := 0, AlwaysOnTop := True)
;-------------------------------------------------------------------------------
; show a custom input box with a ListBox control
; return the text of the selected item. Empty if cancelled
; return the index of the selected item. Empty if cancelled
;---------------------------------------------------------------------------
; Title is the title for the GUI
; Prompt is the text to display
Expand All @@ -22,12 +22,19 @@ Gui, -MinimizeBox
If Prompt ; not empty
Gui, Add, Text,, %Prompt%

Loop Parse, List,|
Loop Parse, List,|
{
rCnt++
Gui, Add, ListBox, r%rCnt% vLB hwndHLB Choose%Select%, %List%
maxsize := StrLen(A_LoopField) > maxsize ? StrLen(A_LoopField) : maxsize
}
boxwidth := maxsize * 5
If returnIndex
Gui, Add, ListBox, +AltSubmit w%boxwidth% r%rCnt% vLB hwndHLB Choose%Select%, %List%
Else
Gui, Add, ListBox, w%boxwidth% r%rCnt% vLB hwndHLB Choose%Select%, %List%

W := LB_EX_CalcWidth(HLB)
GuiControl, Move, HLB, w%W% ; h%H%
;W := LB_EX_CalcWidth(HLB)
;GuiControl, Move, HLB, w%W% ; h%H%

Gui, Add, Button, w60 Default, &OK
Gui, Add, Button, x+m wp, &Cancel
Expand Down Expand Up @@ -78,9 +85,9 @@ LB_EX_CalcWidth(HLB) { ; calculates the width of the list box needed to show the
Loop, Parse, Items, `n
{
Txt := A_LoopField
DllCall("Gdi32.dll\GetTextExtentPoint32", "Ptr", HDC, "Ptr", &Txt, "Int", StrLen(Txt), "Ptr", &Size)
If (W := NumGet(SIZE, 0, "Int")) > MaxW
MaxW := W
DllCall("Gdi32.dll\GetTextExtentPoint32", "Ptr", HDC, "Ptr", &Txt, "Int", StrLen(Txt), "UIntP", Width)
If (Width > MaxW)
MaxW := Width
}
DllCall("User32.dll\ReleaseDC", "Ptr", HLB, "Ptr", HDC)
Return MaxW + 8 ; + 8 for the margins
Expand Down
43 changes: 18 additions & 25 deletions Lib/Teams.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -2015,8 +2015,6 @@ Loop %Win% {
WinId := Win%A_Index%
; WinActivate, ahk_id %WinId%
TeamsEl := UIA.ElementFromHandle(WinId)

;MsgBox % TeamsEl.Name

If Teams_IsMeetingWindow(TeamsEl) {
If (!Minimize)
Expand All @@ -2036,8 +2034,26 @@ If (showTrayTip)

; -------------------------------------------------------------------------------------------------------------------

Teams_IsMeetingWindow(TeamsEl,ExOnHold:=true){
; does not return true on Share / Call in progress window

; If Meeting Reactions Submenus are opened AutomationId are not visible.

If (ExOnHold) {
Name := Teams_GetLangName("Resume","Resume")
If (Name="")
return
}

If TeamsEl.FindFirstBy("AutomationId=microphone-button") {
If (ExOnHold) { ; exclude On Hold meeting windows
If TeamsEl.FindFirstByName(Name) ; Exclude On-hold meetings with Resume button
return false
}
return true
}
return false
} ; eofun

; -------------------------------------------------------------------------------------------------------------------
Teams_IsMinMeetingWindow(TeamsEl) {
Expand All @@ -2049,7 +2065,6 @@ Teams_IsMinMeetingWindow(TeamsEl) {
If (Name="")
return


El := TeamsEl.FindFirstByNameAndType(Name, "button") ;

If El
Expand All @@ -2059,28 +2074,6 @@ Teams_IsMinMeetingWindow(TeamsEl) {

} ; eofun

; ---------------------------------------------------------
Teams_IsMeetingWindow(TeamsEl,ExOnHold:=true){
; does not return true on Share / Call in progress window

; If Meeting Reactions Submenus are opened AutomationId are not visible.

If (ExOnHold) {
Name := Teams_GetLangName("Resume","Resume")
If (Name="")
return
}

If TeamsEl.FindFirstBy("AutomationId=microphone-button") {
If (ExOnHold) { ; exclude On Hold meeting windows
If TeamsEl.FindFirstByName(Name) ; Exclude On-hold meetings with Resume button
return false
}
return true
}
return false
} ; eofun


; -------------------------------------------------------------------------------------------------------------------
Teams_ActivateMainWindow(){
Expand Down
2 changes: 1 addition & 1 deletion Lib/TrayIcon.ahk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; wrapper for ToolTip command
; wrapper for Tray Icon command with Time to display option
TrayIcon(IcoFile, TimeToDisplay := 1000)
{
; display IcoFile
Expand Down
6 changes: 3 additions & 3 deletions PeopleConnector.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
; See help/homepage: https://tdalon.github.io/ahk/People-Connector

; Calls: ExtractEmails, TrayTipAutoHide, ToStartup
LastCompiled = 20230123165715
LastCompiled = 20230130144220

#SingleInstance force ; for running from editor

Expand Down Expand Up @@ -184,8 +184,8 @@ If InStr(sEmailList,";") { ; multiple Emails
TrayTipAutoHide("People Connector warning!","Feature does not work for multiple users!")
return
} Else {
EnvGet, userprofile , userprofile
Run, %userprofile%\AppData\Local\Microsoft\Teams\current\Teams.exe callto:%sEmailList%
TeamsExe := Teams_GetExe()
Run, %TeamsExe% callto:%sEmailList%
}
return

Expand Down

0 comments on commit 84721da

Please sign in to comment.