GodForsakenSoul Posted December 19, 2009 Share Posted December 19, 2009 hello again. this time i'm looking to restrict the info to be input in the input thing to numbers only. unless there's a nifty line of code i can add, i'd prefer to do it something like this $inputk1=GUICtrlCreateInput("",0,40,100,20) if $inputk1 is not numbers then msgbox(1,"","please input numbers only") endif suggestions? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 19, 2009 Moderators Share Posted December 19, 2009 GodForsakenSoul,Just create the input with the $ES_NUMBER style. It is all in the Help file..... M23 xixautoeat and Chiitus 2 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
RobertH Posted December 19, 2009 Share Posted December 19, 2009 GodForsakenSoul,Just create the input with the $ES_NUMBER style. It is all in the Help file..... M23In the Example Script, can you demonstrate how to use $ES_NUMBER to force the user to input an integer only instead of autoit?;; AutoIt Version: 3.0; Language: English; Platform: Win9x/NT; Author: Jonathan Bennett (jon@hiddensoft.com);; Script Function:; Demonstrates the InputBox, looping and the use of @error.;; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)$answer = MsgBox(4, "AutoIt Example (English Only)", "This script will open an input box and get you to type in some text. Run?"); Check the user's answer to the prompt (see the help file for MsgBox return values); If "No" was clicked (7) then exit the scriptIf $answer = 7 Then MsgBox(4096, "AutoIt", "OK. Bye!") ExitEndIf; Loop around until the user gives a valid "autoit" answer$bLoop = 1While $bLoop = 1 $text = InputBox("AutoIt Example", "Please type in the word ""autoit"" and click OK") If @error = 1 Then MsgBox(4096, "Error", "You pressed 'Cancel' - try again!") Else ; They clicked OK, but did they type the right thing? If $text <> "autoit" Then MsgBox(4096, "Error", "You typed in the wrong thing - try again!") Else $bLoop = 0 ; Exit the loop - ExitLoop would have been an alternative too EndIf EndIfWEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 19, 2009 Moderators Share Posted December 19, 2009 RobertH,Welcome to the AutoIt forum. Does this make it clear? Try entering anything other than a number! #include <GUIConstantsEx.au3> #include <EditConstants.au3> $hGUI = GUICreate("Test", 500, 500) $hInput = GUICtrlCreateInput("", 10, 10, 250, 20, $ES_NUMBER) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndCome back if it does not.M23P.S. When you psot code, please use Code tags. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here). Chiitus 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
RobertH Posted December 20, 2009 Share Posted December 20, 2009 Thank you. It makes it clear and opens my eyes to another useful part of AutoIt. RobertH, Welcome to the AutoIt forum. Does this make it clear? Try entering anything other than a number! #include <GUIConstantsEx.au3> #include <EditConstants.au3> $hGUI = GUICreate("Test", 500, 500) $hInput = GUICtrlCreateInput("", 10, 10, 250, 20, $ES_NUMBER) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Come back if it does not. M23 P.S. When you psot code, please use Code tags. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here). Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 20, 2009 Moderators Share Posted December 20, 2009 RobertH,Glad I could help! M23P.S. When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
RobertH Posted December 22, 2009 Share Posted December 22, 2009 Thanks Melba23. With the help of this forum I was able to put together the following code. But I still have one problem that I can't seem to figure out. If the person does not enter a number and presses the "OK" button, the program will still try to go and download the zipped sales file. It will not work because there is no employee ID number to attach to the filename. I think that I have to use an "IF THEN ELSE" statement in the Func OKButton section but I haven't been able to get it right. Can someone point me in the right direction with some examples? #include <GUIConstantsEx.au3> #include <EditConstants.au3> Opt("GUIOnEventMode", 1) $hGUI = GUICreate("Enter Employee ID Number", 275, 70) $empID = GUICtrlCreateInput("", 10, 10, 250, 20, $ES_NUMBER) $okbutton = GUICtrlCreateButton("OK", 10, 35, 60) GUICtrlSetOnEvent($okbutton, "OKButton") $cancelbutton = GUICtrlCreateButton("Cancel", 200, 35, 60) GUICtrlSetOnEvent($cancelbutton, "CANCELButton") GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func OKButton() Run("C:\Program Files\Internet Explorer\IEXPLORE.EXE http://www.fakewebsite.com/sales/individual/sales_data/" & GUICtrlRead($empID) & "weekly.zip") EndFunc Func CANCELButton() Exit EndFunc Func CLOSEClicked() Exit EndFunc Link to comment Share on other sites More sharing options...
Bert Posted December 22, 2009 Share Posted December 22, 2009 Take a look at StringRegExp. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 22, 2009 Moderators Share Posted December 22, 2009 RobertH, Just check if there is something in the input. Change the relevant lines thus: ; This must be Global so the function can see it Global $empID = GUICtrlCreateInput("", 10, 10, 250, 20, $ES_NUMBER) ; Check there is something in the input - it can only be a number so we need not worry about using IsNumber Func OKButton() If GUICtrlRead($empID) <> "" Then Run(.......) EndFunc As usual, ask if anything is unclear. If you wanted to get really fancy we could check it was a valid employee number...... Take a look at StringRegExpNot necessary as we are dealing with all-number integers, thank goodness. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Bert Posted December 22, 2009 Share Posted December 22, 2009 (edited) Good call. Much simpler your way. Edited December 22, 2009 by Volly The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
kootchy71 Posted November 7, 2014 Share Posted November 7, 2014 (edited) expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> $GUI = GUICreate("Login",300,300,-1,-1,0x16C80000,0x00000181) Global $idlfile = GUICtrlCreateInput("",5, 5,90,20,$ES_NUMBER) Global $idtfile = GUICtrlCreateInput("",5,30,90,20,$ES_NUMBER) Global $idsfile = GUICtrlCreateInput("",5,60,90,20,$ES_NUMBER) $LOGIN = GUICtrlCreateButton("LOGIN",20,160,60,20) GUISetState(@SW_SHOW,$GUI) While 1 $MSG = GUIGetMsg() Switch $MSG Case $LOGIN If VerifyLogin(GUICtrlRead($idlfile),GUICtrlRead($idtfile),GUICtrlRead($idsfile)) = 1 Then GUIDelete($GUI) $slfile = FileOpen("C:\Users\zahra\AppData\Roaming\MetaQuotes\Terminal\018A810E5020C8CCAC9958F668872FB7\MQL4\Files\lotmm.csv", 1) $stfile = FileOpen("C:\Users\zahra\AppData\Roaming\MetaQuotes\Terminal\018A810E5020C8CCAC9958F668872FB7\MQL4\Files\TP.csv", 1) $ssfile = FileOpen("C:\Users\zahra\AppData\Roaming\MetaQuotes\Terminal\018A810E5020C8CCAC9958F668872FB7\MQL4\Files\SL.csv", 1) filewrite($slfile,GUICtrlRead($idlFile) & @CRLF) filewrite($stfile,GUICtrlRead($idtFile) & @CRLF) filewrite($ssfile,GUICtrlRead($idsFile) & @CRLF) Else MsgBox(-1,"Login Session","INCORRECT USERNAME OR PASSWORD") EndIf Case -3 Exit EndSwitch WEnd Func VerifyLogin($idlfile,$idtfile,$idsfile) If $idlfile > 0.01 And $idtfile > 1 And $idsfile > 1 Then Return 1 Else Return 0 EndIf EndFunc please help if i should had of receives of the good returns with the form submission as the correct of number as those with the input box. the script above returns of the number 0 with the records on csv files. yet the $ES_NUMBER customs referring of the number only with the chance on submitting entries but the returns of any number with the forms shows of "0" with each of csv files had just tried to add of the $ES_NUMBER with the Global constant with the id string details with the form requests. should those had as much with each of calling with the sentences on process? Edited November 7, 2014 by kootchy71 Link to comment Share on other sites More sharing options...
Malkey Posted November 8, 2014 Share Posted November 8, 2014 You should have started your own thread instead of tacking on to a 5 year one. Your problem actually has nothing to do with $ES_NUMBER. You are deleting the Graphic User Interface, GUIDelete($GUI), then you are trying to read the controls belonging to that now non- existent window. The reading of the non-existent controls returns zero which you are writing to the csv files. Link to comment Share on other sites More sharing options...
xixautoeat Posted May 10, 2016 Share Posted May 10, 2016 On 12/19/2009 at 1:37 AM, Melba23 said: GodForsakenSoul, Just create the input with the $ES_NUMBER style. It is all in the Help file..... M23 Thank you. 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