Since I think UpDown control is limited or maybe not so very well designed (damn it, neither A_GuiEvent nor A_EventInfo tells you which button was pressed), so I decided to use the below alternative instead (Hope you find it useful! Thanks):
Code: Select all
gui, add, Edit, w50 vUserValue center gUpDown, 5
gui, add, button, x+5 h11 w20 gUpDown, ▴
gui, add, button, y+0 h11 w20 gUpDown, ▾
gui, add, text, x+5 y+-18, Increment=
gui, add, edit, x+5 w50 vIncrement center, 1
gui, show
return
UpDown: ;_________________ UpDown ____________________
guicontrolget, UserValue
guicontrolget, Increment
;"==" is always case-sensitive
if (a_guicontrol == "▴")
UserValue := UserValue + Increment
if (a_guicontrol == "▾")
UserValue := UserValue - Increment
;Ternary operator, "? = if", ": = else"
;in the exmple below, Range is from -50 to 100
if UserValue is number
UserValue := UserValue < -50 ? -50 : UserValue > 100 ? 100 : UserValue
else if (UserValue != "" and UserValue != "-")
UserValue := "0"
guicontrol, -g, UserValue ;remove gLabel from "UserValue" control in order to prevent infinite loop
guicontrol, , UserValue, % UserValue
send, {End} ;move the caret\cursor to the end of the edit control
guicontrol, +gUpDown, UserValue ;add gLabel back again to "UserValue" control
hh++ ;just for test
tooltip, % "loop test " hh ;if "guicontrol, -g, UserValue" above line was not in use, this tooltip would go into an infinite loop
return
guiclose: ;_________________ gui close _________________
exitapp