Page 1 of 1

[v2.0-a131] - window visible

Posted: 13 Apr 2021, 01:14
by w64bit
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.

Re: 131 - window visible

Posted: 13 Apr 2021, 10:08
by jasc2v8
Please explain what is your desired and/or expected result?
Are you expecting the window in the upper left corner?

Re: 131 - window visible

Posted: 13 Apr 2021, 12:43
by w64bit
Because it's ahk compiled, the correct behavior it's no window, like it was up to 131.

Re: 131 - window visible

Posted: 13 Apr 2021, 13:22
by jasc2v8
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
}

Re: 131 - window visible

Posted: 13 Apr 2021, 13:45
by gregster
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...

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

Posted: 14 Apr 2021, 03:24
by lexikos
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?

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

Posted: 14 Apr 2021, 09:30
by w64bit
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

A small window appears in 131 "Reload"

Posted: 15 Apr 2021, 02:00
by viv

Code: Select all

Persistent

A_TrayMenu.add "Reload", f_TrayReload

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

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

Posted: 15 Apr 2021, 04:01
by lexikos
@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.

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

Posted: 15 Apr 2021, 04:46
by viv
@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 1249 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 1249 times
Thanks for your great work and have a nice life!

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

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

Posted: 15 Apr 2021, 12:04
by w64bit
a131 is doing this all the time.
a130 it seems to be OK.

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

Posted: 20 Apr 2021, 04:51
by lexikos
Fixed by v2.0-a132.