Jump to content

Recommended Posts

Posted

Howdy,

I've been a longtime lurker as well as a learner from these forums -- thank you for all your helpful contributions and insights. =) Anyway, the time has come where I am stumped by an issue and have been forced to register in order to post a question; I am sure the answer is quite simple, but I haven't been able to find the answer in my searches of the forum.

I am trying to automatically populate an inputbox ($Input2) with the data from the previous inputbox ($Input1), yet I would still like it to be able to manually edit the data ($Input2).

With the code I have, $Input2 is always the same as $Input1; I understand why, but I don't understand how to modify this behavior. I'm thinking I need some If/Then statements, but not sure how/where they need to be placed.

Hope someone can give me a hand with this... Thank you in advance.

Here is the code:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Display1 = ""
$Form1 = GUICreate("Form1", 250, 200, @DesktopWidth/2-250/2, @DesktopHeight/2-200/2)
$Input1 = GUICtrlCreateInput("", 15, 18, 220, 21)
$Input2 = GUICtrlCreateInput("", 15, 50, 220, 21)
$Button1 = GUICtrlCreateButton ("Field Values",15,150,220,21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()

    Switch $nMsg

        Case $GUI_EVENT_CLOSE
            Exit
        
        Case $Button1
            MsgBox(0,"Field Values","Input 1: " & GUICtrlRead($Input1) & @CRLF & "Input 2: " & GUICtrlRead($Input2))

        Case GUICtrlRead($Input1) <> $Display1
            $Display1 = GUICtrlRead($Input1)
            GUICtrlSetData($Input2,$Display1)
        
    EndSwitch
WEnd

[font="Courier New"]__________________________________________________There is always another way, usually a better one.[/font]

  • Moderators
Posted

TheSovereign,

Welcome to the AutoIt forums, Your Majesty....(bowing and scraping furiously) :-)

Your humble servitor begs leave to inform you that you were very nearly there:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Display1 = ""
$Form1 = GUICreate("Form1", 250, 200, @DesktopWidth/2-250/2, @DesktopHeight/2-200/2)
$Input1 = GUICtrlCreateInput("", 15, 18, 220, 21)
$Input2 = GUICtrlCreateInput("", 15, 50, 220, 21)
$Button1 = GUICtrlCreateButton ("Field Values",15,150,220,21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
      Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                  Exit
            Case $Button1
                  MsgBox(0,"Field Values","Input 1: " & GUICtrlRead($Input1) & @CRLF & "Input 2: " & GUICtrlRead($Input2))
      EndSwitch

      If GUICtrlRead($Input1) <> $Display1 Then
            $Display1 = GUICtrlRead($Input1)
            GUICtrlSetData($Input2,$Display1)
      Endif
WEnd

I have the honour to remain Your Majesty's most obedient servant. :-D

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

Wow, that's great! Thank you very much for your help, and for the fast reply!!!

I've been racking my brains :) on this one for the past day, trying all kinds of combinations and variations... except that one! :party:

And please, dispense with the formalities. :idea: It is I who am humbled by your mastery of AutoIt! =)

[font="Courier New"]__________________________________________________There is always another way, usually a better one.[/font]

Posted

#NoTrayIcon

#include <ButtonConstants.au3>

#include <EditConstants.au3>

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Form1", 295, 175, 192, 124)

$Input1 = GUICtrlCreateInput("", 64, 32, 177, 21)

$Input2 = GUICtrlCreateInput("", 62, 77, 177, 21)

$Button1 = GUICtrlCreateButton("Field Values", 104, 112, 81, 33, $WS_GROUP)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button1

MsgBox(0,"Field Values","Input 1:"& GUICtrlRead($Input1) & @CRLF & "Input 2: " & GUICtrlRead($Input2))

EndSwitch

If GUICtrlRead($Input1)<>"" Then GUICtrlSetData($Input2,GUICtrlRead($Input1))

WEnd

Posted

nanyi0509, that code does not work for me, I am unable to edit the data for $Input2...

BTW, M23's code works perfectly.

[font="Courier New"]__________________________________________________There is always another way, usually a better one.[/font]

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