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

Get help with using AutoHotkey and its commands and hotkeys
Clemens375
Posts: 104
Joined: 11 May 2020, 11:54

How can I display "startingNum" in a Gui?

05 Aug 2020, 11:59

Hello,

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

Thank you!
User avatar
boiler
Posts: 5919
Joined: 21 Dec 2014, 02:44

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

05 Aug 2020, 14:01

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
Clemens375
Posts: 104
Joined: 11 May 2020, 11:54

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

06 Aug 2020, 02:26

@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
User avatar
boiler
Posts: 5919
Joined: 21 Dec 2014, 02:44

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

06 Aug 2020, 06:40

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
Clemens375
Posts: 104
Joined: 11 May 2020, 11:54

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

08 Aug 2020, 12:39

@boiler

Thank you!

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

Code: Select all

AddButton:
	GuiControl,, startingNum, % "Number: " ++StartingNum
	return
	
User avatar
boiler
Posts: 5919
Joined: 21 Dec 2014, 02:44

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

08 Aug 2020, 12:47

Code: Select all

AddButton:
	GuiControl,, startingNum, % "Number: " . (startingNum += 12)
	return
Clemens375
Posts: 104
Joined: 11 May 2020, 11:54

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

09 Aug 2020, 05:32

@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!
User avatar
boiler
Posts: 5919
Joined: 21 Dec 2014, 02:44

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

09 Aug 2020, 07:56

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).

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], electrone77, evilmanimani, FanaticGuru, KerryKaetzchen, mikeyww, Sabestian Caine and 50 guests