Winset GUI underneath particular window

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
scriptor2016
Posts: 849
Joined: 21 Dec 2015, 02:34

Re: Winset GUI underneath particular window

19 Aug 2017, 02:30

Hi!

GUI1 - w400 h400
GUI2 - w100 h100

Whenever I drag GUI2 ontop of GUI1, I would like GUI2 to remain visible even when GUI1 has been activated at a later time. But if something else (like Notepad for example) is activated and covers both GUIs, then both GUIs are hidden underneath Notepad (the normal WIndows behavior)

So, whenever GUI1 is active, it must remain underneath GUI2 at all times.

Hope this makes sense, as I just re-phrased this whole question lol.

Can this sort of Winset be done? It's not really a generic +AlwaysOnTop, but kind of like a +AlwaysUnderneathParticularWindow type thing.

Could it be done?
just me
Posts: 9442
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Winset GUI underneath particular window

19 Aug 2017, 04:08

Code: Select all

#NoEnv
Gui, GUI1: New
Gui, GUI2: New, +OwnerGUI1
Gui, GUI1: Show, w600 h400, GUI1
Gui, GUI2: SHow, w400 h300, GUI2
Return
GUI1GuiClose:
ExitApp
scriptor2016
Posts: 849
Joined: 21 Dec 2015, 02:34

Re: Winset GUI underneath particular window

20 Aug 2017, 00:01

Thank you justme, that works perfectly - I managed to add several more GUIs and perform the same behavior on these, so that GUI1 is always on the bottom no matter how many GUIs are ontop of it. I can't thank you enough for the help.

Question-

Can this be done using 2 scripts? For example, script 1 would be:

Code: Select all

Gui, GUI1: New 
Gui, GUI1: Show, w600 h400, GUI1
Return
And script 2 would be:

Code: Select all

Gui, GUI2: Show, x100 y100 w100 h30, GUI2
Gui, GUI3: SHow, x300 y300 w100 h30, GUI3
Gui, GUI4: SHow, x500 y500 w100 h30, GUI4
Return
So basically, GUI1 (the first script) would be the "always on bottom" gui, and GUI2, GUI3, GUI4 (the second script) would always be ontop of it.

Would this be possible?
just me
Posts: 9442
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Winset GUI underneath particular window

20 Aug 2017, 02:03

Owner wrote:[v1.1.03+]: +Owner can be immediately followed by the name or number of an existing Gui or the HWND of any top-level window.

Gui, +/-Option1 +/-Option2 ...
So you need to get the HWND of the GUI1 window, e.g.

Code: Select all

GUI1HWND := WinExist("SpecifyGui1TitleHere ahk_class AutoHotkeyGUI")
scriptor2016
Posts: 849
Joined: 21 Dec 2015, 02:34

Re: Winset GUI underneath particular window

20 Aug 2017, 02:16

ok, great - let me try this out...
scriptor2016
Posts: 849
Joined: 21 Dec 2015, 02:34

Re: Winset GUI underneath particular window

20 Aug 2017, 02:25

I added the line to the second script:

Code: Select all

GUI1HWND := WinExist("GUI1 ahk_class AutoHotkeyGUI")
Gui, GUI2: Show, x100 y100 w100 h30, GUI2
Gui, GUI3: SHow, x300 y300 w100 h30, GUI3
Gui, GUI4: SHow, x500 y500 w100 h30, GUI4
Return
is this right? So far GUI isn't staying underneath the other GUIs.. let me keep trying here..
scriptor2016
Posts: 849
Joined: 21 Dec 2015, 02:34

Re: Winset GUI underneath particular window

20 Aug 2017, 02:37

Hey, I think I got it !! Here it is (for the second script):

Code: Select all

GUI1HWND := WinExist("GUI1 ahk_class AutoHotkeyGUI")

Gui, GUI2: +Owner%GUI1HWND%
Gui, GUI2: Show, x100 y100 w150 h30, GUI2


Gui, GUI3: +Owner%GUI1HWND%
Gui, GUI3: SHow, x300 y300 w150 h30, GUI3

Gui, GUI4: +Owner%GUI1HWND%
Gui, GUI4: SHow, x500 y500 w150 h30, GUI4
Return
scriptor2016
Posts: 849
Joined: 21 Dec 2015, 02:34

Re: Winset GUI underneath particular window

20 Aug 2017, 02:43

thanks justme!! Looks like I managed to get this going. The only problem is that when another program is activated, GUI1 goes to the background and is no longer visible. Yet, GUI2, GUI3 and GUI4 stay ontop at all times - but this part is okay.

Now - when I click on any of the 3 GUI's to re-activate any one of them, I need GUI1 to show itself again - but as usual, stay underneath those 3 GUI's.

This is getting complicated.
just me
Posts: 9442
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Winset GUI underneath particular window

20 Aug 2017, 02:48

Why do you need to run the GUI1 script separately?
scriptor2016
Posts: 849
Joined: 21 Dec 2015, 02:34

Re: Winset GUI underneath particular window

20 Aug 2017, 03:12

I have a seperate script which is creating 100's of GUI's and they are all visible on screen. Basically, these are all individual buttons which each act as a brush preset for Photoshop. They are all "on top", meaning they are always on top of the Photoshop window. So, when I click any one of them, they select a brush preset in Photoshop.

So, to add this additional code to that script is a bit overwhelming for me.

If I could run a separate script, which would show a main GUI, and would remain underneath all those 100's of GUIs and at the same time always above Photoshop (so, it would be in between) then it would be perfect. I don't know if this is getting too complicated or not.

So the basic scripts I posted in this thread were just to give me ideas and help me along.

I guess the best thing to do is return to the problem of 2 messages above - when clicking on any of those 3 GUI's, how would I make it also show GUI beneath them? (but not activate it, of course)
just me
Posts: 9442
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Winset GUI underneath particular window

20 Aug 2017, 03:16

scriptor2016 wrote:They are all "on top", meaning they are always on top of the Photoshop window.
How did you manage this as yet?
scriptor2016
Posts: 849
Joined: 21 Dec 2015, 02:34

Re: Winset GUI underneath particular window

20 Aug 2017, 03:32

Code: Select all

Gui 1: -Caption +Border +ToolWindow +AlwaysOnTop  

Code: Select all

Gui 2: -Caption +Border +ToolWindow +AlwaysOnTop  

Code: Select all

Gui 3: -Caption +Border +ToolWindow +AlwaysOnTop  
..and so on, all the way up to 190 GUI's or so. Obviously, there is a lot more code to each GUI, but I thought showing just the simple line of code for each would suffice - if not, let me know and I will post more.

Each GUI has common string in its title, which is "TOOL3" (without the quotes)

so, GUI142 might be "TOOL3-hard_brush"

and, GUI74 might be "TOOL3-watercolor_brush"


..they all have "TOOL3" at the beginning of their WinTitles. (again, without the quotes)
just me
Posts: 9442
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Winset GUI underneath particular window

20 Aug 2017, 03:41

If all of the GUIs depend on an existing Photoshop window, you could try the following:
  • Get the HWND of the Photoshop window.
  • Set the owner of GUI1 to this HWND.
  • Get the HWND of the GUI1 window.
  • Set the owner of all other GUIs to this HWND and remove the ToolWindow and AlwaysOnTop options.
Note: In theory
  • taskbar buttons won't be shown,
  • all GUI windows will be minimized when the Photoshop window is minimized,
  • all GUI windows will be closed when the Photoshop window is closed.
Edit: Typos!
Last edited by just me on 20 Aug 2017, 03:51, edited 1 time in total.
scriptor2016
Posts: 849
Joined: 21 Dec 2015, 02:34

Re: Winset GUI underneath particular window

20 Aug 2017, 03:46

thank my friend - I will try this as soon as possible - right now it's almost 5AM my time and I need to book off - but I promise I will report back to you as soon as I've tried this out.
scriptor2016
Posts: 849
Joined: 21 Dec 2015, 02:34

Re: Winset GUI underneath particular window

27 Aug 2017, 02:11

My apologies for the slow response - but during the summer, weekends are my only time to check in on the forums.

Hi justme, if I try to identify the window via its HWND, it fails because in Photoshop the active window is constantly changing since the user is routinely switching documents within the software. So you might be working on "Document1", but then in a few minutes you switch over to "Document2" and it looks like this changes the HWND value. Is there a way to do this via an .exe value or something similar? Or can an HWND value have something similar to a settitlematchmode,2 situation where we could just use the "x" and in this case, EVERY hwnd window would contain that x value and ultimately every HWMD window would be recognized in Photoshop even when switching documents within it?

A Wintitle example of working on document1 in Photoshop would be:
Untitled-1 @ 33.3% (Layer 1, RGB/8) *

and--

A Wintitle example of working on document2 in Photoshop would be:
Untitled-2 @ 33.3% (Layer 1, RGB/8) *

--notice that the asterisk always remains intact - the * is present in ALL photoshop wintitles, so a Settitlematchmode, 2, * will work every time.

I suppose what this boils down to is that GUI1 needs to be alwaysontop of the Photoshop window (ahk_class Photoshop), and GUI2, GUI3 and GUI4 need to always be ontop of GUI1 (and also ontop of Photoshop) - so it's kind of like a heirarchy) - the heiracrchy must remain intact when these programs are in use

-bottom level is Photoshop
-next level up is GUI1 - this is the larger GUI which acts as the 'container' that will cause all the other small GUIs which are currently ontop of it to drag along with it when dragged
-next level up is the small GUIs (GUI2, GUI3, GUI4, etc etc etc , these are all on the same default level(in my case, there are 100's of more GUIs- so, GUI98, GUI99, GUI100, etct etc etc))
*keep this level of heirarchy
just me
Posts: 9442
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Winset GUI underneath particular window

27 Aug 2017, 02:44

Hi scriptor2016,

I don't have PhotoShop so I cannot test here. Considering how your script has been working as yet it might be sufficient to make GUI1 'AlwaysOnTop' instead of beeing owned by a PhotoShop window. Try it out and report if it fits yout needs, please.
scriptor2016
Posts: 849
Joined: 21 Dec 2015, 02:34

Re: Winset GUI underneath particular window

27 Aug 2017, 02:47

thanks!! I'm going to try this right now and see how it goes- I'll be right back
scriptor2016
Posts: 849
Joined: 21 Dec 2015, 02:34

Re: Winset GUI underneath particular window

27 Aug 2017, 02:52

here's GUI1 trying to stay on top, but it doesn't work:

Code: Select all

Gui, GUI1: +alwaysontop
Gui, GUI1: New 
Gui, GUI1: Show, w600 h400, GUI1
Return
just me
Posts: 9442
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Winset GUI underneath particular window

27 Aug 2017, 02:55

Code: Select all

Gui, GUI1: New, +AlwaysOnTop
Gui, GUI1: Show, w600 h400, GUI1
Return
scriptor2016
Posts: 849
Joined: 21 Dec 2015, 02:34

Re: Winset GUI underneath particular window

27 Aug 2017, 03:01

yes, thank you!! That works - I tried that and got it going. I think the major hurdles have been overcome here - the heirarchy with Photoshop is now working - let me try merging this with my existing codes and see how it goes -wish me luck - it could be a total win or a complete fail lol - I will report back soon as I can - aghain, I apologize for slow responses but in August I have only limited time to check in :)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Giresharu and 269 guests