[V2] V2GuiCreator

Post your working scripts, libraries and tools.
AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

[V2] V2GuiCreator

Post by AHK_user » 19 Jun 2022, 14:08

V2GuiCreator is based heavy on the script of Auto-Gui of Adventure, but written for V2.

This is a beta release but a lot of functions are already working great.
- Import Gui is working very great (press the button and activate another window and press F12)
- Placing, moving controls and resizing them
- Adding events

It is not as great as AutoGui, but it is a good start.

V2GuiCreator
V2 GuiCreator.png
V2 GuiCreator.png (105.69 KiB) Viewed 2609 times

hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: [V2] V2GuiCreator

Post by hasantr » 18 Jul 2022, 00:01

This will be very helpful in the V2 Migration. Thank you.

AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: [V2] V2GuiCreator

Post by AHK_user » 18 Jul 2022, 13:51

hasantr wrote:
18 Jul 2022, 00:01
This will be very helpful in the V2 Migration. Thank you.
Thanks for the compliment.
I was also starting experimenting with using a Scintilla control, but this it still in testing fase and gives some errors when running the code.

User avatar
oldbrother
Posts: 273
Joined: 23 Oct 2013, 05:08

Re: [V2] V2GuiCreator

Post by oldbrother » 31 Jul 2022, 07:25

Thank you! It will be perfect if Autoxywh for V2 can be integrated.

User avatar
haichen
Posts: 631
Joined: 09 Feb 2014, 08:24

Re: [V2] V2GuiCreator

Post by haichen » 28 Aug 2022, 06:40

Is there a V2 version of Autoxywh yet?

AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: [V2] V2GuiCreator

Post by AHK_user » 05 Sep 2022, 00:31

haichen wrote:
28 Aug 2022, 06:40
Is there a V2 version of Autoxywh yet?
Here is some code that can help you, this function automatically resizes gui controls, just add properties like
GuiObject.LeftMargin := 10

You can also hook them to other controls by telling the reference object GuiCtrlObj.PosRef and the x and y offset.

Code: Select all

; Automatically change size of controls based on properties
Gui_Size(thisGui, MinMax:=1, Width:="", Height:= "") {
    if MinMax = -1	; The window has been minimized. No action needed.
        return
    ;DllCall("LockWindowUpdate", "Uint", thisGui.Hwnd)
    (Width="" && WinGetPos(, , &Width, &Height, thisGui)) ; autocollect missing parameters

    For Hwnd, GuiCtrlObj in thisGui {
        GuiCtrlObj.GetPos(&cX, &cY, &cWidth, &cHeight)
        if (GuiCtrlObj.HasProp("LeftMargin") && GuiCtrlObj.LeftMargin!="") {
            GuiCtrlObj.Move(, , Width - cX - GuiCtrlObj.LeftMargin, )
        }
        if (GuiCtrlObj.HasProp("LeftDistance") && GuiCtrlObj.LeftDistance!="") {
            GuiCtrlObj.Move(Width - cWidth - GuiCtrlObj.LeftDistance, , , )
        }
        if (GuiCtrlObj.HasProp("BottomDistance") && GuiCtrlObj.BottomDistance!="") {
            GuiCtrlObj.Move(, Height - cHeight - GuiCtrlObj.BottomDistance, , )
        }
        if (GuiCtrlObj.HasProp("BottomMargin") && GuiCtrlObj.BottomMargin!="") {
            GuiCtrlObj.Move(, , , Height - cY - GuiCtrlObj.BottomMargin)
        }
        if (GuiCtrlObj.HasProp("PosRef") && GuiCtrlObj.PosRef!="") {
            GuiCtrlPosRef := GuiCtrlObj.PosRef
            
            loop{
                if (GuiCtrlPosRef.Visible){
                    break
                } else{
                    if (GuiCtrlPosRef.hasProp("PosRef")){
                        GuiCtrlPosRef := GuiCtrlPosRef.PosRef
                    } else{
                        
                        Break
                    }
                }
            }
            GuiCtrlPosRef.GetPos(&rX, &rY, &rW, &rH)
            if (!GuiCtrlPosRef.Visible){
                GuiCtrlObj.Move(, rY, , )
            }
            else{
                GuiCtrlObj.Move(, rY+(GuiCtrlObj.HasProp("yOffset") ? GuiCtrlObj.yOffset : 0)+(GuiCtrlObj.HasProp("yMargin") ? rH+GuiCtrlObj.yMargin : 0), , )
            }
        }
    }
}

User avatar
haichen
Posts: 631
Joined: 09 Feb 2014, 08:24

Re: [V2] V2GuiCreator

Post by haichen » 05 Sep 2022, 10:00

I don't have time to try it out at the moment, but thanks for this. :-)

Post Reply

Return to “Scripts and Functions (v2)”