WinActivate showing a blank window Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
SquirrelHugger
Posts: 17
Joined: 23 Feb 2018, 04:17

WinActivate showing a blank window

12 Mar 2018, 23:18

Hello!

I have this following code:

Code: Select all

DetectHiddenWindows, On
SetTitleMatchMode RegEx
	
; WinActivate WhatsApp
; WinActivate CAM
WinActivate qBittorrent
WinActivate NetLimiter
When that code is executed, I get the following:
index.png
index.png (11.49 KiB) Viewed 1945 times
What I have tried:
1. Adding 50ms sleep between the two WinActivate (any other sleep timer also won't help)
2. Adding #WinActivateForce after WinActivate
3. Using WinShow instead of WinActivate

To fix the blank window I have to double click the appropriate icon in the system tray.

Note: I have noticed that this problem only happens when the windows I am trying to activate are hidden.
Would appreciate any help!

Thank you!
:morebeard:
Rohwedder
Posts: 7762
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: WinActivate showing a blank window

13 Mar 2018, 01:35

Hallo,
many applications have additional hidden windows which are hidden for good reason.
Usually it makes no sense to activate them.
SquirrelHugger
Posts: 17
Joined: 23 Feb 2018, 04:17

Re: WinActivate showing a blank window

13 Mar 2018, 02:02

Rohwedder wrote:Hallo,
many applications have additional hidden windows which are hidden for good reason.
Usually it makes no sense to activate them.
I am not sure what you mean.

If I click the icons in the system tray, the window is shown normally, however I only get the blank window when I try to activate the window using WinActivate
:morebeard:
lexikos
Posts: 9688
Joined: 30 Sep 2013, 04:07
Contact:

Re: WinActivate showing a blank window

13 Mar 2018, 03:00

If this is the correct window (and not some other hidden window with the same name), it is likely that the window does not load or display its contents in response to being shown, but rather the program shows the window and loads its contents in response to clicking the tray icon. When you call WinActivate (or WinShow), you circumvent the program and tell the OS to display the window in its current state.

I would suggest searching for the TrayIcons() script, which (if it still works) can tell you which WM_COMMAND ID can be sent to the program's window to simulate clicking the tray icon. Alternatively, check if the program has the capability to set its own global hotkey to show the window.
SquirrelHugger
Posts: 17
Joined: 23 Feb 2018, 04:17

Re: WinActivate showing a blank window

13 Mar 2018, 03:11

@lexikos thank you for your answer.

I think I have managed to find an alternative? I switched WinActivate for Run. Well it works even if it does not look that good.

Here is the code if anyone is interested:

Code: Select all

DetectHiddenWindows, On
SetTitleMatchMode RegEx

Run, "C:\Program Files\qBittorrent\qbittorrent.exe"
WinWait, qBittorrent v4.0.3
WinActivate
#WinActivateForce
	
Run, "C:\Program Files\Locktime Software\NetLimiter 4\NLClientApp.exe"
WinWait, qBittorrent v4.0.3
WinActivate
#WinActivateForce
	
;WinActivate WhatsApp
;WinActivate CAM
:morebeard:
SquirrelHugger
Posts: 17
Joined: 23 Feb 2018, 04:17

Re: WinActivate showing a blank window  Topic is solved

15 Mar 2018, 10:08

Ok found a permanent fix for this. Sorry for double posting, just wanted to make a clear statement.

The code in my previous post will work but has the issue of running the program each time, and in the case of NetLimiter 4 for some reason more than one instance of the program can be run at the same time. So if you run NetLimiter 3 times in your script, you will end up 3 instances of NetLimiter. qBitTorrent has another issue where using TrayIcon_Button() would not work so I settled on running qbittorrent everytime since only one instance of qbittorrent can be running at any given time.

What I did to fix this is to DISABLE minimize to tray but i kept close to tray ENABLED. That way when I send a WinActivate command the program shows up normally and does not show me a blank window.
Code below if anyone is interested (however as stated above, I think its fixed not thanks to the script but thanks to that setting change in the program):

Code: Select all

showNetlimiter()
{
	DetectHiddenWindows, On
	isHidden := WinExist("ahk_exe NLClientApp.exe")
	
	DetectHiddenWindows, Off
	isNotHidden := WinExist("ahk_exe NLClientApp.exe")
	
	if isHidden and !isNotHidden
	{
		TrayIcon_Button("NLClientApp.exe", "L", true)
	}
	else
		WinActivate, ahk_exe NLClientApp.exe
	
	WinWaitActive, ahk_exe NLClientApp.exe
	
	; Very specific coordinates and size, would look very bad on your monitor (edit to your liking)
	WinMove, ahk_exe NLClientApp.exe, , 2490, 1129, 517, 336
}

showQbittorrent()
{
	if WinExist("ahk_exe qbittorrent.exe")
		WinActivate, ahk_exe qbittorrent.exe
	else
	{
		Run, C:\Program Files\qBittorrent\qbittorrent.exe
		WinWait, ahk_exe qbittorrent.exe
		
		WinActivate, ahk_exe qbittorrent.exe
	}
	
	WinWaitActive, ahk_exe qbittorrent.exe
	
	; Very specific coordinates and size, would look very bad on your monitor (edit to your liking)
	WinMove, ahk_exe qbittorrent.exe, , 1913, 1129, 592, 338
}
:morebeard:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Chunjee, LovesMtns, mikeyww and 93 guests