Sign in to follow this  
Followers 0
Dillon

Get Text/String from Combo Box

9 posts in this topic

#1 ·  Posted (edited)

I am attempting to build an Auto It window that will interact with another program window based on user input. However, first I need to display text and information from the outside program on my Auto It window. I am attempting to get text from a Combo Box that is on the outside window and display it on my window. I can not seem to find a function that will successfully retrieve the strings from the Combo Box.

 

I tried two different functions.

First I tried '_GUICtrlComboBoxEx_GetItemText ()' as show below, but that returned me nothing.

 

'_GUICtrlComboBoxEx_GetEditText ()' came back blank as well.

 

Then I tried 'ControlGetText ()'. The problem with that function was that the ID for the Combo Box was identical to another ID for a button in the same window and it was getting the text on the button. Since 'ControlGetText ()' only uses, "title", "text", and ID, I don't see a way to pick out the ComboBox instead of the button.

 

Below, 'WinActivate ("Window")' is the window that has a Combo Box I am trying to get the String from.

 

1000 is the ID of the Combo Box in "Window".

#include <GuiComboBoxEx.au3>
#include <GuiImageList.au3>
#include <GUIConstantsEx.au3>

HotKeySet ("{Esc}", "Quit")

Local $mywindow = GUICreate ("Title", 400, 300, -1, -1)

Local $sText

Local $button = GUICtrlCreateButton ("Get Text", 100, 100)
GUISetState (@SW_SHOW, $mywindow)

While 1
Switch GUIGetMsg()
Case $button
WinActivate ("Window") ;program window that has Combo Box
_GUICtrlComboBoxEx_GetItemText (1000, 0, $sText) ;1000 is the Control ID of the Combo Box
MsgBox (0, "Control Text", $sText)
Case -3
Exit
EndSwitch
WEnd
Edited by Dillon

Share this post


Link to post
Share on other sites



The first parameter of _GUICtrlComboBoxEx_GetItemText is the hwnd (handle to the control you want to interact with).  If 1000 is the controlid, then try something like:

Local $sText
Local $hWnd ControlGetHandle("Window Title or Handle", "", 1000)
_GUICtrlComboBoxEx_GetItemText($hWnd, 0, $sText)
MsgBox(64, "info", $sText)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Are you sure that the controlID is 1000? see the return value of function you are using. A Simple Google search might find you a answer  :shifty:


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

 

The first parameter of _GUICtrlComboBoxEx_GetItemText is the hwnd (handle to the control you want to interact with).  If 1000 is the controlid, then try something like:

Local $sText
Local $hWnd ControlGetHandle("Window Title or Handle", "", 1000)
_GUICtrlComboBoxEx_GetItemText($hWnd, 0, $sText)
MsgBox(64, "info", $sText)

 

I tried this, but I still get nothing in return. My thought is that because there is a button with the same Control ID in the window "ControlGetHandle' is getting the handle for the button and not the Combo Box. I also tried using the Finder Tool in the Auto It Window Info to get the handle for the Combo Box, then plugging that in to the '_GUICtrlComboBoxEx_GetItemText' where you had the hwnd and that returned me nothing as well.

Share this post


Link to post
Share on other sites

What program are you trying to do this in?  It would save days worth of guessing...

In the mean time... Make sure you wrap the handle you get from the info tool in the Hwnd() control.

eg.

_GUICtrlComboBoxEx_GetItemText(Hwnd(0x09394298), etc...


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

What program are you trying to do this in?  It would save days worth of guessing...

In the mean time... Make sure you wrap the handle you get from the info tool in the Hwnd() control.

eg.

_GUICtrlComboBoxEx_GetItemText(Hwnd(0x09394298), etc...

 

I am trying to do this in RenWeb.

I tried the Hwnd () and it returned me a strange character I am unfamiliar with.

Share this post


Link to post
Share on other sites

You're trying to interact with a website or with an app?  I didn't see anywhere to download an app.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

You're trying to interact with a website or with an app?  I didn't see anywhere to download an app.

 

RenWeb has online uses but it also has downloadable software which is what I am using.

Here is the link to download -----> http://www.renweb.com/Support/Software-Downloads.aspx

My guess is however that you won't be able to pull up the window I am seeing because you need to purchase Product key to access.

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  
Followers 0