jamesbrindle / Keypad4TeamsGlobalKeys

A program to make the 3D printed Keypad4Team's keys globally registered.
MIT License
3 stars 0 forks source link

Desktop app is not consistently switching focus back to teams #2

Open RHill051 opened 3 years ago

RHill051 commented 3 years ago

I often have a team's call open while also working in Azure Dev Ops (in Chrome) or addressing communication on other apps like Slack or Skype. I've noticed that the desktop app doesn't always set the focus back to teams for the keypad macros to be correctly processed. In Chrome it opens the bookmarks manager ('Ctrl'+'Shift'+'O') so it doesn't seem like that 'Alt'+'0' is being recognized by the GlobalKeys app. I tried to increase the 'sleep' in the Pico code from .4 to .5 speculating that maybe the desktop app isn't able to process everything quickly enough but that didn't seem to make any difference. I'm curious if you have any ideas as to why it might not be working before I try my hand at debugging the project.

jamesbrindle commented 3 years ago

Hey,

Annoying isn't it? I thought I cracked it to be fair, but obviously not.

I'll be having another mess with it at some point.

What I was struggling with is basically identifying what the 'Call' window is, since you can't get it from the window handle title. I've used an automation UI API to drill into the window and identify components, such as the 'Leave' button to determine if it's the call window...

Trouble is, if the call window is out of focus or worse minimised, the UI api won't bring anything useful back. Therefore, I've implemented a shell window event handler, which registers every new teams related window in a cache, so at some point it has to be in focus and will identify the 'leave' button (amongst a couple of other) and then refers back to it by the handle id when the global key event handler sees a 'Alt + 0'.

When you close the call window, that handler ID is removed from the cache, and there's a timer that periodically checks if the handler is still valid, and if not, removes from the cache. The reason being, if more than one 'call window' exists in the cache, then the program doesn't know which one to activate.

If no call window is present, is should activate the 'main' Teams window... Then the 'Answer Call' buttons can work...

This technique seems to be great for me. It seems to work all the time...

I wonder if. Is your teams call window getting focus, then your original window taking over it again or does it appear the call window isn't activating at all?

Do you have multiple 'chat' windows open (i usually have just the main teams window open, plus a call window if i'm in a call). I've noticed the automation UI API takes an ages to iterate over control when multiple chat windows are open - In which case, the program might not have enough time to identify the call window, and so the 'Alt + 0' is actually lost.

Also, what version of the app are you using? the 1.0.2 is the latest.

Regards,

Jamie