Page 1 of 2

Can't get WinActivate to activate Microsoft Teams

Posted: 23 Apr 2019, 09:33
by geekyadam
Simply put I can't get WinActivate to activate Microsoft Teams.
Here is WindowSpy after manually activating Teams window...
4sRaf9O.png
4sRaf9O.png (15.98 KiB) Viewed 1645 times
...then I activate another Window (Firefox)...
28eXQz2.png
28eXQz2.png (15.71 KiB) Viewed 1645 times
...finally I try to use WinActivate Microsoft Teams ...
BsqTpsm.png
BsqTpsm.png (12.63 KiB) Viewed 1645 times
I've also tried the full window information in the WinActivate:
WinActivate Microsoft Teams ahk_class Chrome_WidgetWin_1 ahk_exe Teams.exe

The window never activates and the WindowSpy shows same contents each time.

Re: Can't get WinActivate to activate Microsoft Teams

Posted: 23 Apr 2019, 09:54
by AlleyArtwork
i'm able to use the below successfully.
WinAvtivate, ahk_exe Teams.exe

this worked regardless of which team i was currently viewing. (wintitle seems to change based on the currently viewed team).

Re: Can't get WinActivate to activate Microsoft Teams

Posted: 23 Apr 2019, 09:59
by SuperFoobar

Code: Select all

WinActivate("ahk_exe Teams.exe")

Re: Can't get WinActivate to activate Microsoft Teams

Posted: 23 Apr 2019, 10:01
by geekyadam
AlleyArtwork wrote:
23 Apr 2019, 09:54
i'm able to use the below successfully.
WinAvtivate, ahk_exe Teams.exe

this worked regardless of which team i was currently viewing. (wintitle seems to change based on the currently viewed team).
I just tried that and the window still won't activate. Also the WindowSpy still shows same contents (empty). Does this likely mean somethings up on my end? Not sure what that could be...

Re: Can't get WinActivate to activate Microsoft Teams

Posted: 23 Apr 2019, 10:02
by geekyadam
SuperFoobar wrote:
23 Apr 2019, 09:59

Code: Select all

WinActivate("ahk_exe Teams.exe")
I get a "Call to nonexistent function." when trying to use that. Is there a new version of AHK I'm not aware of that has built-in WinActivate() function?

Re: Can't get WinActivate to activate Microsoft Teams

Posted: 23 Apr 2019, 10:28
by SuperFoobar
geekyadam wrote:
23 Apr 2019, 10:02
SuperFoobar wrote:
23 Apr 2019, 09:59

Code: Select all

WinActivate("ahk_exe Teams.exe")
I get a "Call to nonexistent function." when trying to use that. Is there a new version of AHK I'm not aware of that has built-in WinActivate() function?
Yes please update by running this script

Code: Select all

UrlDownloadToFile, https://www.autohotkey.com/download/, page
FileRead, page, page
FileDelete, page

RegExMatch(page, "\d+\.\d+\.\d+\.\d+", curVersion)

If (A_AhkVersion <> curVersion)
{
    MsgBox, 4161, AHK Updater, AHK is out of date`n`nCurrent: %A_AhkVersion%`nLatest: %curVersion%`n`nPress OK to download latest
	IfMsgBox Ok
	{
		FileDelete, installer.exe
		UrlDownloadToFile, https://www.autohotkey.com/download/ahk-install.exe, installer.exe
		Run, installer.exe
	}
} else {
	MsgBox, 4160, AHK Updater, AHK is up to date (%curVersion%)
}


Re: Can't get WinActivate to activate Microsoft Teams

Posted: 23 Apr 2019, 10:35
by gregster
SuperFoobar wrote:
23 Apr 2019, 10:28
Yes please update by running this script
Afaik, there is no such function called WinActivate() in the latest version of AHK 1.1, which would be 1.1.30.03 (not even in v2, it seems), there is only the command WinActivate.
Perhaps you added one function of this name in your personal user library...

Re: Can't get WinActivate to activate Microsoft Teams

Posted: 23 Apr 2019, 10:56
by jeeswg
AHK v1 and v2 have WinActive(), which checks if a window is active.
Only AHK v2 has WinActivate(). Although you can backport it to AHK v1. E.g.:
commands as functions (AHK v2 functions for AHK v1) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=29689

Re: Can't get WinActivate to activate Microsoft Teams

Posted: 23 Apr 2019, 10:58
by geekyadam
gregster wrote:
23 Apr 2019, 10:35
SuperFoobar wrote:
23 Apr 2019, 10:28
Yes please update by running this script
Afaik, there is no such function called WinActivate() in the latest version of AHK 1.1, which would be 1.1.30.03 (not even in v2, it seems), there is only the command WinActivate.
Perhaps you added one function of this name in your personal user library...
Yeah that's what I'm guessing as well...nonetheless, WinActivate ahk_exe Teams.exe does not work for me.

Any other ideas here?

Re: Can't get WinActivate to activate Microsoft Teams

Posted: 23 Apr 2019, 10:59
by geekyadam
jeeswg wrote:
23 Apr 2019, 10:56
AHK v1 and v2 have WinActive(), which checks if a window is active.
Only AHK v2 has WinActivate(). Although you can backport it to AHK v1. E.g.:
commands as functions (AHK v2 functions for AHK v1) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=29689
Searching the v2 docs I don't see any mention of WinActivate() function: https://lexikos.github.io/v2/docs/commands/WinActivate.htm

Re: Can't get WinActivate to activate Microsoft Teams

Posted: 23 Apr 2019, 11:01
by jeeswg
In AHK v2, commands and functions are equivalent. The only difference is whether you omit the parentheses or not. However, if you want to store the return value, you need the parentheses.

Code: Select all

Cmd Arg1, Arg2
Func(Arg1, Arg2)
RetValue := Func(Arg1, Arg2)

Re: Can't get WinActivate to activate Microsoft Teams

Posted: 23 Apr 2019, 11:02
by geekyadam
jeeswg wrote:
23 Apr 2019, 10:56
AHK v1 and v2 have WinActive(), which checks if a window is active.
Only AHK v2 has WinActivate(). Although you can backport it to AHK v1. E.g.:
commands as functions (AHK v2 functions for AHK v1) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=29689
Also, I see that "commands as functions" is just a function that calls the command, and since I've already confirmed using the command does not work for me, then using a function to call the same command likely won't change that result.

Re: Can't get WinActivate to activate Microsoft Teams

Posted: 23 Apr 2019, 11:05
by jeeswg
Did you try running as admin?

Re: Can't get WinActivate to activate Microsoft Teams

Posted: 23 Apr 2019, 11:20
by geekyadam
jeeswg wrote:
23 Apr 2019, 11:05
Did you try running as admin?
No change in behavior.

Re: Can't get WinActivate to activate Microsoft Teams

Posted: 23 Apr 2019, 11:27
by jeeswg
You could try WinGet Count. If the count is 0, you have a problem, if it is greater than 1, you might have to use WinGet List, to get the right window.

Code: Select all

WinGet, vCount, Count, ahk_class Notepad
MsgBox, % vCount
Also, you may want to turn DetectHiddenWindows on/off.

Re: Can't get WinActivate to activate Microsoft Teams

Posted: 23 Apr 2019, 12:53
by geekyadam
jeeswg wrote:
23 Apr 2019, 11:27
You could try WinGet Count. If the count is 0, you have a problem, if it is greater than 1, you might have to use WinGet List, to get the right window.

Code: Select all

WinGet, vCount, Count, ahk_class Notepad
MsgBox, % vCount
Also, you may want to turn DetectHiddenWindows on/off.
DetectHiddenWindows has always been on.
Okay you may have helped me find my issue...

Code: Select all

WinGet wincount, count, ahk_exe Teams.exe
	msgbox count: %wincount%
count: 28

Soooo.....there are 28 Teams.exe windows? I only see the one that exists and the systray icon...

Re: Can't get WinActivate to activate Microsoft Teams

Posted: 23 Apr 2019, 15:32
by geekyadam
I just looped through all the IDs and tried activating them. None of them activated the actual Teams window.

Code: Select all

	WinGet winlist, list, ahk_exe Teams.exe
	Loop %winlist%
	{
		thisID := winlist%A_Index%
		fullwinlist := fullwinlist . thisID . "`r`n"
		WinActivate ahk_id thisID
		msgbox activated ID %thisID%
	}

Re: Can't get WinActivate to activate Microsoft Teams

Posted: 23 Apr 2019, 15:33
by geekyadam
Wait, scratch that, I forgot the % characters around thisID in the winactivate line...

Re: Can't get WinActivate to activate Microsoft Teams

Posted: 23 Apr 2019, 15:42
by geekyadam
Okay so two of the ~15 IDs activate the Teams window: 0xb0c02 and 0x205ac
Not sure which I should use...I might actually just use the Loop for the winactivate to be sure it gets activated...

Re: Can't get WinActivate to activate Microsoft Teams

Posted: 23 Apr 2019, 16:00
by jeeswg
You can try getting info, to identify the correct window, especially window styles/ex. styles.

Code: Select all

q:: ;get window info
WinGet, vWinList, List, ahk_class Notepad
Loop, % vWinList
{
	hWnd := vWinList%A_Index%
	WinGetTitle, vWinTitle, % "ahk_id " hWnd
	WinGetClass, vWinClass, % "ahk_id " hWnd
	WinGet, vPName, ProcessName, % "ahk_id " hWnd
	;WinGet, vPID, PID, % "ahk_id " hWnd

	WinGet, vWinStyle, Style, % "ahk_id " hWnd
	WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
	WinGet, vCtlList, ControlList, % "ahk_id " hWnd
	MsgBox, % vPName "`r`n" vWinTitle "`r`n" vWinClass "`r`n" Format("0x{:08X}`r`n0x{:08X}", vWinStyle, vWinExStyle) "`r`n`r`n" vCtlList
}
return