Page 1 of 1

[V2] V2GuiCreator

Posted: 19 Jun 2022, 14:08
by AHK_user
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 2727 times

Re: [V2] V2GuiCreator

Posted: 18 Jul 2022, 00:01
by hasantr
This will be very helpful in the V2 Migration. Thank you.

Re: [V2] V2GuiCreator

Posted: 18 Jul 2022, 13:51
by AHK_user
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.

Re: [V2] V2GuiCreator

Posted: 31 Jul 2022, 07:25
by oldbrother
Thank you! It will be perfect if Autoxywh for V2 can be integrated.

Re: [V2] V2GuiCreator

Posted: 28 Aug 2022, 06:40
by haichen
Is there a V2 version of Autoxywh yet?

Re: [V2] V2GuiCreator

Posted: 05 Sep 2022, 00:31
by AHK_user
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), , )
            }
        }
    }
}

Re: [V2] V2GuiCreator

Posted: 05 Sep 2022, 10:00
by haichen
I don't have time to try it out at the moment, but thanks for this. :-)