Jump to content

Recommended Posts

  • Moderators
Posted

GodForsakenSoul,

Just create the input with the $ES_NUMBER style. It is all in the Help file..... ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

GodForsakenSoul,

Just create the input with the $ES_NUMBER style. It is all in the Help file..... :evil:

M23

In 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 script

If $answer = 7 Then

MsgBox(4096, "AutoIt", "OK. Bye!")

Exit

EndIf

; Loop around until the user gives a valid "autoit" answer

$bLoop = 1

While $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

EndIf

WEnd

  • Moderators
Posted

RobertH,

Welcome to the AutoIt forum. ;)

Does this make it clear? Try entering anything other than a number! :evil:

#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).

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

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! :evil:

#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).

  • Moderators
Posted

RobertH,

Glad I could help! ;)

M23

P.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. :evil:

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

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
  • Moderators
Posted

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. :evil:

If you wanted to get really fancy we could check it was a valid employee number...... :evil:

Take a look at StringRegExp

Not necessary as we are dealing with all-number integers, thank goodness. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • 4 years later...
Posted (edited)

#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 by kootchy71
Posted

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.

  • 1 year later...
Posted
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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...