Simple way to get UpDown box to move in values not 1 (non unitary) Topic is solved

Helpful script writing tricks and HowTo's
IWantItAll2
Posts: 8
Joined: 14 Jun 2023, 10:00

Simple way to get UpDown box to move in values not 1 (non unitary)  Topic is solved

Post by IWantItAll2 » 15 Jun 2023, 04:48

I Hope this helps someone. It took me a long time to work out how to get this to work and i was very frustrated.
The code is a simple way to change a Updown box in values that aren't 1. so you can change Inc to any value and it should work.
P.S im sure someone smarter than me can make an easier way, but i couldn't find any help online for this!

Code: Select all

; AutoHotkey Version: 2.0.2.00
; Language:       English
; Platform:       Win10
; Function: adjust upDown control in steps that arent 1

Inc := 0.25 ; amount to increment by

myGUI :=Gui()

	myGUI.Add("Text", , "My value")
	myGUI.Add("Edit", "ys w80 vTextValue", "5")	
	myGUI.Add("upDown", "-2 vUDValue Range-1-1").OnEvent("Change", UD_change) ;-2 to make UD and edit seperate
	
myGUI.Show()
myGUI.submit(0)
return

UD_change(*) ; updown clicked
{
	FormVars := myGUI.Submit(0)

	If( FormVars.UDValue < 0 ) ; decide if value should go up or down
	{
		newValue := FormVars.TextValue - Inc
	}
	Else
	{				
		newValue := FormVars.TextValue + Inc		
	}
	
	myGUI['UDValue'] = 0 ;set UD to 0 so value out is -1 or 1
	myGUI['TextValue'].Value := newValue ;set the value back in the form
	return	
}

Return to “Tutorials (v2)”