Jump to content

Autofilling input depending data from another input [solved]


Tipulatoid
 Share

Recommended Posts

Hello all

I have such GUI:

#include <GuiConstants.au3>
$MainGui = GUICreate('test', 300, 150)
$Label1 = GUICtrlCreateLabel ("E-mail", 5, 10, 40, 17)
$Input1 = GUICtrlCreateInput ("sample@uknown.com", 50, 10, 150)
$Email = GUICtrlRead ($Input1)
$SplitEmail = StringSplit ($Email, "@")
$Label2 = GUICtrlCreateLabel ("SMTP", 5, 40, 40, 17)
$Input2 = GUICtrlCreateInput ("smtp." & $SplitEmail[2], 50, 40, 150)


GUISetState ()


While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
       Exit
    
    EndSelect
WEnd

I need "on fly" autofilling '$Input2' when user types e-mail in '$Input1'. When he enters "@" character, then the string "smtp." must appear in '$Input2' and all the characters he types after "@". But '$Input2' box must be available for next editing, so I can't place this code in the main loop. Please help. And sorry for bad English.

Edited by Tipulatoid
Link to comment
Share on other sites

Hello all

I have such GUI:

I need "on fly" autofilling '$Input2' when user types e-mail in '$Input1'. When he enters "@" character, then the string "smtp." must appear in '$Input2' and all the characters he types after "@". But '$Input2' box must be available for next editing, so I can't place this code in the main loop. Please help. And sorry for bad English.

#include <GuiConstantsEx.au3>
#include <editconstants.au3>
#include <windowsconstants.au3>
$MainGui = GUICreate('test', 300, 150)
$Label1 = GUICtrlCreateLabel("E-mail", 5, 10, 40, 17)
$Input1 = GUICtrlCreateInput("sample@uknown.com", 50, 10, 150)
$Email = GUICtrlRead($Input1)
$SplitEmail = StringSplit($Email, "@")
$Label2 = GUICtrlCreateLabel("SMTP", 5, 40, 40, 17)
$Input2 = GUICtrlCreateInput("smtp." & $SplitEmail[2], 50, 40, 150)


GUISetState()
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND");only used for EN_CHANGE so far

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit

    EndSelect
WEnd



Func WM_COMMAND($hWnd, $imsg, $iwParam, $ilParam)
    Local $AtPos, $s1
    $nNotifyCode = BitShift($iwParam, 16)
    $nID = BitAND($iwParam, 0x0000FFFF)
    $hCtrl = $ilParam
    
    If $nNotifyCode = $EN_CHANGE Then
        If $ilParam = GUICtrlGetHandle($Input1) Then
            $s1 = GUICtrlRead($Input1)
            $AtPos = StringInStr($s1, '@')
            If $AtPos Then
                GUICtrlSetData($Input2, "smpt." & StringRight($s1, StringLen($s1) - $AtPos))
            EndIf
        EndIf
        
    EndIf

    Return $GUI_RUNDEFMSG
    

EndFunc  ;==>WM_COMMAND
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Many thanks, martin! That's great.

That's ok. :)
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...