Jump to content

Recommended Posts

Posted

i saw something a long time ago that did detection sort of like the way i want it done this but i can't remember where it was or how it is done.Posted Image i was hoping to look at the script and apply it to mine. i screwed around with a couple of different things...but failed

here is my script. all i need help with is where the >>>> are, my explanation of what i wanted to do is in the ""

Thanks a lot in advance.

#include <GUIConstants.au3>
#include <Constants.au3>
#include <File.au3>
#include <GuiStatusBar.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
#include <GuiButton.au3>
#include <GuiEdit.au3>
#Include <WinAPI.au3>
#include <AVIConstants.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
#include <IE.au3>
#Include <Misc.au3>





$MAIN_GUI = GUICreate("Detection Test",250,300)
$INPUT_1 = GUICtrlCreateInput("",0,0,198,30,BitOR($BS_PUSHLIKE,$SS_CENTER))
$INPUT_2 = GUICtrlCreateInput("",0,32,198,30,BitOR($BS_PUSHLIKE,$SS_CENTER))
GUICtrlSetFont($INPUT_1, 14, 510, "", "Candara")
GUICtrlSetFont($INPUT_2, 14, 510, "", "Candara")
$ANSWER = GUICtrlCreateEdit("", 0, 64, 198, 214)
GUISetState()
;_invalid_detection()


While 1
    $msg = GUIGetMsg()
    Select


            Case $msg = $GUI_EVENT_CLOSE
            Exit


    EndSelect
WEnd



;Func _invalid_detection()


    Do
        $1 = GUICtrlRead($INPUT_1)
        $2 = GUICtrlRead($INPUT_2)


    If "there is an input of any character other than the characters 0-9" Then >>>>>>>>>>>>>

        GUICtrlSetData($ANSWER,"Invalid character! The input boxes can only contain numbers")
        Beep(350,350)



    If "there is an input of any character other than the characters 0-9" Then >>>>>>>>>>>>>

        GUICtrlSetData($ANSWER,"Invalid character! The input boxes can only contain numbers")
        Beep(350,350)



    Until $msg = $GUI_EVENT_CLOSE



EndFunc
Posted (edited)

Hi,

This might help....

If StringRegExp($sString, "[^\d]+") Then ; If the value of $sString is not a digit

I think in your script it might be better to just set the input to a number only input.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


$MAIN_GUI = GUICreate("Detection Test",250,300)
$INPUT_1 = GUICtrlCreateInput("",0,0,198,30,BitOR($BS_PUSHLIKE,$SS_CENTER,$ES_NUMBER)) ; set to number only control using $ES_NUMBER
$INPUT_2 = GUICtrlCreateInput("",0,32,198,30,BitOR($BS_PUSHLIKE,$SS_CENTER,$ES_NUMBER)) ; same here
GUICtrlSetFont($INPUT_1, 14, 510, "", "Candara")
GUICtrlSetFont($INPUT_2, 14, 510, "", "Candara")
$ANSWER = GUICtrlCreateEdit("", 0, 64, 198, 214)
GUISetState()


While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
;~         Case $INPUT_1, $INPUT_2
;~          _invalid_detection()
    EndSwitch

    Sleep(25)
WEnd


;~ Func _invalid_detection()
;~  Local $1 = GUICtrlRead($INPUT_1)
;~  Local $2 = GUICtrlRead($INPUT_2)

;~  If StringRegExp($1, "[^\d]+") Then
;~      GUICtrlSetData($ANSWER,"Invalid character! The input boxes can only contain numbers")
;~      Beep(350,350)
;~  ElseIf StringRegExp($2, "[^\d]+") Then
;~      GUICtrlSetData($ANSWER,"Invalid character! The input boxes can only contain numbers")
;~      Beep(350,350)
;~  EndIf
;~ EndFunc
Edited by Robjong
Posted

ummm.......Posted ImageI did not know you could do that. thanks a lot. where did you find the list of variables to use($ES_NUMBER)? i found out the other two from an example script

Posted (edited)

i never really took a good look at all of the shortcut keys and tools of autoit. so that is a big help to me.thanksPosted Image

Edited by scriptomator

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
×
×
  • Create New...