Winset top issues

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Seeds
Posts: 87
Joined: 31 Dec 2018, 01:39

Winset top issues

18 May 2021, 15:20

When a program is open I use:

Code: Select all

WinGet, save_PID, PID, A
WinGet, save_ID, ID, A
WinGetClass, save_class, A

To save the windows class as save_class.

I then have two guis open on top of this program, which works fine.

Before I close the two guis, I re-activate the progam under save_class, set it to top, and then my two gui's are meant to close in the background using this:
-------------------------------------------------------------------------------------------------

Code: Select all

WinRestore, ahk_id %save_ID%
winactivate, ahk_id %save_ID% 

start := A_TickCount
While !WinActive("ahk_class" save_class)
{
now := A_TickCount-start
winactivate, ahk_class %save_class%
if now > 5000
break
}
winset, top, ahk_class %save_class%  ;;; Make top so destroy doesn't inturrupt gui destroy
Gui, 1:Destroy
Gui, 52:Destroy
winset, top, ahk_class %save_class%
winactivate, ahk_class %save_class%
[Mod edit: [code][/code] tags added.]
----------------------------------------------------------------------

What tends to happen is that the program seems to activate just fine, but then it takes the full 5000 ms to activate the class (Indicating that it never "activates"). And then it places my two GUIS on top for some reason that have a different class than the program. Then the gui's close.
Last edited by gregster on 18 May 2021, 15:22, edited 1 time in total.
Reason: [code] tags added, again. Please use them yourself, next time. Thank you!
User avatar
mikeyww
Posts: 26847
Joined: 09 Sep 2014, 18:38

Re: Winset top issues

18 May 2021, 16:09

I understand that it should work, but if you want the class to be active, then why are you activating by HWND instead of by the class?
Seeds
Posts: 87
Joined: 31 Dec 2018, 01:39

Re: Winset top issues

18 May 2021, 16:50

mikeyww wrote:
18 May 2021, 16:09
I understand that it should work, but if you want the class to be active, then why are you activating by HWND instead of by the class?
This is meant to work on many different programs, some don't seem to like to be activated by HWND, so I added class as a backup. This one program in particular seems to have issues with class though. I have verified the class name by copying it to clippboard.
User avatar
mikeyww
Posts: 26847
Joined: 09 Sep 2014, 18:38

Re: Winset top issues

18 May 2021, 20:13

Your script generates a syntax error at my end. You are not seeing it?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: haomingchen1998 and 234 guests