Jump to content
Sign in to follow this  
PieMan

Copying text between edit boxes when the user tabs down

Recommended Posts

PieMan

I'm not sure how to do this exactly... what i want to do is when a user fills out edit box1 ($InputSDescrition) in my gui, when the tab key is pressed to go to edit box 2 ($InputLDescrition), i want the text to be copied from edit box1 to edit box2.

Can anyone help? here is my code:

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=F:\Affinity\Affinity Script Resources\icon.ico
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

    AutoIt Version: 3.3.0.0
    Author:      Hilmy Abdic

    Script Function:
    Automate matter creation in Affinity

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

WinWaitActive("Matter Creation")


$destination = "F:\Affinity\Affinity Script Resources\affinityB.JPG"

SplashImageOn("Splash Screen", $destination,288,236)
WinSetOnTop("Splash Screen", "", 1)
Sleep(3000)
SplashOff()

Global $Date, $DTM_SETFORMAT_, $style, $validation, $Alpha, $Sinput, $Linput, $Value, $InputDisb1

#include <ButtonConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$MatterCreationForm_1 = GUICreate("New Matter Creation Form", 485, 555, 192, 114)
$MenuFile = GUICtrlCreateMenu("&File")
$MenuClear = GUICtrlCreateMenuItem("Clear Fields", $MenuFile)
$MenuExit = GUICtrlCreateMenuItem("Exit", $MenuFile)
$MenuHelp = GUICtrlCreateMenu("&Help")
$MenuAbout = GUICtrlCreateMenuItem("About", $MenuHelp)
$Label1 = GUICtrlCreateLabel("*Instructed:", 8, 32, 54, 17)
$Label2 = GUICtrlCreateLabel("Matter Creation", 168, 8, 79, 17)
$Date = GUICtrlCreateDate("", 112, 32, 186, 21)
$InputAlpha = GUICtrlCreateInput("", 112, 64, 121, 21)
$InputSDescrition = GUICtrlCreateEdit("", 112, 96, 289, 57, $ES_AUTOVSCROLL + $WS_VSCROLL)
GUICtrlSetLimit($InputSDescrition, 85)
GUICtrlSetData(-1, "")
$InputLDescrition = GUICtrlCreateEdit("", 112, 168, 289, 81, $ES_AUTOVSCROLL + $WS_VSCROLL)
GUICtrlSetLimit($InputLDescrition, 400)
GUICtrlSetData(-1, "")
$InputRef = GUICtrlCreateInput("", 112, 272, 121, 21)
$Label4 = GUICtrlCreateLabel("*Short Description:", 8, 88, 88, 17)
$Label5 = GUICtrlCreateLabel("*Long Description:", 8, 168, 87, 17)
$Group1 = GUICtrlCreateGroup("Financial", 17, 305, 255, 151)
$Label7 = GUICtrlCreateLabel("Expected Value:", 24, 320, 85, 17)
$Label8 = GUICtrlCreateLabel("Credit Limits:", 72, 352, 63, 17)
$Label9 = GUICtrlCreateLabel("*Fees:", 24, 376, 30, 17)
$Label10 = GUICtrlCreateLabel("*Disbursements:", 24, 400, 76, 17)
$Label11 = GUICtrlCreateLabel("Overall Limit:", 24, 424, 64, 17)
$InputEValue = GUICtrlCreateInput("", 112, 320, 73, 21)
GUICtrlSetState(-1, $GUI_DISABLE)
$InputFees = GUICtrlCreateInput("", 109, 373, 73, 21)
$InputDisb = GUICtrlCreateInput("", 109, 397, 73, 21)
$Label13 = GUICtrlCreateLabel("(Optional)", 208, 392, 49, 17)
$InputOverLimit = GUICtrlCreateInput("", 109, 421, 73, 21)
GUICtrlSetState(-1, $GUI_DISABLE)
$ChkAuth = GUICtrlCreateCheckbox("Authority", 192, 376, 65, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Billing = GUICtrlCreateGroup("Billing", 280, 304, 169, 153)
$RadioTaxBill = GUICtrlCreateRadio("Taxable Bill", 288, 352, 113, 17)
$Label3 = GUICtrlCreateLabel("Tax Status for New  Bills:", 288, 328, 122, 17)
$RadioExportBill = GUICtrlCreateRadio("Export Bill", 288, 385, 113, 17)
$RadioOther = GUICtrlCreateRadio("Other Tax-free Bill", 288, 416, 113, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ButtonPopulate = GUICtrlCreateButton("Populate Fields", 184, 480, 123, 33, $WS_GROUP)
$Label6 = GUICtrlCreateLabel("Alpha (Optional):", 8, 64, 96, 17)
$Label12 = GUICtrlCreateLabel("Your Ref. (Optional):", 8, 272, 100, 17)
GUISetState(@SW_SHOW)
Dim $MatterCreationForm_1_AccelTable[1][2] = [["{NUM 5}", $MenuExit]]
GUISetAccelerators($MatterCreationForm_1_AccelTable)
#EndRegion ### END Koda GUI section ###


; to select a specific default format
$DTM_SETFORMAT_ = 0x1032
$style = "dd/MM/yyyy"
GUICtrlSendMsg($Date, $DTM_SETFORMAT_, 0, $style)

;Sets radio button to be checked at load
GuiCtrlSetState($RadioTaxBill, $GUI_CHECKED)

WinSetOnTop ("New Matter Creation Form", "", 1)

While 1
    $nMsg = GUIGetMsg()
    If Not WinActive($MatterCreationForm_1) Then WinActivate($MatterCreationForm_1)

Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Sleep(300)
            Run("F:\Affinity\Affinity Script Resources\New Affinity Scripts\Matter Creation reset.exe")
            Exit
        Case $ButtonPopulate
            Validation()
        If $validation = 0 Then
            BlockInput(1)
            WinSetState("New Matter Creation Form", "", @SW_MINIMIZE)
            WinActivate("Matter Creation")
            Sleep(200)
            AutoItSetOption("MouseClickDelay", 15)
            Opt("SendKeyDelay", 10)
            MatterDetails()
            Fdate()
            Sdescription()
            Ldescription()
            Financial()
            Billing()
            Contacts()
            Sleep(300)
            Run("F:\Affinity\Affinity Script Resources\New Affinity Scripts\Matter Creation reset.exe")
            Exit
        ElseIf $Validation = 1 Then
            WinSetOnTop ("New Matter Creation Form", "", 0)
            MsgBox(16, "STOP", "Not all the required fields have been enetered, please fill out the required fields (*) and try again.")
            WinSetOnTop ("New Matter Creation Form", "", 1)
        ElseIf $validation = 2 Then
            WinSetOnTop ("New Matter Creation Form", "", 0)
            MsgBox(16, "STOP", "You can only enter in numbers in the Financial section. Please amend and try again")
            WinSetOnTop ("New Matter Creation Form", "", 1)
        EndIf
        Case $MenuAbout
            WinSetOnTop ("New Matter Creation Form", "", 0)
            MsgBox(0, "About", "Written By: Hilmy Abdic V1.0")
            WinSetOnTop ("New Matter Creation Form", "", 1)
        Case $MenuExit
            Sleep(300)
            Run("F:\Affinity\Affinity Script Resources\New Affinity Scripts\Matter Creation reset.exe")
            Exit
    EndSwitch

WEnd

    func Validation()
        $validation = 0
        If GUICtrlRead($InputSDescrition) = "" Then
        $validation = 1
        ElseIf GUICtrlRead($InputLDescrition) = "" Then
        $validation = 1
        ElseIf Not StringIsDigit(GUICtrlRead($InputFees)) Then
            If Not StringIsFloat(GUICtrlRead($InputFees)) Then
            $validation = 2
            EndIf
        ElseIf Not StringIsDigit(GUICtrlRead($InputDisb)) Then
            If Not StringIsFloat(GUICtrlRead($InputDisb)) Then
            $validation = 2
            EndIf
        EndIf

    EndFunc

    Func MatterDetails()
        ControlClick("Matter Creation", "", "TBitBtn1")
        WinWaitActive("Code Selection", "")
        BlockInput(0)
        MsgBox(64, "Partner", "Please select the managing Partner for this Matter")
        WinWaitClose("Code Selection", "")
        BlockInput(1)
        WinActivate("Matter Creation")

        ControlClick("Matter Creation", "", "TBitBtn2")
        WinWaitActive("Code Selection", "")
        BlockInput(0)
        MsgBox(64, "Controller", "Please select the Controller for this Matter")
        WinWaitClose("Code Selection", "")
        BlockInput(1)
        WinActivate("Matter Creation")

        ControlClick("Matter Creation", "", "TBitBtn3")
        WinWaitActive("Code Selection", "")
        BlockInput(0)
        MsgBox(64, "Author", "Please select the Author for this Matter")
        WinWaitClose("Code Selection", "")
        BlockInput(1)
        WinActivate("Matter Creation")

        ControlClick("Matter Creation", "", "TBitBtn4")
        WinWaitActive("Code Selection", "")
        BlockInput(0)
        MsgBox(64, "Type", "Please select the Type for this Matter")
        WinWaitClose("Code Selection", "")
        BlockInput(1)
        WinActivate("Matter Creation")

    EndFunc

    Func Fdate()
        ControlClick("Matter Creation", "", "TPageControl1", "left", 1, 24, 10)
        ControlClick("Matter Creation", "", "TDateTimePicker1", "left", 1, 9, 10)
        Send(GUICtrlRead($Date))
        Send("{TAB}")
        Send("{TAB}")
    EndFunc ;==>Fdate

    Func Sdescription()
        $Alpha = GUICtrlRead($InputAlpha)
        Send($Alpha)
        Send("{TAB}")
        $Sinput = StringUpper(GUICtrlRead($InputSDescrition))
        Send($Sinput)
        Send("{TAB}")
        send("^a")
        send("{BS}")
    EndFunc ;==>Sdescription

    Func Ldescription()
        $Linput = StringUpper(GUICtrlRead($InputLDescrition))
        Send($Linput)
        Send("{TAB}")
        $Ref = GUICtrlRead($InputRef)
        Send($ref)
        Send("{TAB 5}")
        Send("{RIGHT}")
        Send("{TAB}")
    EndFunc ;==>Ldescription

    Func Financial()
        $Value = GUICtrlRead($InputFees)
        Send($Value)
        Send("{TAB 3}")
        Send($Value)
        Send("{TAB}")
        $InputDisb1 = GUICtrlRead($InputDisb)
        Send($InputDisb1)
        $total = $Value + $InputDisb1
        Send("{TAB}")
        Send($total)
        If GUICtrlRead($ChkAuth) = 1 Then
            ControlClick("Matter Creation", "", "TDBCheckBox2")
            Send("+{TAB 3}")
        Else
        EndIf
    EndFunc

    Func Billing()
        Send("+{TAB 6}")
        Send("{RIGHT 3}")
        ControlClick("Matter Creation", "", "TGroupButton4")
        Send("+{TAB 4}")
        Send("{RIGHT 2}")
        Send("{TAB 4}")
    If GUICtrlRead($RadioTaxBill) = 1 Then
    ElseIf GUICtrlRead($RadioExportBill) = 1 Then
        Send("{DOWN}")
    ElseIf GUICtrlRead($RadioOther) = 1 Then
        Send("{DOWN 2}")
    EndIf
    EndFunc

    Func Contacts()
        Send("+{TAB 4}")
        Send("{LEFT 3}")
        BlockInput(0)
        MsgBox(64, "Nearly Done...", "Please fill out all the fields in the Contacts Tab (Bill To, Contact, Referred By, Bill To Contact), Review the information and Submit. Your Done! ")

    EndFunc

Thanks,

Edited by PieMan

Share this post


Link to post
Share on other sites
Melba23

PieMan,

Add this just after your GUI creation code:

; Catch focus passing to $InputLDescrition
GUIRegisterMsg($WM_COMMAND, "ED_WM_COMMAND")

And then add this function at the end:

; credit to martin for the basis of this code
Func ED_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    Local $iCode = BitShift($wParam, 16)
    Switch $lParam
        Case GUICtrlGetHandle($InputLDescrition)
            Switch $iCode
                 Case $EN_SETFOCUS
                      If GUICtrlRead($InputLDescrition) = "" Then GUICtrlSetData($InputLDescrition, GUICtrlRead($InputSDescrition))
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc ;==>ED_WM_COMMAND

Now whenever the second edit ($InputLDescrition) gets focus, it will automatically fill with the content of the first edit ($InputSDescrition) - unless it already has some input, in which case nothing happens.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
PieMan

Wow... You are a legend mate!

Thanks!!!!

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.