Jump to content

Extract input data with button


Kowala
 Share

Recommended Posts

Friends,

This is probably one of the most basic GUI functions but its stumped me. I have created a basic GUI window using Koda and created three, GUICtrlCreateInput fields, $InPN, $InDS, $InPD. I have created one, GUICtrlCreateButton, $BtnOK.

My goal is to click the $BtnOK, take the data from the three input fields ($InPN, $InDS, $InPD) and link that data to separate variables for further use in the script.

I have researched the forums and read help but the process seems to still be fuzzy to me. I have attached my basic Koda created code that represents my one window GUI interface.

Any suggestions are welcome...no rush.

With much appreciation,

Kowala

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\temp\koda\forms\doc400printer.kxf
$Form1_1 = GUICreate("Create DOC400 printer", 363, 349, 367, 213)
$InPN = GUICtrlCreateInput("", 240, 24, 105, 21)
$InDS = GUICtrlCreateInput("", 240, 112, 105, 21)
$InPD = GUICtrlCreateInput("", 240, 216, 105, 21)
$LabPN1 = GUICtrlCreateLabel("Printer Name", 16, 24, 94, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$BtnOK = GUICtrlCreateButton("Ok", 240, 296, 107, 25, 0)
$LabPN2 = GUICtrlCreateLabel("Printer name should be 10 or less", 16, 48, 201, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$LabPN3 = GUICtrlCreateLabel("alphanumeric characters.", 16, 64, 154, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$LabDS1 = GUICtrlCreateLabel("Driver Selection", 16, 112, 115, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$LabDS2 = GUICtrlCreateLabel("Deskjet models input, *HP500", 16, 136, 180, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$LabDS3 = GUICtrlCreateLabel("LaserJet models input, *HP4", 16, 152, 172, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$LabDS4 = GUICtrlCreateLabel("Savin models input, *HP8000 or *RIOCH2035", 16, 168, 268, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$InPD1 = GUICtrlCreateLabel("Printer Description", 16, 216, 132, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$InPD2 = GUICtrlCreateLabel("Input printer description (optional)", 16, 240, 200, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Select
Case $nMsg = $GUI_EVENT_CLOSE
ExitLoop
Case $nMsg = $BtnOK
    Run ('Notepad.exe')
EndSelect
WEnd
Link to comment
Share on other sites

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\temp\koda\forms\doc400printer.kxf
$Form1_1 = GUICreate("Create DOC400 printer", 363, 349, 367, 213)
$InPN = GUICtrlCreateInput("", 240, 24, 105, 21)
$InDS = GUICtrlCreateInput("", 240, 112, 105, 21)
$InPD = GUICtrlCreateInput("", 240, 216, 105, 21)
$LabPN1 = GUICtrlCreateLabel("Printer Name", 16, 24, 94, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$BtnOK = GUICtrlCreateButton("Ok", 240, 296, 107, 25, 0)
$LabPN2 = GUICtrlCreateLabel("Printer name should be 10 or less", 16, 48, 201, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$LabPN3 = GUICtrlCreateLabel("alphanumeric characters.", 16, 64, 154, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$LabDS1 = GUICtrlCreateLabel("Driver Selection", 16, 112, 115, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$LabDS2 = GUICtrlCreateLabel("Deskjet models input, *HP500", 16, 136, 180, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$LabDS3 = GUICtrlCreateLabel("LaserJet models input, *HP4", 16, 152, 172, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$LabDS4 = GUICtrlCreateLabel("Savin models input, *HP8000 or *RIOCH2035", 16, 168, 268, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$InPD1 = GUICtrlCreateLabel("Printer Description", 16, 216, 132, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$InPD2 = GUICtrlCreateLabel("Input printer description (optional)", 16, 240, 200, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Select
Case $nMsg = $GUI_EVENT_CLOSE
ExitLoop
Case $nMsg = $BtnOK
    $Pn = GUICtrlRead($InPN)
    $DS = GUICtrlRead($InDS)
    $PD = GUICtrlRead(($InPD)
       ; Inputs are in read into variables above
    Run ('Notepad.exe')
EndSelect
WEnd

Link to comment
Share on other sites

Maybe...

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\temp\koda\forms\doc400printer.kxf
$Form1_1 = GUICreate("Create DOC400 printer", 363, 349, 367, 213)
$InPN = GUICtrlCreateInput("", 240, 24, 105, 21)
$InDS = GUICtrlCreateInput("", 240, 112, 105, 21)
$InPD = GUICtrlCreateInput("", 240, 216, 105, 21)
$LabPN1 = GUICtrlCreateLabel("Printer Name", 16, 24, 94, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$BtnOK = GUICtrlCreateButton("Ok", 240, 296, 107, 25, 0)
$LabPN2 = GUICtrlCreateLabel("Printer name should be 10 or less", 16, 48, 201, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$LabPN3 = GUICtrlCreateLabel("alphanumeric characters.", 16, 64, 154, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$LabDS1 = GUICtrlCreateLabel("Driver Selection", 16, 112, 115, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$LabDS2 = GUICtrlCreateLabel("Deskjet models input, *HP500", 16, 136, 180, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$LabDS3 = GUICtrlCreateLabel("LaserJet models input, *HP4", 16, 152, 172, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$LabDS4 = GUICtrlCreateLabel("Savin models input, *HP8000 or *RIOCH2035", 16, 168, 268, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$InPD1 = GUICtrlCreateLabel("Printer Description", 16, 216, 132, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$InPD2 = GUICtrlCreateLabel("Input printer description (optional)", 16, 240, 200, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $nMsg = $BtnOK
            $InPN2 = GUICtrlRead($InPN)
            Run('Notepad.exe')
            WinWait("")
            Send($InPN2, 1)
    EndSelect
WEnd

8)

................ Too Slow.........................

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