simplify stuff in script by having a variable in variable

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
wryyymuda
Posts: 32
Joined: 21 Sep 2018, 21:43

simplify stuff in script by having a variable in variable

07 Nov 2018, 20:26

so i made this

Code: Select all

ranxy = 0
gui, add, text, x1 y1 w100 h100 varxy1, a
gui, add, text, x1 y1 w100 h100 varxy2, b
gui, add, text, x1 y1 w100 h100 varxy3, c
gui, add, text, x1 y1 w100 h100 varxy4, d
gui, add, text, x1 y1 w100 h100 varxy5, e
gui, add, text, x1 y1 w100 h100 varxy6, f
gui, add, text, x1 y1 w100 h100 varxy7, g 
gui, add, text, x1 y1 w100 h100 varxy8, h
gui, show, h700 w700
loop, 
	{
	sleep, 100
	ranxy = 0
	loop 8 {
		ranxy += 1
		random, x%ranxy%, 0, 690
		random, y%ranxy%, 0, 690
		}
	ranxy = 0
	guicontrol, move, arxy1, x%x1% y%y1% 
	guicontrol, move, arxy2, x%x2% y%y2%
	guicontrol, move, arxy3, x%x3% y%y3%
	guicontrol, move, arxy4, x%x4% y%y4%
	guicontrol, move, arxy5, x%x5% y%y5%
	guicontrol, move, arxy6, x%x6% y%y6%
	guicontrol, move, arxy7, x%x7% y%y7%
	guicontrol, move, arxy8, x%x8% y%y8%
	}
	return
	
guiclose:
	exitapp
	return
so i want o simplify

Code: Select all

	guicontrol, move, arxy1, x%x1% y%y1% 
	guicontrol, move, arxy2, x%x2% y%y2%
	guicontrol, move, arxy3, x%x3% y%y3%
	guicontrol, move, arxy4, x%x4% y%y4%
	guicontrol, move, arxy5, x%x5% y%y5%
	guicontrol, move, arxy6, x%x6% y%y6%
	guicontrol, move, arxy7, x%x7% y%y7%
	guicontrol, move, arxy8, x%x8% y%y8%
but idk how. any help?
wryyymuda
Posts: 32
Joined: 21 Sep 2018, 21:43

Re: simplify stuff in script by having a variable in variable

07 Nov 2018, 20:28

the purpose of this script is just testing some stuff for another script im making
User avatar
AlphaBravo
Posts: 586
Joined: 29 Sep 2013, 22:59

Re: simplify stuff in script by having a variable in variable

07 Nov 2018, 20:37

Code: Select all

loop, 8
	guicontrol, move, arxy%A_Index%, % "x" X%A_Index% " y" Y%A_Index% 
wryyymuda
Posts: 32
Joined: 21 Sep 2018, 21:43

Re: simplify stuff in script by having a variable in variable

07 Nov 2018, 20:43

thanks. i have shaved off 34 lines of code.
Last edited by wryyymuda on 07 Nov 2018, 20:47, edited 1 time in total.
wryyymuda
Posts: 32
Joined: 21 Sep 2018, 21:43

Re: simplify stuff in script by having a variable in variable

07 Nov 2018, 20:47

Code: Select all

loop 8 
	{
	gui, add, text, x1 y1 w15 h15 varxy%A_index%, %A_index%
	}	
gui, show, h700 w700
loop, {
	sleep, 100
	loop 8 {
		ranxy += 1
		random, x%A_index%, 0, 690
		random, y%A_index%, 0, 690 
		}
	loop, 8 
		{
		guicontrol, move, arxy%A_Index%, % "x" X%A_Index% "y" Y%A_Index%
	}}
guiclose:
	exitapp
this is it now
here is what it was

Code: Select all

x = 1
xx = 300
xxx = 750
yy = 300
yyy = 750
y=1
var1 = 0
mytext = 0
gui, show , w1000 h1000
+,::
loop  {
var1 += 1
random, x1, %xx%, %xxx%
random, y1, %yy%, %yyy%
random, x2, %xx%, %xxx%
random, y2, %yy%, %yyy%
random, x3, %xx%, %xxx%
random, y3, %yy%, %yyy%
random, x4, %xx%, %xxx%
random, y4, %yy%, %yyy%
random, x5, %xx%, %xxx%
random, y5, %yy%, %yyy%
random, x6, %xx%, %xxx%
random, y6, %yy%, %yyy%
random, x7, %xx%, %xxx%
random, y7, %yy%, %yyy%
random, x8, %xx%, %xxx%
random, y8, %yy%, %yyy%
gui, add, text, x%x1% y%y1% vmytext1%var1% , sample text
gui, add, text, x%x2% y%y2% vmytext2%var1% , sample text
gui, add, text, x%x3% y%y3% vmytext3%var1% , sample text
gui, add, text, x%x4% y%y4% vmytext4%var1% , sample text
gui, add, text, x%x5% y%y5% vmytext5%var1% , sample text
gui, add, text, x%x6% y%y6% vmytext6%var1% , sample text
gui, add, text, x%x7% y%y7% vmytext7%var1% , sample text
gui, add, text, x%x8% y%y8% vmytext8%var1% , sample text
;sleep, 1000
guicontrol, hide , mytext1%var1%
guicontrol, hide , mytext2%var1%
guicontrol, hide , mytext3%var1%
guicontrol, hide , mytext4%var1%
guicontrol, hide , mytext5%var1%
guicontrol, hide , mytext6%var1%
guicontrol, hide , mytext7%var1%
guicontrol, hide , mytext8%var1%
}

guiclose:
	exitapp
	return

.::pause

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Aqualest, jdfnnl, serenite, yanjujino1 and 323 guests