Jump to content

Run multiple scripts through the edit box


Go to solution Solved by Dan_555,

Recommended Posts

Posted

Hey guys!

I just started working with the GUI yesterday and it has only brought more fun to the Autoit adventure :) 

Basically I have a GUI windows that opens and based on the selection of the combo box the button will do something different. This specific scenario I am talking about the Client Update Verification  combo selection. When selected and the button is pressed my second gui window opens. As of now if I only paste comp1 or comp2 by itself it works correctly, but if I paste both, it has a fit.

What would the correct way to do this be? Any help or examples, would be greatly appreciated! Thank you in advance

 

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Client_List.au3>
#Region ### START Koda GUI section ### Form=c:\users\dnoble\pictures\plexiibox v4.kxf
Global $Form1_1 = GUICreate("Plexii", 336, 419, 1548, 586)
GUISetBkColor(0xFFFFFF)
Global $Pic1 = GUICtrlCreatePic("C:\Users\dnoble\Pictures\plexii.jpg", 41, 0, 252, 268, BitOR($GUI_SS_DEFAULT_PIC,$SS_CENTERIMAGE))
Global $Label2 = GUICtrlCreateLabel("Select Test", 125, 280, 95, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
Global $Combo2 = GUICtrlCreateCombo("Select Test", 39, 312, 257, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Client Update Verification|Bids")
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
Global $Button1 = GUICtrlCreateButton("Proceed", 111, 352, 129, 33)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1
            If GUICtrlRead($Combo2) = "Client Update Verification" Then _Form2()
                ;clientupdateverification()
    EndSwitch
WEnd

Func _Form2()
#Region ### START Koda GUI section ### Form=c:\users\dnoble\pictures\plexiiboxclientupdate verification.kxf
$Form1_1 = GUICreate("Plexii", 336, 521, 866, 454)
GUISetBkColor(0xFFFFFF)
$Edit1 = GUICtrlCreateEdit("", 57, 72, 241, 345)
GUICtrlSetData(-1, "Edit1")
$Button1 = GUICtrlCreateButton("Execute", 95, 440, 145, 41)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            If GUICtrlRead($Edit1) = "comp1" Then comp1()
            If GUICtrlRead($Edit1) = "comp2" Then comp2()

    EndSwitch
WEnd
EndFunc

 

edit box.png

  • Solution
Posted (edited)

Hmm, 

the code does not work here, because of the missing include. (client_list.au3)

 

I saw your question in the other thread ...  this is how you can get lines from a textfield (one by one):

 

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


#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 396, 437, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 12, 11, 291, 400)
GUICtrlSetData(-1, "Edit1")
$Button1 = GUICtrlCreateButton("Button1", 319, 18, 57, 28)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $tmp=_GUICtrlEdit_GetLineCount($Edit1)
            CW("***********")
            For $x=0 to $tmp-1
                $line=_GUICtrlEdit_GetLine($Edit1,$x)
                Cw($line)
            Next
    EndSwitch
WEnd

Func CW($txt)
    ConsoleWrite ($txt & @CRLF)
EndFunc

 

Edited by Dan_555

Some of my script sourcecode

Posted (edited)

Dan, thank you so much man!

I do have one question. It seems to throw a fit (CW() undefined function) when it is the second window in my GUI, but beautiful when its ran on its own.

Edited by Mo0C0w
Posted

CW is only a helper function which writes some text + the @crlf to the console window.

 

Func CW($txt)
    ConsoleWrite ($txt & @CRLF)
EndFunc

And CW is writing this line

$line=_GUICtrlEdit_GetLine($Edit1,$x)

to the console.

You have to adjust the $edit1 for every edit field.

$x is the line number to read out.

Some of my script sourcecode

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