Can't get WinActivate to activate Microsoft Teams

Get help with using AutoHotkey and its commands and hotkeys
User avatar
geekyadam
Posts: 31
Joined: 01 Aug 2016, 17:11

Can't get WinActivate to activate Microsoft Teams

23 Apr 2019, 09:33

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 1330 times
...then I activate another Window (Firefox)...
28eXQz2.png
28eXQz2.png (15.71 KiB) Viewed 1330 times
...finally I try to use WinActivate Microsoft Teams ...
BsqTpsm.png
BsqTpsm.png (12.63 KiB) Viewed 1330 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.
Last edited by geekyadam on 23 Apr 2019, 11:23, edited 1 time in total.
User avatar
AlleyArtwork
Posts: 43
Joined: 09 Jun 2015, 21:08

Re: Can't get WinActivate to activate Microsoft Teams

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).
User avatar
SuperFoobar
Posts: 48
Joined: 23 Nov 2018, 15:14

Re: Can't get WinActivate to activate Microsoft Teams

23 Apr 2019, 09:59

Code: Select all

WinActivate("ahk_exe Teams.exe")
User avatar
geekyadam
Posts: 31
Joined: 01 Aug 2016, 17:11

Re: Can't get WinActivate to activate Microsoft Teams

23 Apr 2019, 10:01

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...
User avatar
geekyadam
Posts: 31
Joined: 01 Aug 2016, 17:11

Re: Can't get WinActivate to activate Microsoft Teams

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?
User avatar
SuperFoobar
Posts: 48
Joined: 23 Nov 2018, 15:14

Re: Can't get WinActivate to activate Microsoft Teams

23 Apr 2019, 10:28

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%)
}

gregster
Posts: 3377
Joined: 30 Sep 2013, 06:48

Re: Can't get WinActivate to activate Microsoft Teams

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...
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Can't get WinActivate to activate Microsoft Teams

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
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
geekyadam
Posts: 31
Joined: 01 Aug 2016, 17:11

Re: Can't get WinActivate to activate Microsoft Teams

23 Apr 2019, 10:58

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?
User avatar
geekyadam
Posts: 31
Joined: 01 Aug 2016, 17:11

Re: Can't get WinActivate to activate Microsoft Teams

23 Apr 2019, 10:59

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
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Can't get WinActivate to activate Microsoft Teams

23 Apr 2019, 11:01

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)
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
geekyadam
Posts: 31
Joined: 01 Aug 2016, 17:11

Re: Can't get WinActivate to activate Microsoft Teams

23 Apr 2019, 11:02

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.
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Can't get WinActivate to activate Microsoft Teams

23 Apr 2019, 11:05

Did you try running as admin?
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
geekyadam
Posts: 31
Joined: 01 Aug 2016, 17:11

Re: Can't get WinActivate to activate Microsoft Teams

23 Apr 2019, 11:20

jeeswg wrote:
23 Apr 2019, 11:05
Did you try running as admin?
No change in behavior.
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Can't get WinActivate to activate Microsoft Teams

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.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
geekyadam
Posts: 31
Joined: 01 Aug 2016, 17:11

Re: Can't get WinActivate to activate Microsoft Teams

23 Apr 2019, 12:53

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...
User avatar
geekyadam
Posts: 31
Joined: 01 Aug 2016, 17:11

Re: Can't get WinActivate to activate Microsoft Teams

23 Apr 2019, 15:32

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%
	}
User avatar
geekyadam
Posts: 31
Joined: 01 Aug 2016, 17:11

Re: Can't get WinActivate to activate Microsoft Teams

23 Apr 2019, 15:33

Wait, scratch that, I forgot the % characters around thisID in the winactivate line...
User avatar
geekyadam
Posts: 31
Joined: 01 Aug 2016, 17:11

Re: Can't get WinActivate to activate Microsoft Teams

23 Apr 2019, 15:42

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...
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Can't get WinActivate to activate Microsoft Teams

23 Apr 2019, 16:00

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
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, DataLife, diegobh00, gignu, MikeyG12, shawnway and 81 guests