Code: Select all
#SingleInstance Force
Gui, Color,, Yellow
Gui, Add, Button, x2 y2 w70 h20 gLight vLightBttn, Light
Gui, Add, Edit, x2 y25 w70 h20 vLight -VScroll
Gui, Add, Button, x72 y2 w70 h20 vNameBttn gName, Name
Gui, Add, Edit, x72 y25 w70 h20 vName -VScroll
Gui, Add, Button, x1050 y150 w50 h20 gCoordates
Gui, Add, Button, x142 y2 w70 h20 vCoordsBttn gCoords, Coords
Gui, Add, Edit, x142 y25 w70 h20 vCoords -VScroll
Gui +LastFound
Winset, TransColor, Yellow 255
Gui, Show, xcenter ycenter w1100 h200
Return
GuiClose:
ExitApp
Return
Coordates:
WinGetPos, XPositions, YPositions
GuiControlGet, Positions, Pos, Light
MsgBox % XPositions ":" YPositions ":" Positionsw ":" Positionsh
Return
Light:
Gui, Submit, NoHide
GuiControlGet, Field,, Light
WinGetPos, Xpos, Ypos
GuiControlGet, GBPos, Pos, Light
GBPosx+=GBPosw
GBPosy+=GBPosh
MouseMove, GBPosw, GBPosh,, R
Loop,
{
MouseGetPos, X, Y
wThis := X-GBPosx+GBPosw
hThis := Y-GBPosy+GBPosh-47
GuiControl, Move, Light, w%wThis% h%hThis%
wthis+=3
GuiControl, Move, Name, x%wThis%
GuiControl, Move, NameBttn, x%wThis%
GuiControlGet, Temp, Pos, Name
wThis+=Tempw
GuiControl, Move, Coords, x%wThis%
GuiControl, Move, CoordsBttn, x%wThis%
Sleep 10
}
Until GetKeyState("LButton")
Return
Name:
Gui, Submit, NoHide
GuiControlGet, Field,, Name
WinGetPos, Xpos, Ypos
GuiControlGet, GBPos, Pos, Name
GBPosx+=GBPosw
GBPosy+=GBPosh
MouseMove, GBPosw, GBPosh,, R
Loop,
{
MouseGetPos, X, Y
wThis := X-GBPosx+GBPosw
hThis := Y-GBPosy+GBPosh-47
GuiControl, Move, Name, w%wThis% h%hThis%
wthis+=3
GuiControl, Move, Coords, x%wThis%
GuiControl, Move, CoordsBttn, x%wThis%
Sleep 10
}
Until GetKeyState("LButton")
Return
Coords:
Gui, Submit, NoHide
GuiControlGet, Field,, Coords
WinGetPos, Xpos, Ypos
GuiControlGet, GBPos, Pos, Coords
GBPosx+=GBPosw
GBPosy+=GBPosh
MouseMove, GBPosw, GBPosh,, R
Loop,
{
MouseGetPos, X, Y
wThis := X-GBPosx+GBPosw
hThis := Y-GBPosy+GBPosh-47
GuiControl, Move, Coords, w%wThis% h%hThis%
Sleep 10
}
Until GetKeyState("LButton")
Return
GuiSize:
AutoXYWH("xwh", "Light" "Name" "NameBttn" "Coords" "CoordsBttn")
AutoXYWH("xwh", "Name" "Coords" "CoordsBttn")
Return
; =================================================================================
; Function: AutoXYWH
; Move and resize control automatically when GUI resizes.
; Parameters:
; DimSize - Can be one or more of x/y/w/h optional followed by a fraction
; add a '*' to DimSize to 'MoveDraw' the controls rather then just 'Move', this is recommended for Groupboxes
; cList - variadic list of ControlIDs
; ControlID can be a control HWND, associated variable name, ClassNN or displayed text.
; The later (displayed text) is possible but not recommend since not very reliable
; Examples:
; AutoXYWH("xy", "Btn1", "Btn2")
; AutoXYWH("w0.5 h 0.75", hEdit, "displayed text", "vLabel", "Button1")
; AutoXYWH("*w0.5 h 0.75", hGroupbox1, "GrbChoices")
; ---------------------------------------------------------------------------------
; Release date: 2014-7-03
; Author : tmplinshi (mod by toralf)
; requires AHK version : 1.1.13.01+
; =================================================================================
AutoXYWH(DimSize, cList*){ ; http://ahkscript.org/boards/viewtopic.php?t=1079
static cInfo := {}
For i, ctrl in cList {
ctrlID := A_Gui ":" ctrl
If ( cInfo[ctrlID].x = "" ){
GuiControlGet, i, %A_Gui%:Pos, %ctrl%
GuiControlGet, Hwnd, %A_Gui%:Hwnd, %ctrl%
MMD := InStr(DimSize, "*") ? "MoveDraw" : "Move"
fx := fy := fw := fh := 0
For i, dim in (a := StrSplit(RegExReplace(DimSize, "i)[^xywh]")))
If !RegExMatch(DimSize, "i)" dim "\s*\K[\d.-]+", f%dim%)
f%dim% := 1
cInfo[ctrlID] := { x:ix, fx:fx, y:iy, fy:fy, w:iw, fw:fw, h:ih, fh:fh, gw:A_GuiWidth, gh:A_GuiHeight, a:a , m:MMD}
}Else If ( cInfo[ctrlID].a.1) {
dgx := dgw := A_GuiWidth - cInfo[ctrlID].gw , dgy := dgh := A_GuiHeight - cInfo[ctrlID].gh
For i, dim in cInfo[ctrlID]["a"]
Options .= dim (dg%dim% * cInfo[ctrlID]["f" dim] + cInfo[ctrlID][dim]) A_Space
GuiControl, % A_Gui ":" cInfo[ctrlID].m , % ctrl, % Options
} } }