Page 1 of 1

How can I display "startingNum" in a Gui?

Posted: 05 Aug 2020, 11:59
by John1
Hello,

How can I display "startingNum" in a Gui? and when it changes is display there?

Thank you!

Re: How can I display "startingNum" in a Gui?  Topic is solved

Posted: 05 Aug 2020, 14:01
by boiler
Use GuiControl to change what is displayed in controls, as shown here:

Code: Select all

startingNum := 1
Gui, Add, Text, x80 w100 vstartingNum, % "Number: " startingNum
Gui, Add, Button, xm yp+30 w200 gAddButton, Click here to add 1 to the number
Gui, Show
return

AddButton:
	GuiControl,, startingNum, % "Number: " ++StartingNum
return

GuiClose:
ExitApp

Re: How can I display "startingNum" in a Gui?

Posted: 06 Aug 2020, 02:26
by John1
@boiler

Thank you! Great!

How can I do that the startingNum at the Gui get -50 at string 2 and -100 at string 3?

Code: Select all

:T:wol::
Random, Var,1,3
send, % string%Var% 
Send, {ENTER}

string1 =You lose no hit points{!}
string2 =You lose 50 hit points{!}
string3 =You lose 100 hit points{!}
return

Re: How can I display "startingNum" in a Gui?

Posted: 06 Aug 2020, 06:40
by boiler
The string definitions need to occur up front. They will be empty the first time you invoke the hotkey the way you’ve shown it.

Code: Select all

startingNum := 1
string1 =You lose no hit points{!}
string2 =You lose 50 hit points{!}
string3 =You lose 100 hit points{!}

Gui, Add, Text, x80 w100 vstartingNum, % "Number: " startingNum
Gui, Add, Button, xm yp+30 w200 gAddButton, Click here to add 1 to the number
Gui, Show
return

:T:wol::
	Random, Var,1,3
	send, % string%Var% 
	Send, {ENTER}
	if (Var != 1) {
		RegExMatch(string%Var%, "\d+", Num)
		startingNum -= Num
		GuiControl,, startingNum, % "Number: " startingNum
	}
return

AddButton:
	GuiControl,, startingNum, % "Number: " ++StartingNum
return

GuiClose:
ExitApp

Re: How can I display "startingNum" in a Gui?

Posted: 08 Aug 2020, 12:39
by John1
@boiler

Thank you!

How can I add here for example 12 to the startingnum?

Code: Select all

AddButton:
	GuiControl,, startingNum, % "Number: " ++StartingNum
	return
	

Re: How can I display "startingNum" in a Gui?

Posted: 08 Aug 2020, 12:47
by boiler

Code: Select all

AddButton:
	GuiControl,, startingNum, % "Number: " . (startingNum += 12)
	return

Re: How can I display "startingNum" in a Gui?

Posted: 09 Aug 2020, 05:32
by John1
@boiler

Thank you!

How can I save this startingnum in the Gui and script. That when I close the script and run again I have all the changes saved.

Have a good day!

Re: How can I display "startingNum" in a Gui?

Posted: 09 Aug 2020, 07:56
by boiler
Use IniWrite to save the value of startingNum to an ini file each time it changes. In place of where you have startingNum := 1 at the beginning of the script, use IniRead to read the last saved value of startingNum, with 1 as a default value (or whatever value you want if there is no value to be read yet).