Jump to content

GUICtrlList Selection to Change $TextBox


kjbopp
 Share

Recommended Posts

Newbie question; first post... Trying to change the content of $TextBox1 based on the GUICtrlSetData selection. There has to be a cleaner way of doing this because as soon as the loop exits there's no way to reselect.

So I'm trying to stay within the GUI and when I click on the printer model, the corresponding IP will populate in the text box. Thanks in advance for any help.

CODE
#include <GUIConstants.au3>

GUICreate("My GUI")

GUICtrlCreateList("", 8, 25, 225, 97)

GUICtrlSetData(-1, "HP CM8060 MFP with Edgeline PCL 6|HP Color LaserJet 4600 PCL6|HP LaserJet 4345 mfp PCL 6")

$TextBox1 = GUICtrlCreateInput("111.11.111.11", 8, 147, 225, 21)

GUISetState()

While 1

$msg = GUIGetMsg()

$PrinterModel = GUICtrlRead(3)

$PrinterIP = GUICtrlRead(4)

;Send("{LEFT}")

If StringInStr($PrinterModel, "HP CM8060 MFP with Edgeline PCL 6") Then

$PrinterIP = "199.81.167.212"

$TextBox1 = GUICtrlCreateInput($PrinterIP, 8, 147, 225, 21)

GUISetState(@SW_SHOW)

ExitLoop

ElseIf StringInStr($PrinterModel, "HP Color LaserJet 4600 PCL6") Then

$PrinterIP = "199.81.167.79"

$TextBox1 = GUICtrlCreateInput($PrinterIP, 8, 147, 225, 21)

GUISetState(@SW_SHOW)

ExitLoop

ElseIf StringInStr($PrinterModel, "HP LaserJet 4345 mfp PCL 6") Then

$PrinterIP = "199.81.167.86"

$TextBox1 = GUICtrlCreateInput($PrinterIP, 8, 147, 225, 21)

GUISetState(@SW_SHOW)

ExitLoop

Else

If $msg = $GUI_EVENT_CLOSE Then

ExitLoop

EndIf

EndIf

WEnd

MsgBox(16, "New IP?", $PrinterModel & " " & $PrinterIP)

Link to comment
Share on other sites

Welcome to the Autoit Forums

#include <GUIConstants.au3>

GUICreate("My GUI")
GUICtrlCreateList("", 8, 25, 225, 97)
GUICtrlSetData(-1, "HP CM8060 MFP with Edgeline PCL 6|HP Color LaserJet 4600 PCL6|HP LaserJet 4345 mfp PCL 6")
$TextBox1 = GUICtrlCreateInput("111.11.111.11", 8, 147, 225, 21)
GUISetState()

While 1
    $msg = GUIGetMsg()
    $PrinterModel = GUICtrlRead(3)
    $PrinterIP = GUICtrlRead(4)
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    

    If StringInStr($PrinterModel, "HP CM8060 MFP with Edgeline PCL 6") Then
        $PrinterIP = "199.81.167.212" 
        GUICtrlSetData($TextBox1, $PrinterIP)
    ElseIf StringInStr($PrinterModel, "HP Color LaserJet 4600 PCL6") Then
        $PrinterIP = "199.81.167.79" 
        GUICtrlSetData($TextBox1, $PrinterIP)
    ElseIf StringInStr($PrinterModel, "HP LaserJet 4345 mfp PCL 6") Then
        $PrinterIP = "199.81.167.86" 
        GUICtrlSetData($TextBox1, $PrinterIP)
    EndIf
WEnd

MsgBox(16, "New IP?", $PrinterModel & " " & $PrinterIP)

Nice First Post, shows effort... :P

8)

Edited by Valuater

NEWHeader1.png

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