[v2.0-a131] - window visible Topic is solved

Report problems with documented functionality
w64bit
Posts: 14
Joined: 08 Aug 2018, 08:30

[v2.0-a131] - window visible

Post by w64bit » 13 Apr 2021, 01:14

If I compile this code with 131

Code: Select all

Insert::RunOrActivate "C:\Program Files (x86)\SpeedCrunch\speedcrunch.exe"

RunOrActivate(exe)
{
    If !WinExist("ahk_exe " exe)
    {
        Run(exe, , , &pid)
        if !WinWait("ahk_pid " pid, , 3)
            Return
    }
    WinActivate
}
and add the shortcut to Win Startup, at each boot a window toolbar is displayed on lower left corner.
Last edited by w64bit on 13 Apr 2021, 14:26, edited 1 time in total.

User avatar
jasc2v8
Posts: 59
Joined: 10 Dec 2020, 12:24
Contact:

Re: 131 - window visible

Post by jasc2v8 » 13 Apr 2021, 10:08

Please explain what is your desired and/or expected result?
Are you expecting the window in the upper left corner?

w64bit
Posts: 14
Joined: 08 Aug 2018, 08:30

Re: 131 - window visible

Post by w64bit » 13 Apr 2021, 12:43

Because it's ahk compiled, the correct behavior it's no window, like it was up to 131.

User avatar
jasc2v8
Posts: 59
Joined: 10 Dec 2020, 12:24
Contact:

Re: 131 - window visible

Post by jasc2v8 » 13 Apr 2021, 13:22

Where is your Run() function referenced from?
The following runs compiled in v1.33
When I press the Insert key, the speedcrunch window appears.
Is the expected behavior no window after pressing Insert?

Code: Select all

Insert::RunOrActivate("speedcrunch.exe")

RunOrActivate(exe)
{
    If !WinExist("ahk_exe " exe)
    {
        Run, % exe, , , pid
        if !WinWait("ahk_pid " pid, , 3)
            Return
    }
    WinActivate
}

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

Re: 131 - window visible

Post by gregster » 13 Apr 2021, 13:45

I am pretty sure the 131 in the topic title is a hint at the latest released v2 alpha version v2.0-a131.
I will add something to make it clearer...

lexikos
Posts: 9494
Joined: 30 Sep 2013, 04:07
Contact:

Re: [v2.0-a131] - window visible

Post by lexikos » 14 Apr 2021, 03:24

You say "at each boot"; are you saying that this happens immediately when the script is run at startup, not when you press Insert?

In that case, I suppose it has nothing to do with the content of your script, which does not execute until you press Insert.

What is this "window toolbar"? If it has no title, you can use Window Spy or WinGet functions to identify its class and process name.

Does this "window toolbar" go away if you exit the script?

Does this "window toolbar" appear if you run the script manually after startup, not automatically?

w64bit
Posts: 14
Joined: 08 Aug 2018, 08:30

Re: [v2.0-a131] - window visible

Post by w64bit » 14 Apr 2021, 09:30

1. yes
2. yes
3.
C:\Program Files (x86)\SpeedCrunch\SpeedCrunch Launcher.exe
ahk_class AutoHotkey
ahk_exe SpeedCrunch Launcher.exe
ahk_pid 10752
ahk_id 66580
4. yes
5. no

viv
Posts: 217
Joined: 09 Dec 2020, 17:48

A small window appears in 131 "Reload"

Post by viv » 15 Apr 2021, 02:00

Code: Select all

Persistent

A_TrayMenu.add "Reload", f_TrayReload

f_TrayReload(*)
{
    Reload
}
1.jpg
1.jpg (4.33 KiB) Viewed 1211 times
click max in this
2.jpg
2.jpg (24.89 KiB) Viewed 1211 times

lexikos
Posts: 9494
Joined: 30 Sep 2013, 04:07
Contact:

Re: [v2.0-a131] - window visible

Post by lexikos » 15 Apr 2021, 04:01

@viv I have merged your topic with this one, as it's obviously the same issue. AutoHotkey v2 Development is in no way a suitable place for your post. It did make reproducing the problem easier, so thanks for that at least.


This relates to commit 7716cb13.
  • The window you are seeing is the script's main window.
  • When the program creates the main window, it hides the window by calling ShowWindow(g_hWnd, SW_HIDE); twice. It is called twice because the first call may ignore the SW_HIDE parameter, depending on options set by the process that launched AutoHotkey.
  • If the active window is null or ahk_class Shell_TrayWnd (the taskbar), ShowWindow(g_hWnd, SW_MINIMIZE); is called to minimize the window - for the reason stated in the source code:

    Code: Select all

    	// Now that the first call to ShowWindow() is out of the way, minimize the main window so that
    	// if the script is launched from the Start Menu (and perhaps other places such as the
    	// Quick-launch toolbar), the window that was active before the Start Menu was displayed will
    	// become active again.  But as of v1.0.25.09, this minimize is done more selectively to prevent
    	// the launch of a script from knocking the user out of a full-screen game or other application
    	// that would be disrupted by an SW_MINIMIZE
  • Minimizing the window causes a WM_SIZE message. Previously, this message was handled by calling ShowWindow(g_hWnd, SW_HIDE);, as shown in the commit diff. So the window was created in a hidden state, then explicitly hidden (possibly twice), then shown in a minimized state, then hidden again. :facepalm:
  • When you click the minimize button, this sends a WM_SYSCOMMAND, SC_MINIMIZE message, which is also handled by hiding the window instead of minimizing it. Clicking the button therefore does not minimize the window at all, so does not send a WM_SIZE message with wParam == SIZE_MINIMIZED.
  • Originally I wanted to remove both, letting the close button hide the window as it does now, and the minimize button do what it was intended for: minimize the window. However, it turns out minimizing the window also hides any owned windows (such as dialogs), so I decided not to.
  • I also wanted to remove the ShowWindow(g_hWnd, SW_MINIMIZE); call on startup, but testing showed that without it, the focus does not end up anywhere sensible.
You can work around it with WinHide(A_ScriptHwnd).

Again, the minimized window would only appear if the taskbar is active (or nothing is active) when the script launches.

viv
Posts: 217
Joined: 09 Dec 2020, 17:48

Re: [v2.0-a131] - window visible

Post by viv » 15 Apr 2021, 04:46

@lexikos

Ok.
I'm not actually a programmer
So I don't really understand the terminology you are talking about

I hope this experience will be improved in the next version

1, or the same code above, not only the window will appear, but also in the right click tray program menu when this appears
1.gif
1.gif (356.59 KiB) Viewed 1165 times

2,I added "WinHide(A_ScriptHwnd)" to the program, but it still has some visual impact
2.gif
2.gif (13.66 KiB) Viewed 1165 times
Thanks for your great work and have a nice life!

Translated with www.DeepL.com/Translator (free version)

w64bit
Posts: 14
Joined: 08 Aug 2018, 08:30

Re: [v2.0-a131] - window visible

Post by w64bit » 15 Apr 2021, 12:04

a131 is doing this all the time.
a130 it seems to be OK.

lexikos
Posts: 9494
Joined: 30 Sep 2013, 04:07
Contact:

Re: [v2.0-a131] - window visible  Topic is solved

Post by lexikos » 20 Apr 2021, 04:51

Fixed by v2.0-a132.

Post Reply

Return to “Bug Reports”