Where is the error in this code???... Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
MancioDellaVega
Posts: 44
Joined: 16 May 2020, 12:27

Where is the error in this code???...

02 Jul 2020, 23:37

I found this script https://autohotkey.com/board/topic/54443-box-ie-draw-simple-gui-based-boxes-on-screen/
by Wicked...but seems doesn't work right...
When i run it i have this result wrong.. the lines are too long
Screenshot (103).png
Screenshot (103).png (139.09 KiB) Viewed 1424 times

Code: Select all

#SingleInstance,force
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
CoordMode, Tooltip, Screen



SetBatchLines, -1
SetWinDelay, -1

Box_Init("FF0000")

Loop {
   MouseGetPos, , , Window, Control, 2
   WinGetPos, X1, Y1, , , ahk_id %Window%
   ControlGetPos, X, Y, W, H, , ahk_id %Control%
   if(X)
      Box_Draw(X + X1, Y + Y1, W, H, 2)
   Sleep,100 
}


return

Esc::ExitApp



/*
Box_Init - Creates the necessary GUIs.

C - The color of the box.
*/

Box_Init(C="FF0000") {
	Gui, 96: +ToolWindow -Caption +AlwaysOnTop +LastFound
	Gui, 96: Color, % C
	Gui, 97: +ToolWindow -Caption +AlwaysOnTop +LastFound
	Gui, 97: Color, % C
	Gui, 98: +ToolWindow -Caption +AlwaysOnTop +LastFound
	Gui, 98: Color, % C
	Gui, 99: +ToolWindow -Caption +AlwaysOnTop +LastFound
	Gui, 99: Color, % C
}

/*
Box_Draw - Draws a box on the screen using 4 GUIs.

X - The X coord.

Y - The Y coord.

W - The width of the box.

H - The height of the box.

T - The thickness of the borders.

O - The offset. O - Outside. C - Centered. I - Inside.
*/

Box_Draw(X, Y, W, H, T="1", O="I") {
	If(W < 0)
		X += W, W *= -1
	If(H < 0)
		Y += H, H *= -1
	If(T >= 2)
	{
		If(O == "O")
			X -= T, Y -= T, W += T, H += T
		If(O == "C")
			X -= T / 2, Y -= T / 2
		If(O == "I")
			W -= T, H -= T
	}
	Gui, 96: Show, % "x" X " y" Y " w" W " h" T " NA", Horizontal 1
	Gui, 98: Show, % "x" X " y" Y + H " w" W " h" T " NA", Horizontal 2
	Gui, 97: Show, % "x" X " y" Y " w" T " h" H " NA", Vertical 1
	Gui, 99: Show, % "x" X + W " y" Y " w" T " h" H " NA", Vertical 2
}

/*
Box_Destroy - Destoyes the 4 GUIs.
*/

Box_Destroy() {
	Loop, 4
		Gui, % A_Index + 95 ":  Destroy"
}

/*
Box_Hide - Hides the 4 GUIs.
*/

Box_Hide() {
	Loop, 4
		Gui, % A_Index + 95 ":  Hide"
}

MancioDellaVega
Posts: 44
Joined: 16 May 2020, 12:27

Re: Where is the error in this code???...

03 Jul 2020, 03:47

Thanks. All good now... :clap:
Courses on AutoHotkey

Return to “Ask For Help”

Who is online

Users browsing this forum: bby, Bing [Bot], DenisS, mikeyww and 40 guests