Sign in to follow this  
Followers 0

Get value only if number [solved]

4 posts in this topic

#1 ·  Posted (edited)

Trying to put in a GUI(textbox) and want it to get the information only if the input is numbers


Case $Start_button

$var[2] = GUICtrlRead($TimeoutInput)

If $TimeoutInput = ????


Anyone? =)

Edited by Akarillon

Challenge accepted!

Share this post

Link to post
Share on other sites

$str = GUICtrlRead($ID)




Share this post

Link to post
Share on other sites

thanks :mellow:

Challenge accepted!

Share this post

Link to post
Share on other sites

Better yet.

Use the proper style if it is indeed an input box. (Help File)

Set the controls style to BitOr($GUI_SS_Default_Input, $ES_Number) so it won't accept anything except digits 0-9


Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver: - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • spuuunit
      By spuuunit
      Is it possible to know if a textbox is active in FireFox?
      This is what I want:
      if (Textbox in FireFox == Active) { }
    • fopetesl
      By fopetesl
      One statement of GUICtrlRead() fails. Result is always "Long/Short" in written file.
      The other GUICtrlRead() calls work as expected
      Func GetScanSettings() ; Read User Input for scan Local $collectusername, $collectlot, $collectsample $UserFile = "Sample.dat" ; Global $UserFile = save this scan's parameters $datafile = FileOpen($UserFile) If( $datafile <> -1) Then $collectusername = FileReadLine($datafile, 1) EndIf FileClose($datafile) ; now open a new 'clean' file.. $datafile = FileOpen($UserFile,$FO_OVERWRITE ) ;Create GUI $Main = GUICreate('Enter Sample Detail', 500, 500) Opt("GUICoordMode",1) If( $collectusername <> "") Then $username = GUICtrlCreateInput($collectusername,100,20,100,20) Else $username = GUICtrlCreateInput('',100,20,100,20) EndIf $usernamelabel = GUICtrlCreateLabel('Username',30,22) $FileName = GUICtrlCreateInput("",100,45,100,0) $FileNamelabel = GUICtrlCreateLabel('File Name',30,47) $BatchNum = GUICtrlCreateInput("",100,65,100,0) $BatchNumlabel = GUICtrlCreateLabel('Lot',30,72) $SampleNum = GUICtrlCreateInput("",100,85,100,0) $SampleNumlabel = GUICtrlCreateLabel('Sample',30,97) $SampleLS = GUICtrlCreateInput("",100,105,100,0) $SampleNumLS = GUICtrlCreateLabel('Long/Short',30,117) $Button_1 = GUICtrlCreateButton ("OK", 190, 170, 0, 0, 0x0001) GUISetState (); Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() ; complete data entries Select Case $msg = $Button_1 $collectusername = GUICtrlRead($username) WinSetState('Collect Username','',@SW_HIDE) $collectfilename = GUICtrlRead($FileName) $collectlot = GUICtrlRead($BatchNum) $collectsample = GUICtrlRead($SampleNum) $collectLS = GUICtrlRead($SampleNumLS) ; Do ; $collectLS = GUICtrlRead($SampleNumLS) ; If $collectLS <> 'Long' And $collectLS <> 'Short' Then ; Soundplay("Windows XP Error.wav", 1) ; $collectLS = "" ; EndIf ; Until $collectLS = 'Long' Or $collectLS = 'Short' ExitLoop EndSelect Wend GUIDelete($Main) FileWrite($datafile,$collectusername & @CRLF & $collectfilename & @CRLF & $collectlot _ & @CRLF & $collectsample & @CRLF & 'Long' & @CRLF ) ; $collectLS & @CRLF) FileClose($datafile) EndFunc ;<=== GetScanSettings ================== I also tried to force user to enter either 'Short' or 'Long' but I got that wrong also
      The final FileWrite() edited so I do have a correct result.
      Pete FilenamePete Num1 Samp2 Long/Short  
    • 232showtime
      By 232showtime
      im getting strange output in array display,$split_[1] is not properly aligned to other arrays and why guictrlsetdata is not writting any data if i put comma(,) at the end of the text in $Input1???
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #Region ### START Koda GUI section ### Form=C:\Users\user\Desktop\Script\StringSplit.kxf $Form1 = GUICreate("Form1", 623, 449, 192, 114) $Input1 = GUICtrlCreateInput("50UGITQ421X, 50UGITQ422X, 50UGITQ423X, 50UGITQ427X, 50UGITQ431X, 50UGITQ435X, 50UGITQ436X, 50UGITQ437X, 50UGITQ441X, 50UGITQ445X, 50UGITQ449X, 50UGITQ453X, 50UGITQ454X, 50UGITQ455X, 50UGITQ459X", 24, 16, 553, 21) $Split = GUICtrlCreateButton("Split", 24, 48, 75, 25) $List1 = GUICtrlCreateList("", 24, 96, 553, 97) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Split $read = GUICtrlRead($Input1) $split_ = StringSplit($read, ",") $Max = UBound($split_, 1) For $i = 1 To UBound($split_) - 1 ConsoleWrite($split_[$i] & @CRLF) ;~ ControlSetText($Form1, "", $List1, $split_[$i]) GUICtrlSetData($List1, $split_[$i]) ;~ GUICtrlSetData($List1, $split_[$i]) ;~ GUICtrlSetData($List1, $i) Next _ArrayDisplay($split_) EndSwitch WEnd  
    • triodz
      By triodz
      I want the number in a file to be overwritten with the next number up each time a button is pressed. 
      So it is pressed once, the number '1' is written to the file. It is pressed again and the number '2' overwrites the first number.
      At the moment I get the number 1 written, but can't get it to overwrite. What I have so far:
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #Region ### START Koda GUI section ### Form=C:\Users\soulf\Desktop\CalcGui\RLCalc.kxf $Form1 = GUICreate("Form1", 615, 437, 426, 141) $One = GUICtrlCreateButton("1", 32, 72, 25, 25) GUICtrlSetBkColor(-1, 0xFF0000) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Func First ()     $fPath = "C:\temp\First.txt"     $fOpen = FileOpen ($fPath, 2)     $Counter = FileReadLine ($fpath)     $counter = $counter + 1     $fWrite = filewriteline ($fPath, $counter)     FileClose ($fpath) EndFunc While 1     $nMsg = GUIGetMsg()     Switch $nMsg         Case $GUI_EVENT_CLOSE             Exit         Case $One             Call ("First")     EndSwitch WEnd I tried a Do Until statement, but that just puts the numbers 1 to 5 in the file.
      Any help would be greatly appreciated! 
    • TheDcoder
      By TheDcoder
      After watching a whole day of "Journey into cryptography" at Khan Academy, I have got to know the secrets behind some sneaky things! . This is one of em', A PRNG (Pseudo Random Number Generator). Its features (atleast what I believe) are:
      Simple, short and crappy. Great for beginners who are baffled by the mechanics of random number generation in computers! Support for custom seeds! EIGHT DIGITS OF RANDOMNESS!!! Unlike all other PRNGs, This one is predictable 1000 possible PRNs when using @MSEC as the seed. No option for min or max, the min is 10000000 and the max is 99999999. The Unlicensed . #cs LICENSE This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to <> #ce LICENSE ; #FUNCTION# ==================================================================================================================== ; Name ..........: MiddleSquareRandom ; Description ...: Pseudo-random number generator based on the infamous "Middle Sqaure" method. ; Syntax ........: MiddleSquareRandom([$iSeed = @MSEC]) ; Parameters ....: $iSeed - [optional] A seed for generation of the random number. Default is @MSEC. ; Return values .: A pseudorandom 8 digit integer. ; Author ........: John von Neumann ; Modified ......: Damon Harris (TheDcoder) - Conversion into AutoIt and simplification + further crappification. ; Remarks .......: Fun Fact - The output is based on the $iSeed passed, Same $iSeed = Same pseudo-random number. ; Related .......: Random() ; Link ..........: ; Example .......: ConsoleWrite(MiddleSquareRandom() & @CRLF) ; =============================================================================================================================== Func MiddleSquareRandom($iSeed = @MSEC) Local Const $TURNS = 8 Local $sRandomNumber, $sSeed For $iTurn = 1 To $TURNS $iSeed = $iSeed * 2 $sSeed = String($iSeed) $sRandomNumber &= StringMid($sSeed, Ceiling(StringLen($iSeed) / 2), 1) Next Return Int($sRandomNumber) EndFunc  
      Enjoy your numbers, TD .