Jump to content

Want to restrict input to specific words/characters


 Share

Recommended Posts

$CommannameSAN = GUICtrlCreateInput("", 8, 159, 241, 25, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY,$WS_CLIPSIBLINGS), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetFont($CommannameSAN, 11, 400, 0, "Calibri")
GUICtrlSetOnEvent($CommannameSAN, "CommannameSAN")

 

Tried using

if GUICtrlRead ($CommannameSAN) = "*.domain.com" or "*.domain.domain.com" Then
    MsgBox (0, "STOP", "STOP", "","")
Else
    EndIf

 

and also

 

_RegEx_RestrictControl_add ($CommannameSAN, "*.domain.com" or "*.domain.domain.com)

 

So basically i need to restrict and stop if the input if guictrlread reads *.domain.com" or "*.domain.domain.com, dont want uses to use a wild cards...

 

Link to comment
Share on other sites

Use Stringinstr to search for '*' and split by '.' dots count the dots, if more than x then jump.

So in a string like *.domain.domain.com if you check for the *, that excludes it, also if there are more than 2 dots, jump and so on.

Did that make sense for you?

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

@Cyborg5000
I think that there are some other ways to do it, but take a look at this one:

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

Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=
$frmMainForm = GUICreate("A Form", 285, 162, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "ExitApplication")
$txtInput = GUICtrlCreateInput("", 20, 24, 249, 24)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
GUISetState(@SW_SHOW, $frmMainForm)

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd


Func ExitApplication()
    Exit
EndFunc

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    Local $hdlWindowFrom, _
          $intControlID_From, _
          $intMessageCode, _
          $strInputText = ""


    $intControlID_From = BitAND($wParam, 0xFFFF)
    $intMessageCode = BitShift($wParam, 16)

    Switch $intControlID_From
        Case $txtInput
            Switch $intMessageCode
                Case $EN_CHANGE

                    $strInputText = GUICtrlRead($txtInput)
                    If StringInStr($strInputText, "*.domain.com") Or StringInStr($strInputText, "*.domain.domain.com") Then
                        ConsoleWrite("This wildcard is not accepted!" & @CRLF)
                        ; If you want to clear the user input
                        ; GUICtrlSetData($txtInput, "")
                        ; If you want to make the input read-only
                        GUICtrlSetStyle($txtInput, $ES_READONLY)
                    EndIf
                    ; ConsoleWrite($strInputText & " ")

            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG

EndFunc


Cheers :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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