Giggo Posted February 13, 2022 Share Posted February 13, 2022 Hello forum! I should increase a number inside an inputbox with two Button and a limit of 30 numbers = 1 to 30 Link to comment Share on other sites More sharing options...
Developers Jos Posted February 13, 2022 Developers Share Posted February 13, 2022 Build your own inputbox (GUI) and this should be pretty easy to do. The helpfile and Wiki are your friend to get started. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Giggo Posted February 13, 2022 Author Share Posted February 13, 2022 (edited) ok jos i try to learn quickly but i'm only 5 years old sorry, i'm with dad on the forums solved it was very easy indeed 😁 Edited February 13, 2022 by Giggo Link to comment Share on other sites More sharing options...
Developers Jos Posted February 13, 2022 Developers Share Posted February 13, 2022 That is great that you are trying to learn to program and we will be happy to help you out were we can. Just open the helpfile and look at the example of GUICtrlCreateUpdown() which will show you how you can easily do an up down action. You will of course also need an GUICtrlCreateInput() box to be filled with the new number whenever you click the UpDown buttons. Just try together to get something going and post here when you have questions. Giggo 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Giggo Posted February 13, 2022 Author Share Posted February 13, 2022 $Input1 = GUICtrlCreateInput(20, 130, 27, 40) $UpDown1 = GUICtrlCreateUpDown($Input1) GUICtrlSetLimit($UpDown1, 30, 1) Problem is Updown Height and Width Link to comment Share on other sites More sharing options...
Developers Jos Posted February 13, 2022 Developers Share Posted February 13, 2022 (edited) Just take the example from the helpfile an modify that.... as you can see it will show correctly this way: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Example() Func Example() GUICreate("My GUI UpDown", -1, -1, -1, -1, $WS_SIZEBOX) Local $idInput = GUICtrlCreateInput("2", 10, 10, 50, 20) GUICtrlCreateUpdown($idInput) ; Attempt to resize input control GUICtrlSetPos($idInput, 10, 10, 100, 40) GUISetState(@SW_SHOW) Local $idMsg ; Loop until the user exits. While 1 $idMsg = GUIGetMsg() Switch $idMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idInput $curVal = Number(GUICtrlRead($idInput)) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $curVal = ' & $curVal & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console If $curVal > 30 Then GUICtrlSetData($idInput, "30") If $curVal < 1 Then GUICtrlSetData($idInput, "1") EndSwitch WEnd MsgBox($MB_SYSTEMMODAL, "Updown", GUICtrlRead($idInput)) EndFunc ;==>Example EDIT: Added some MIN / MAX logic.. Let me know when you have questions and please post a runnable script when you want to show an issue. Edited February 13, 2022 by Jos Giggo 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Nine Posted February 13, 2022 Share Posted February 13, 2022 (edited) You can use GUICtrlSetLimit to set the limits of the up/down control and use the same to limit the number of char of the input. Example : Local $idInput = GUICtrlCreateInput("1", 10, 5, 100, 20, $ES_NUMBER) ; only number accepted GUICtrlSetLimit(-1, 2) ; maximum of 2 characters Local $idUpDown = GUICtrlCreateUpdown(-1) GUICtrlSetLimit(-1, 30, 1) ; up/down from 1 to 30 Edited February 13, 2022 by Nine Giggo 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Link to comment Share on other sites More sharing options...
Giggo Posted February 13, 2022 Author Share Posted February 13, 2022 (edited) 1 hour ago, Jos said: Just take the example from the helpfile an modify that.... as you can see it will show correctly this way: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Example() Func Example() GUICreate("My GUI UpDown", -1, -1, -1, -1, $WS_SIZEBOX) Local $idInput = GUICtrlCreateInput("2", 10, 10, 50, 20) GUICtrlCreateUpdown($idInput) ; Attempt to resize input control GUICtrlSetPos($idInput, 10, 10, 100, 40) GUISetState(@SW_SHOW) Local $idMsg ; Loop until the user exits. While 1 $idMsg = GUIGetMsg() Switch $idMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idInput $curVal = Number(GUICtrlRead($idInput)) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $curVal = ' & $curVal & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console If $curVal > 30 Then GUICtrlSetData($idInput, "30") If $curVal < 1 Then GUICtrlSetData($idInput, "1") EndSwitch WEnd MsgBox($MB_SYSTEMMODAL, "Updown", GUICtrlRead($idInput)) EndFunc ;==>Example EDIT: Added some MIN / MAX logic.. Let me know when you have questions and please post a runnable script when you want to show an issue. thanks jos, i had come to your example for a long time, maybe i speak badly, but i see that updown becomes child of the inputbox and is "forced to become a limited control", i seem to understand that it does not fully access the inputbox control because it is forced by it, I can hardly believe that it remains such an unmanageable control, in a nutshell you can't use it externally to the inputbox and give the size you want as a button? Edited February 13, 2022 by Giggo Link to comment Share on other sites More sharing options...
Giggo Posted February 13, 2022 Author Share Posted February 13, 2022 hi forum! I tried to post an example of what I meant, now I have to limit the box to just 30 numbers Code: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $n = 1 $Form = GUICreate("Simple Button UpDown", 400, 67, -1, -1) $iInput = GUICtrlCreateInput("1", 13, 21, 250, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_READONLY,$ES_NUMBER)) $bLeft = GUICtrlCreateButton(ChrW(706), 280, 8, 50, 50) $bRight = GUICtrlCreateButton(ChrW(707), 330, 8, 50, 50) GUISetState(@SW_SHOW) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE exitloop Case $bRight $n += 1 GUICtrlSetData($iInput, $n) Case $bLeft If $n == 1 Then $n = 1 GUICtrlSetData($iInput, $n) Else $n -= 1 GUICtrlSetData($iInput, $n) EndIf EndSwitch WEnd Link to comment Share on other sites More sharing options...
Nine Posted February 13, 2022 Share Posted February 13, 2022 A few comments. 1- Do not use == in if as this is reserved for case-sensitive strings comparaison 2- No need to specify number only if the input box is readonly Here a way to simplify your loop : While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $bRight If $n = 30 Then ContinueLoop $n += 1 GUICtrlSetData($iInput, $n) Case $bLeft If $n = 1 Then ContinueLoop $n -= 1 GUICtrlSetData($iInput, $n) EndSwitch WEnd Giggo 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Link to comment Share on other sites More sharing options...
Giggo Posted February 13, 2022 Author Share Posted February 13, 2022 9 minutes ago, Nine said: A few comments. 1- Do not use == in if as this is reserved for case-sensitive strings comparaison 2- No need to specify number only if the input box is readonly Here a way to simplify your loop : While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $bRight If $n = 30 Then ContinueLoop $n += 1 GUICtrlSetData($iInput, $n) Case $bLeft If $n = 1 Then ContinueLoop $n -= 1 GUICtrlSetData($iInput, $n) EndSwitch WEnd you ROCK bro... thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now