Jump to content
Sign in to follow this  
JRider64

Getting Text and Selected Item from ComboBox

Recommended Posts

JRider64

I am currently trying to build an application that will pull from one Windows app and put information into another app based on certain conditions.

I am rather new to this(a day or so) so I apologize for a noob post or posting in the wrong area.

What I am trying to do:

I am trying to get the selection of a combBox that I created in the gui. With that I am going to create conditions for that selection.

Here is what I have so far: (I have commented where I cam stuck):

#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>
#include <ButtonConstants.au3>

Func sendToCher()
;; ---- Pull and send ---- ;;
$sUserConWin = WinGetHandle("User Console - 2.0.1.71")

;;--PULL
Dim $aArgs[8]
    ;NT ID Pull
    $aArgs[0] = ControlGetText($sUserConWin, '',"[NAME:txtUserName]")
    ;ID Pull
    $aArgs[1]= ControlGetText($sUserConWin, '',"[NAME:txtGID]")
    ;First name
    $aArgs[2] = ControlGetText($sUserConWin, '',"[NAME:txtFName]")
    ;Last name
    $aArgs[3] = ControlGetText($sUserConWin, '',"[NAME:txtLName]")
    ;Location
    $aArgs[4] = ControlGetText($sUserConWin, '', "[NAME:txtLocation]")
    ;Phone Number
    $aArgs[5] = ControlGetText($sUserConWin, '',"[NAME:txtContact]")
    ;Title
    $aArgs[6] = ControlGetText($sUserConWin, '',"[NAME:txtTitle]")
    ;Boss
    $aArgs[7] = ControlGetText($sUserConWin, '',"[NAME:txtBoss]")

;; Determine selection and fill string with selection conditions Working
$sTitleText = ControlGetText($hComboSystem, '','') ;;; ----- CURRENT FAILURE
$sDescription = "Test Description"


;; -- Send
$hWin = WinGetHandle("Cherwell Service Management (licensed to Gentiva Health Services)")
;Requestor
ControlSetText($hWin, "", "[CLASS:WindowsForms10.EDIT.app.0.141b42a_r13_ad1; INSTANCE:4]", $aArgs[1])
;Title
ControlSetText($hWin, "", "[CLASS:WindowsForms10.EDIT.app.0.141b42a_r13_ad1; INSTANCE:3]", $sTitleText)
;Description
ControlSetText($hWin, "", "[CLASS:WindowsForms10.RichEdit20W.app.0.141b42a_r13_ad1; INSTANCE:2]", $sDescription)
;Call source
ControlSetText($hWin, "","[CLASS:WindowsForms10.EDIT.app.0.141b42a_r13_ad1; INSTANCE:12]","Phone")
;Service
ControlSetText($hWin, "","[CLASS:WindowsForms10.EDIT.app.0.141b42a_r13_ad1; INSTANCE:6]","User Account Management")
;Category
ControlSetText($hWin, "","[CLASS:WindowsForms10.EDIT.app.0.141b42a_r13_ad1; INSTANCE:11]","Network Account")
;SubCategory
ControlSetText($hWin, "","[CLASS:WindowsForms10.EDIT.app.0.141b42a_r13_ad1; INSTANCE:10]","Password/Locked Account")
;Priority
ControlSetText($hWin, "","[CLASS:WindowsForms10.EDIT.app.0.141b42a_r13_ad1; INSTANCE:5]","Normal")

EndFunc
;; To Do
;Func statementBuilder($sTitleText, $sDescription)
;
;EndFunc


;;GUI CREATION --- START

$hGUI = GUICreate("Simple Password", 206, 89, -1, -1)
$hTicketButton= GUICtrlCreateButton("Create Ticket", 10, 60, 180, 20)
$hComboSystem = GUICtrlCreateCombo("Gentivalink", 10, 20, 170, 21)
GUICtrlSetData($hComboSystem, "Network|Passcode|Odyinfo|Harden|AS/400", "GentivaLink")
GUISetState()

While 1
    $hMsg = GUIGetMsg()
    Switch $hMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hTicketButton
            sendToCher()
    EndSwitch
WEnd

;;GUI CREATE -- END

Share this post


Link to post
Share on other sites
JLogan3o13

You are trying to get the text of $hComboSystem (line 31) in a function before you initialize it (line 65), for starters.

Edit:

Scratch that, missed your function declaration. It is usually best practice to put your "main" above any function calls, for readability.

Also, if you're trying to read the selected contents of the combobox, use GuiCtrlRead, instead of ControlGetText. GUICtrlRead is for getting the value of a control in your GUI, ControlGetText would be for getting the value of a control in an external GUI (See the help file example for ControlGetText).

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
JRider64

You are trying to get the text of $hComboSystem (line 31) in a function before you initialize it (line 65), for starters.

Edit:

Scratch that, missed your function declaration. It is usually best practice to put your "main" above any function calls, for readability.

Also, if you're trying to read the selected contents of the combobox, use GuiCtrlRead, instead of ControlGetText.

Thank you, that fixed it

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  

×