Trouble minimising borderless always on top Gui

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
omar
Posts: 540
Joined: 22 Oct 2015, 17:56

Trouble minimising borderless always on top Gui

31 Mar 2018, 19:43

I've finished making some code for a Gui that is borderless + always sits on top.

Problem: when I click on the program icon on the taskbar it minimises.

It's impossible to get back. What can I do?

Same happens when I press Windows + D - to minimise all windows.

EDIT I remove the borderless. Then I remove always ontop. I minimise. It pops back into place. I minimise again. It pops back into place. Then I minimise again and it dissapears. I can see a green AHK icon on the top right, but can't do anything to get back. :(

Grrrr!
Help!

Thanks.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Trouble minimising borderless always on top Gui

01 Apr 2018, 00:39

Maybe post your code? It could help!
omar
Posts: 540
Joined: 22 Oct 2015, 17:56

Re: Trouble minimising borderless always on top Gui

01 Apr 2018, 09:32

@wolf_II i found the problem: Guisize
when i have this, it gives unwanted behaviour.

i removed different bits of code until i found the problem.
see the code further below. press minimise (you might need to press 2 or 3 times) and you will see the screen goes out of screen and you can't bring back.
for my code, there seems to be other odd behaviour, but i deduced everything comes from this code.
i used the code to put my window on the top right hand side of the screen.

Code: Select all

#SingleInstance, force

Gui, Add, Text,, Some sample text goes here
Gui, Add, Button, w200 gExitAction,Exit
Gui, Show
Return

ExitAction:
	ExitApp
Return

Guisize:
	guiheight := A_guiheight
	guiwidth := A_guiwidth
	gui, show, % "x" A_ScreenWidth - GuiWidth " y"  0 " w" Guiwidth " h" GuiHeight
Return
Actually this line of code is what causes the problem: gui, show, % "x" A_ScreenWidth - GuiWidth " y" 0 " w" Guiwidth " h" GuiHeight
just experimenting, if i use just: gui,show - no problems

is this a bug?
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Trouble minimising borderless always on top Gui

01 Apr 2018, 09:57

Try this:

Code: Select all

#SingleInstance, force
WinX := A_ScreenWidth - 220
Gui, Add, Text,, Some sample text goes here
Gui, Add, Button, w200 gExitAction,Exit
Gui, Show, x%WinX% y0
Return

ExitAction:
	ExitApp
Return
I hope that helps.

I don't think there is a bug. There is however a known problem with GuiSize being called unreliably during Auto-Execute.
IIRC: Auto-Execute is a critical thread, meaning no other thread should be able to interrupt it.
Problem comes with GUISize: this is a thread which will be called during Auto-Execute, and sometimes is allowed to run, sometimes not allowed (still Critical Auto-Exec).

I have only superficial knowledge and little experience, but Sleep, -1 will be useful for directing flow of control , ... bla bla ..., I don't know more.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Trouble minimising borderless always on top Gui

01 Apr 2018, 10:01

Also, the size - 220 is 200px for buttonwidth, 10 extra for each margin left, right.
Also, I did not mention: Gui, Show is the place where inside the AUTOEXEC GuiSize gets called.
omar
Posts: 540
Joined: 22 Oct 2015, 17:56

Re: Trouble minimising borderless always on top Gui

01 Apr 2018, 10:55

@wolf_II i've done what u have said. works nicely.
i would prefer not to have to set the width myself.
instead... just let it be whatever it is.
i can't find anyway of JUST getting the width after showing.
any ideas?
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Trouble minimising borderless always on top Gui

18 Sep 2018, 12:46

omar wrote:i can't find anyway of JUST getting the width after showing.
any ideas?
Is this still of interest?

Try this:

Code: Select all

#SingleInstance, Force

    Gui, Add, Text,, Some sample text goes here
    Gui, Add, Button, w200 gExitAction, Exit
    Gui, Show, Hide
    Critical, Off
    Sleep, -1
    Gui, Show, % "y0 x" A_ScreenWidth - GuiWidth

Return

ExitAction:
	ExitApp
Return

Guisize:
	GuiWidth := A_GuiWidth
Return
I hope that helps.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: NinjoOnline and 212 guests