I am trying to run an AHK script to open/show/minimize teams depending on the state of the app. I currently have the same functionality work for the windows calculator, but when I copy/paste the same solution, AHK fails to run teams. Currently, this is what I am working with
F11::
If WinExist("Teams ahk_class ApplicationFrameWindow")
{
IfWinActive
WinMinimize
Else
{
WinGet, winState, MinMax
If (winState = -1)
{
WinRestore
WinActivate
}
}
}
Else
{
run ahk_exe Teams.exe
WinWait, Teams
WinActivate
}
return
however, it seems line 24 (run ahk_exe Teams.exe) is causing the issue. When I run windowSpy, I get the following:
When I replace ahk_exe Teams.exe with ahk_pid 6440 I get the same issues. Has anyone else had this issue and found a way around it?
I feel like some of these terms need to be cleared up a bit:
ahk_exe is the name of the executable file (i.e. .exe) that the process is associated with. Normally, just using the run command generically with the name of this file would do nothing, as AHK has no idea which folder this .exe is in. This just happened to work with the Windows Calculator app [calc.exe], since that was a program that Windows allows you to run anywhere you want. The solution is to tell ahk which folder the .exe is in so that it can run it.
If you want to test whether or not a specific program parameter for the run command will work properly, you can open up a command prompt window and try the command, replacing AHK's run with the Commandline's start [ex: run calc.exe becomes start calc.exe].
Additionally, ahk_pid is not a constant number that persistently associates with a program. In fact, every time you run a program, even if it is the same exact program, Windows will assign a new PID to it every time. Futhermore, because a new one is assigned after the program is launched, we cannot use it to initially launch a program.
Important!: This code immediately below is unsafe and can corrupt your installation of Teams. Please see Update 1 for more info and a better alternative.
Here is a solution that launches the Teams app (Teams.exe) from the default installation location in C:\Users\[YOUR USER NAME HERE]\appdata\local\Microsoft\Teams\current\Teams.exe
run "%LOCALAPPDATA%\Microsoft\Teams\current\Teams.exe"
Hope this was helpful. If you have any additional questions, please lmk
Update 1:
While looking back at my original solution, I found out that directly running the Teams.exe file was not a good solution, as it has the potential to corrupt the installation of Microsoft Teams (which happened to me). As such, in order to run Teams the way the developers intended it to, I am opting to run the Program's shortcut file (i.e. the "Microsoft Teams.lnk" file in the %AppData%\Microsoft\Windows\Start Menu\Programs\ folder). Upon inspecting this .lnk file, I found that it contained additional logic and calls to MS Teams' Update.exe file that help prevent these issues from occurring. So, the new Run code to start MS Teams would be
run "%AppData%\Microsoft\Windows\Start Menu\Programs\Microsoft Teams.lnk"
With that out of the way, we can now integrate this new run command back into OP's program. From what I could understand of the original code, these were the objectives OP was trying to code (if any of these are incorrect, please lmk and I can update):
If Teams is running and the currently active window, minimize it.
If Teams is running, but not the active window, make it the active window
If Teams is not running, run it and make the active window once it opens.
So, we can effectively boil down the logic to be something like this (in pseudocode):
If Teams is running
If Teams is the Active Window
Minimize Teams
Else (i.e. Teams is NOT the Active Window)
Make Teams the Active Window
Else (i.e. Teams is NOT running)
Run Teams
Wait until Teams is done opening
Make Teams the Active Window
Let's start with the code to detect if Teams is running. Currently, the source code uses this to try to detect is Teams is active: If WinExist("Teams ahk_class ApplicationFrameWindow"). Ignoring whether or not this syntax is correct (I've never seen both a WinTitle and ahk_class parameter used in the same "" block for WinExist), using the ahk_class, at least in this case, might not be the best option available. In the the Windows Spy screenshot that OP kindly provided, we can see the ahk_exe of Teams.exe would be much more specific than the ahk_class of Chrome_WidgetWin_1. As such, can use If WinExist("ahk_exe Teams.exe") instead for this program to detect if MS Teams is already running.
The next thing I want to touch on is that when Teams is "closed" i.e. by clicking the X button in the upper right corner of the screen or even when closed using the WinClose command, it's default behaviour actually minimizes it to the tray, from where the WinActivate command can be used maximize it, similar to how it would be if it was instead minimized to the taskbar by clicking the - button instead. As such, depending on personal preference, you can have Teams either minimize to the taskbar or minimize to the tray and still work the same functionally with the rest of the program. Although this was not a requested or mentioned feature by OP, I feel like this is still a useful behaviour to mention/ include in this response.
Next, the original code that the original script was using to Activate a non-active but still running MS Teams was as follows:
Else
{
WinGet, winState, MinMax
If (winState = -1)
{
WinRestore
WinActivate
}
}
While the additional checks and logic that OP implemented could be useful in some scenarios, I feel like it could effectively be shortened and replaced with just a simple
Else
WinActivate
The last change I made that deviated from the original script was just the bit that ran Teams if it was not already open. I feel like I've already discussed the changes enough above, but in summary: run ahk_exe Teams.exe was replaced with run "%AppData%\Microsoft\Windows\Start Menu\Programs\Microsoft Teams.lnk"
Final Code:
F11::
If WinExist("ahk_exe Teams.exe")
{
IfWinActive
WinMinimize ;Use this if you want to minimize Teams to the Taskbar
;WinClose ;Use this if you want to minimize Teams to the Tray
Else
WinActivate
}
Else
{
run "%AppData%\Microsoft\Windows\Start Menu\Programs\Microsoft Teams.lnk"
WinWait, Teams
WinActivate
}
return
This was a bit longer than usual, but I hope this was helpful. Once again, if you have any Questions/ Comments/ Concerns, or just want more clarification, feel free to ask.
I am calling chrome.notifications.create(msgID, msg), multiple times, each time with different msgID. For example if I have 5 messages to User, I call the chrome.notifications.create(msgID, msg) 5 times. It works perfectly fine on Apple MacBook where it stacks the pop-up windows on one above other. However on Windows 10, it shows just one pop-up window and only after closing the first pop-up it shows second one and so on so forth.
How can I achieve same experience as MacBook on Windows 10?
On a client machine, all of the TextFields are displayed with the text cut in half, vertically.
A few fields that display correctly are Formula fields or have a height increased for testing purposes.
This bug started happening without any update of my software, so must be something inside the machine of the user.
It works elsewhere.
The client uses a XP SP3, the only thing that happened (what I can see, using the event viewer) is that a Office 2007 installation failed and after that all reports have this problem.
Since this report works everywhere except this client, it must be some sort of wrong config with in the client machine.
So, I replaced the printer default with another printer and the reports started displaying everything as it should.
So a wrong default printer was the problem.
I have a window, with several Gtk-2.0 widgets. One of them is a GtkEntry, with the corresponding GtkCompletion connected.
I need to debug the code called when a selection ('match' event) is made in the dropdown shown by the GtkCompletion. So I set a breakpoint, activate the selection, and the entire desktop hangs. The only form I found to get out is Ctl-Alt-Backspace, and delete the gdb instance.
When this happens, the entire windows manager remains as if the dropdown is still active - only responds to Ctl-Alt functions, like Ctl-Alt-F2.
I tried the --sync commandline option, but that didn't make any difference. Though there seem to be some (rather complicated) solutions such as running a nested Window server, or debug remotely, I can't imagine there isn't a more elegant solution.
Any suggestions?
I do this all the time.
You need to grab another laptop, or a console on another server, and ssh into your primary desktop/laptop. Start your GTK application on your main desktop/laptop, then attach gdb to it from your connection from your other laptop/machine.
Then, you will run your gtk application on your main screen, and debug it from a separate connection, without interfering with your primary display.
EDIT: I see that you already considered remote debugging, but in my experience it's really not that difficult. I just have another laptop on my desk, next to me, to debug my X applications.
I'm working on an C++ app which uses opencv for some data manipulation and visualization. I'm using three to four cvShowImage() statements to visualize the data. I've recently noticed, that only the window which has focus, will be updated constantly after each cvShowImage() call. All the other windows only get updated infrequently. Is there a way to make sure that all opencv windows get refreshed and updated?
If you don't already, I would suggest issuing a cvWaitKey(30) after each cvShowImage() and not only once after the last one. Or you could try displaying all the images in one window.